Protocols

eputtone edited this page Aug 19, 2012 · 34 revisions

XBee communication protocols

PC to Micro Controller (version 2)

Send commands to Micro Controller.

TODO

PC to Micro Controller (version 1)

Send commands to Micro Controller.

  • PC sends direct commands to motors. Rover keeps driving at these commands until next instruction:
  • left motor: 50% forward, right motor 100% backwards

Messages are fixed length messages, consisting of bytes. Start and end of each message are magic bytes.

  • Start bytes (in hex): 52 61 (ASCII codes for 'R' and 'a')
  • Left engine speed 0-255
  • Left engine direction: 42 = backwards, 46 = forwards ('B' and 'F')
  • Right engine speed 0-255
  • Right engine direction: 42 = backwards, 46 = forwards ('B' and 'F')
  • Pan servo angle (allowed values 40-140: 40=right, 90=forward, 140=almost left - these values are degrees * 2)
  • Tilt servo angle (allowed values 0-120: 120=horizontal - these values are degrees)
  • Control byte 1:
  • bits 0 and 1 are reserved for blue lights
  • 00 and 11-> don't change state (bit 0 is first)
  • 01 -> turn off lights
  • 10 -> turn on lights
  • bit 3 is reserved for the camera
  • 1xx -> take a picture
  • End bytes (in hex): 69 73 ('i' and 's')

Motor speed values are inserted directly to Arduino ports. It is up to PC handle situations where motors are not equal.

Example: 52 61 ff 42 ff 46 02 69 73 // rotate in place, turn on lights

Micro Controller to PC

Send sensor readings to PC.

  • Distance measurements / servo directions
  • Rotational speed of wheels
  • Inertial measurements
  • Sound sensor readings?

Protocol should support adding and removing sensors. Every message doesn't have to have data from all sensors.

Example:

Line oriented ASCII messages:

STA;RL10;RR20;NO1012;SR60;SD72,IR5;END;\n
STA;NO1013;RL12;RR1;SR65;SD72;IR60;ID78;TE10;END;\n

Messages start with STA field, end with END field. Every other field has two letter header. Fields end with ; - character. STA and END are mandatory, other fields are optional. Fields can occur in any order, except STA is always first and END is always last.

  • STA = start of message
  • END = end of message
  • NO = message number, starting at 1 when the device is powered up.
  • RL = encoder value for left wheel encoder (ticks since last message)
  • RR = encoder value for right wheel encoder (ticks since last message)
  • SR = current direction for ultra sound distance sensor (forwards) (degrees 0-180)
  • ST = current direction for ultra sound distance sensor (backwards) (degrees 180-360)
  • SD = distance value from ultra sound distance sensor pointing forward (direct sensor reading, must be converted to cm)
  • Sd = distance value from ultra sound distance sensor pointing forward (value in cm)
  • TD = distance value from ultra sound distance sensor pointing backward (direct sensor reading, must be converted to cm)
  • Td = distance value from ultra sound distance sensor pointing backward(value in cm)
  • IR = current direction for infra red distance sensor (forwards) (degrees 0-180)
  • JR = current direction for infra red distance sensor (backwards) (degrees 180-360)
  • ID = distance value from infra red distance sensor pointing forward (direct sensor reading, must be converted to cm)
  • Id = distance value from infra red distance sensor pointing forward (value in cm)
  • JD = distance value from infra red distance sensor pointing backward (direct sensor reading, must be converted to cm)
  • Jd = distance value from infra red distance sensor pointing backward (value in cm)
  • CD = compass heading
  • TI = milliseconds since Arduino started. Measured just before sending, after taking all the measurements.
  • GX = gyroscope x-value (direct value from sensors)
  • GY = gyroscope y-value
  • GZ = gyroscope z-value
  • Gx = gyroscope x-value (in degrees/sec)
  • Gy = gyroscope y-value
  • Gz = gyroscope z-value
  • AX = accelerometer x-value (direct value from sensors)
  • AY = accelerometer y-value
  • AZ = accelerometer z-value
  • Ax = accelerometer x-value (in m/s^2)
  • Ay = accelerometer y-value
  • Az = accelerometer z-value
  • CA = JPEG picture contents (bytes) as hexadecimal numbers