Close

Super Brief Documentation

A project log for Moti, a smart servo

Moti is a smart servo that simplifies the design of intricate robots.

nicholas-stedmanNicholas Stedman 10/08/2014 at 04:310 Comments

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.

begin(SerialPort)
- initializes a moti with stored settings, and uses the provided Serial port for communicating over network.

reset()
- reset to default settings.

update()
- force motor update critical processes including checking for network messages, reading encoder, and changing motion as necessary.

close()
- shut down the motor.

rotate(int speed)
- 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()
- Stop moving and hold position.

freeSpin()
- Cut power to motor. Will rotate under external load.

speedWrite(int speed)
- Set the speed...affects any motion in progress.

loadWrite(int load)
- Set the stall torque of the motor.

angleLimitsWrite(int cwLimit, int ccwLimit)
- Set the angle limits. Limits motion between the specified limits.

angleRead()
- reads the encoder, and returns angle as int.

speedRead()
- calculates and returns the rotations per minute as int.

currentRead()
- reads the current sensor, and returns current measurement as int.

temperatureRead()
- reads the temperature sensor, and returns temperature as int.

voltageRead()
- reads the voltage sensor, and returns voltage as int.

analogRead(int pin)
- reads ADC value of the specified A2D pin, and returns the raw value as int.

digitalRead(int pin)
- 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.

registersRead(byte register)
- 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.

nameRead()
- reads and returns an 8 char array used to store a user-designated label for the moti.

nameWrite(char name[])
- writes 8 chars of the given array to a block of moti registers. Meant to store a user-designated label for the moti.

enumerate()
- query all available motis on the network. They will each reply with their unique ID.

ping(int id)
- check for the specified motor on the network.

messageAvailable()
- checks the network port for new message and returns the length of the message as an int, or 0 if no message.

messageRead(byte data[])
- 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.

messageWrite(struct message)
- 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[8]), 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.

Discussions