Cmd: Sensors
updated on 06-11-2009

dsNav communication

Detailed commands description
Constant parameters setting group commands

Commands (Cmd field) are one single character long and case sensitive.           

In following list:

- r        this is a command that request parameters reading from dsNav to the master

- w       this is a command that writes parameters to dsNav from the master

- TX    these are the parameters sent from supervisor and received by dsNav

- RX    these are the data sent back by dsNav after a correct decoding of the command and received by external board or PC.

The TxData and RxData procedures will be used as example. The code examples are written in Processing language on the PC side.

J

- w

Settings PID coefficients for DistPid: DistKP, DistKI, DistKD

Data

0 – 1     DistKp

2 – 3     DistKi

4 – 5     DistKd

            - TX:

                        CmdLen = 7    Params 6 (3 int MSF) = (Kx * 10000) range 0 9999

DistKp = InputDistKp.getValue();

      DistKi = InputDistKi.getValue();

      DistKd = InputDistKd.getValue();

      TxIntValue[0] = DistKp;

      TxIntValue[1] = DistKi;

      TxIntValue[2] = DistKd;

      TxData(0, 'J', 3, 1);

            - RX:

                        N/A

 

K

- w

Settings PID coefficients for SpeedPID:

Data

0 – 1     Kp right

2 – 3     Ki right

4 – 5     Kd right

6 – 7     Kp left

8 – 9     Ki left

10 – 11 Kd left

            - TX:

                        CmdLen = 13  Params 12 (6 int MSF) = (Kx * 10000) range 0 9999

Example:

KpR = InputDistKpR.getValue();

      KiR = InputDistKiR.getValue();

      KdR = InputDistKdR.getValue();

KpL = InputDistKpL.getValue();

      KiL = InputDistKiL.getValue();

      KdL = InputDistKdL.getValue();

TxIntValue[0] = KpR;

      TxIntValue[1] = KiR;

      TxIntValue[2] = KdR;

      TxIntValue[3] = KpL;

      TxIntValue[4] = KiL;

      TxIntValue[5] = KdL:;

      TxData(0, 'K', 6, 1);

            - RX:

                        N/A

k

- w

Settings PID coefficients for AnglePid: AngleKP, AngleKI, AngleKD

            - TX:

                        CmdLen = 7    Params 6 (3 int MSF) = (Kx * 10000) range 0 9999

Example:

AngleKp = InputAngleKp.getValue();

      AngleKi = InputAngleKi.getValue();

      AngleKd = InputAngleKd.getValue();

      TxIntValue[0] = AngleKp;

      TxIntValue[1] = AngleKi;

      TxIntValue[2] = AngleKd;

      TxData(0, 'k', 3, 1);

            - RX:

                        N/A

 

L

- w

Speed constant parameters designation: KvelR, KvelL

Read detailed explanations on how to compute these values

            - TX:

                        CmdLen = 9    Params 8 (2 long MSF) = KvelX

Example:

K = InputAxle.getValue();           

      Wheel1 = InputWheel1.getValue();

      Wheel2 = InputWheel2.getValue();     

      Cpr = InputCpr.getValue();      

      Gear = InputGear.getValue();

 

Kvel1=(Wheel1*PI*Fcy*32768) /(Cpr*Gear*1000) ;

      Kvel2=(Wheel2*PI*Fcy*32768) /(Cpr*Gear*1000) ;

      TxIntValue[0] = (int)(Kvel1);

      TxIntValue[1] = (int)(Kvel2);

      TxData(0, 'L', 2, 2);

            - RX:

                        N/A

 

M

- w

Mechanical costants:

Axle size: the length of the axle as the distance between the center of right and left wheels

KspR, KspL: the space traveled by the wheel for every single encoder tick (Right and Left)

            - TX:

                        CmdLen = 13  Params 12 (3 long MSF)

Example:

K = InputAxle.getValue();           

      Wheel1 = InputWheel1.getValue();

      Wheel2 = InputWheel2.getValue();     

      Cpr = InputCpr.getValue();     

      Gear = InputGear.getValue();

     

      Ksp1 = (long)((Wheel1*PI*1000)/(Cpr*Gear*4));

      Ksp2 = (long)((Wheel2*PI*1000)/(Cpr*Gear*4));

      TxIntValue[0] = K/100;

      TxIntValue[1] = (int)(Ksp1);

      TxIntValue[2] = (int)(Ksp2);

      TxData(0, 'M', 3, 2);

            - RX:

                        N/A