2 months ago •
Moti Firmware API Documentation The Super Brief Version
Here's synopses of the API methods provided for using Moti in the Arduino environment. Once I actually finish coding the methods I'll post more complete documentation...but this gives you the idea.
- initializes a moti with stored settings, and uses the provided Serial port for communicating over network.
- reset to default settings.
- force motor update critical processes including checking for network messages, reading encoder, and changing motion as necessary.
- shut down the motor.
- Keep on going at the given speed
rotateTo(int speed, int angle)
- Goto a specific angle at the given speed
rotateFor(int speed, int degrees)
- Turn for the given number degrees relative to the current position.
- Stop moving and hold position.
- Cut power to motor. Will rotate under external load.
- Set the speed...affects any motion in progress.
- Set the stall torque of the motor.
angleLimitsWrite(int cwLimit, int ccwLimit)
- Set the angle limits. Limits motion between the specified limits.
- reads the encoder, and returns angle as int.
- calculates and returns the rotations per minute as int.
- reads the current sensor, and returns current measurement as int.
- reads the temperature sensor, and returns temperature as int.
- reads the voltage sensor, and returns voltage as int.
- reads ADC value of the specified A2D pin, and returns the raw value as int.
- reads the binary state of specified pin, and returns the state as int.
analogWrite(int pin, int value)
- writes a PWM value to a PWM pin.
digitalWrite(int pin, int value)
- writes a binary value to a pin.
registersRead(int register, byte data, int length)
- reads a block of moti registers into the provided array.
registersRead(int register, int data)
- reads two consecutive 8-bit registers, and returns them as a single int.
- reads and returns a single register as a byte
registersWrite(int register, byte data, int length)
- writes a byte array to a block of moti registers.
registersWrite(int register, int data)
- writes each half of an int to two consecutive moti registers.
registersWrite(int register, byte data)
- writes a byte to a moti register.
- reads and returns an 8 char array used to store a user-designated label for the moti.
- writes 8 chars of the given array to a block of moti registers. Meant to store a user-designated label for the moti.
- query all available motis on the network. They will each reply with their unique ID.
- check for the specified motor on the network.
- checks the network port for new message and returns the length of the message as an int, or 0 if no message.
- checks the network port for new message and saves it to provided array.
messageParse(byte data, int length)
- decipher the message, and return a struct containing the ID of the Moti, the command, the parameters, the length of the message, and other parameters if available.
- packetize and send a message over the network containing the IDs of both sender and receiver, the command, the parameters, the length of the message, and other parameters if available.
N.B. int here means uint16_t, and byte means uint8_t.
N.B. Methods can be overloaded by providing an ID (int) as the last parameter, or a name (char), in which case this Moti will trigger the operation to occur on the designated Moti in the network if available. The only exceptions are begin(), enumerate() and ping(). Overloaded methods are not shown here for brevity.