SMRD communication

From Rsewiki
(Difference between revisions)
Jump to: navigation, search
 
Line 109: Line 109:
 
  Robot PSU voltage:  Vpsu = 4.1 * 3.5 / 1.1 / 1024 * ADin.  [V]
 
  Robot PSU voltage:  Vpsu = 4.1 * 3.5 / 1.1 / 1024 * ADin.  [V]
 
  Battery Chg Current: Ichg = ADin * 3 [mA].
 
  Battery Chg Current: Ichg = ADin * 3 [mA].
  Battery Temp 1: Tbatt = ADin [0.1 °C].
+
  Battery Temp 1:     Tbatt = ADin [0.1 °C].
  Battery SOC: Bsoc = ADin [% remaining capacity]
+
  Battery SOC:         Bsoc = ADin [% remaining capacity]
  
 
----
 
----

Latest revision as of 11:50, 5 February 2009

Normally, the SMR C library copes with communication between a user's program and the SMR sensor daemon SMRD.

This page documents this communication.


Connect

SMRD listens for TCP/IP connections on port 24901. Multiple clients (up to ten) can be connected at once.


Data Packets

The communication protocol is byte oriented and binary coded.

Data both from client to server, and from server to client, is sent in packets. Each packet starts with a length byte, specifying the number of bytes to follow. For example:

0x04 0x10 0x20 0x30 0x40

Only the lower 5 bits of the first byte give the length. The upper 3 bits describe the source/destination of the packet:

  0b000?????:   RS485 master/slave serial bus
  0b001?????:   RS232 serial port
  0b011?????:   AU simulator packet
  0b111?????:   SMRD control packet

Poll

Clients start the communication by sending a client ready packet:

0xE1 0x02

The server responds with a number of packets. First, a start of period. This is followed by a series of data packets. Finally, an end of period packet is sent.


Start of period

0xE9 0x00 <sample no.> <time stamp>
  <sample no.>:   4 byte (integer) sample number
  <time stamp>:   4 byte (integer) cpu clock time stamp

Motor data

The two motors on an SMR are numbered 1 and 2. In the following, replace i with the motor number.

Some motor modules return more data than others. The length byte distinguishes between module types.

0x03 0xAi <encoder position>
0x05 0xAi <encoder position> <status> <pwm>
  <encoder position>:   2 byte (integer). 2000 positions per wheel turn.
  <status>:   1 byte status
  <pwm>:   1 byte motor drive voltage

MSB is to the left, for example: encoder position = 256*byte2 + byte3.


IR proximity data

0x09 0x88 <proximity data>
  <proximity data>:   8 bytes (array of bytes) proximity data. The first 6 bytes contain measurement data.

Serial line sensor

The serial port line sensor sends 16 bytes of sensor data; typically split into 2 or more packets. So, the length fields can vary from packet, and from sample to sample. A typical period might look like this:

0x27 0x73 <6 bytes serial data>
0x2B 0x73 <10 bytes serial data>
  <serial data>:   Up to 16 bytes (array of bytes) serial data. The first 8 bytes contain measurement data.

Other packets may be received between serial port packets.


RS485 line sensor

0x09 0x17 <line sensor data>
  <line sensor data>:   8 bytes (array of bytes) line sensor data.

Power module

0x08 0x19 0b<fedcbaAA> 0b<BBCCDDEE> 0b<AAAAAAAA> 0b<BBBBBBBB> 0b<CCCCCCCC> 0b<DDDDDDDD> 0b<EEEEEEEE>
  fedcba:   Digital input channels 5 to 0.
  AAAAAAAAAA...EEEEEEEEEE:   Analog input (10 bits) channels 0 to 4. The two MSBs come from one of the pairs in byte 2 or 3. LSB is to the right.

The module inputs are connected as follows:

  Digital input 0:   Power on.
  Digital input 1...5:   Unused.
  Analog input 0:   Battery voltage.
  Analog input 1:   External supply voltage.
  Analog input 2,3,4:   Unused.

To convert analog input readings to volts:

Vin = 4.1 * 3.5 / 1.1 / 1024 * ADin


New Power Module v. 3.3b (firmware 3.31+)

Data is sent in same format as the old module

The module inputs are connected as follows:

  Digital input 0 (a):   Power on.
  Digital input 1 (b):   External Power Connected.
  Digital input 2 (c):   Robot is charging.
  Digital input 3 (d):   Robot is calibrating battery
  Digital input 4..5 (e..f):   Unused.
  Analog input 0 (A):   Battery voltage.
  Analog input 1 (B):   Robot Power Supply voltage.
  Analog input 2 (C):   Battery charge current.
  Analog input 3 (D):   Battery temperature sensor 1.
  Analog input 4 (E):   Battery state-of-charge.

To convert analog input readings into usable values:

Battery voltage:     Vbatt = 4.1 * 3.5 / 1.1 / 1024 * ADin. [V]
Robot PSU voltage:   Vpsu = 4.1 * 3.5 / 1.1 / 1024 * ADin.  [V]
Battery Chg Current: Ichg = ADin * 3 [mA].
Battery Temp 1:      Tbatt = ADin [0.1 °C].
Battery SOC:         Bsoc = ADin [% remaining capacity]

End of period

SMRD signals that the period is finished by sending end of period.

0xE1 0x01

No more packets will be sent to the client until a new poll is started.


Simulation time

When SMRdemo is connected to the simulator, it will receive the simulation time just before the end of period packet.

0x69 0x01 <simulation time>
  <simulation time>: 8 byte (double) simulation time.
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox