Wiki source code of SSC-32 Binary Commands

Last modified by Eric Nantel on 2023/01/24 11:41

Show last authors
1 {{html wiki="false" clean="true"}}
2 <body>
3 <div id="container">
4 <p align="center"><span class="headlg">SSC-32 Binary Commands.</span>
5 </p><p align="center"><!--Author: Mike Dvorsky<br>-->
6 Version: 1.00<br>
7 Date: Apr 25, 2011</p>
8 <p align="center"><span class="headmd">Table of Contents</span></p>
9 <table border="0" width="100%">
10 <tbody><tr>
11 <td width="50%" valign="top">
12 <ul class="toc">
13 <li><a href="https://wiki.lynxmotion.com/info/wiki/lynxmotion/view/servo-erector-set-system/ses-electronics/ses-modules/ssc-32/ssc-32-binary-commands/#overview">Binary Command Overview</a></li>
14 <li><a href="https://wiki.lynxmotion.com/info/wiki/lynxmotion/view/servo-erector-set-system/ses-electronics/ses-modules/ssc-32/ssc-32-binary-commands/#srvmov">Binary Servo Move or Group Move</a></li>
15 <li><a href="https://wiki.lynxmotion.com/info/wiki/lynxmotion/view/servo-erector-set-system/ses-electronics/ses-modules/ssc-32/ssc-32-binary-commands/#qpwidth">Query Pulse Width</a></li>
16 <li><a href="https://wiki.lynxmotion.com/info/wiki/lynxmotion/view/servo-erector-set-system/ses-electronics/ses-modules/ssc-32/ssc-32-binary-commands/#stopall">Stop All</a></li>
17 <li><a href="https://wiki.lynxmotion.com/info/wiki/lynxmotion/view/servo-erector-set-system/ses-electronics/ses-modules/ssc-32/ssc-32-binary-commands/#ssc32ex">Atom / SSC-32 Binary Test Example</a></li>
18 </ul>
19 </td>
20 <td width="50%" valign="top">&nbsp; </td>
21 </tr>
22 </tbody></table>
23 <hr width="95%" color="#808080">
24 <p align="center"><span class="headmd"><a name="overview">Binary Command Overview</a></span></p>
25 <p>Some of the more recent General Purpose Sequencer versions of the SSC-32 firmware have added an additional set of commands to support some of the more commonly used operations of the SSC-32, but in a shorter more concise format.</p>
26 <p>These commands are in a binary non-human readable format. That is up till now all of the commands that were sent to the SSC-32 were such that all of the characters in the command were in the normal human readable range of a space character, which has the value 32 decimal (hex 20) up to the "~" character which has the value 126 (hex 7E) and the commands were variable length and were executed when the user sent the Carriage Return, which has a value 13 decimal (D hex). This format is great for being able to enter commands through programs like Lynxterm. However having a textual commands set causes the programs to have to send (or receive) several characters over the relatively slow communication port and some programs needed a faster mechanism.</p>
27 <p>So a few new commands were added that supported a fixed binary format. These commands are distinguished from other commands as their first character starts out side of the human readable range. In particular they are in the range 128-255 (Hex 80-FF).</p>
28 <hr width="95%" color="#808080">
29 <p align="center"><span class="headmd"><a name="srvmov">Binary Servo Move or Group Move</a></span></p>
30 <p>0x80 - 0x9F are the pulse width commands, and specify a servo number 0-31 (0x80=servo0, 0x81=servo1, etc.). The next 2 bytes must be the desired pulse width in microseconds, MSB first.</p>
31 <p>0xA0 is the optional speed command for a servo. It must immediately follow the pulse width command for the servo, and the next 2 bytes must be the max speed in microseconds/second.</p>
32 <p>0xA1 is the move time. It is required for a group move, and the move will not begin until the move time is received. The next 2 bytes must be the move time in milliseconds. If you want the move to be as fast as possible, just specify a move time of 0.</p>
33 <p>As an example, the group move "#0P1000 #1P1500S1000 #3P2000 T1000
34 &lt;cr&gt;" is equivalent to the following (hex) bytes in an extended binary command:</p>
35 <p>Code: 80 03 E8 81 05 DC A0 03 E8 83 07 D0 A1 03 E8</p>
36 <p>Like the standard group move command, you can combine the speed and time commands if desired. The speed for each servo will be calculated according to the following rules:</p>
37 <ol>
38 <li> All channels will start and end the move simultaneously.</li>
39 <li>If a speed is specified for a servo, it will not move any faster than the speed specified (but it might move slower if the time command requires).</li>
40 <li>If a time is specified for the move, then the move will take at least the amount of time specified (but might take longer if the speed command requires). </li>
41 </ol>
42 <p>Any move that involves more than one servo is considered a Group Move, and all servos will start and stop moving at the same time. If you require moving several servos at different speeds, you must issue the commands separately.</p>
43 <hr width="95%" color="#808080">
44 <p align="center"><span class="headmd"><a name="qpwidth">Query Pulse Width</a></span></p>
45 <p><span lang="EN-GB">The binary query command is 5 bytes. The servos are specified using a bitmap, with each servo being represented by a bit. The 5 bytes are:</span></p>
46 <p><span lang="EN-GB"> - byte 1 = command byte, and servos 0-3<br>
47 - byte 2 = servos 4-10<br>
48 - byte 3 = servos 11-17<br>
49 - byte 4 = servos 18-24<br>
50 - byte 5 = servos 25-31<br>
51 <br>
52 In more detail:</span></p>
53 <p><span lang="EN-GB"> - byte 1 = (binary) 1 0 1 1 s3 s2 s1 s0<br>
54 - byte 2 = (binary) 0 s10 s9 s8 s7 s6 s5 s4<br>
55 - byte 3 = (binary) 0 s17 s16 s15 s14 s13 s12 s11<br>
56 - byte 4 = (binary) 0 s24 s23 s22 s21 s20 s19 s18<br>
57 - byte 5 = (binary) 0 s31 s30 s29 s28 s27 s26 s25<br>
58 <br>
59 The numbers s0 through s31 represent servos 0-31. A 1 bit requests the value for the servo.<br>
60 <br>
61 Byte 1 starts with bits 1011, or 0xB, which is the start of binary query commands. The other bytes all start with a 0 bit.<br>
62 <br>
63 So, for example, to query servos 0, 3, 4, 12, 21, and 31, you would use the following bytes:</span></p>
64 <p><span lang="EN-GB"> 10111001 = 0xB9<br>
65 00000001 = 0x01<br>
66 00000010 = 0x02<br>
67 00001000 = 0x08<br>
68 01000000 = 0x40<br>
69 <br>
70 serout p0,i38400,[0xB9,0x01,0x02,0x08,0x40]<br>
71 <br>
72 The result of this command will be 12 bytes, 2 bytes per servo requested. They will be in order starting with S0 through S31. There is no prefix byte.<br>
73 <br>
74 You can request any number of servos, and it will take 5 bytes to make the request regardless of the number of servos requested. The number of bytes returned will be 2x the number of servos requested. Servo pulse widths are returned most significant byte first.<br>
75 <br>
76 The SSC-32 will send the servos as fast as it can, honoring the delay and pacing values that have been set.<br>
77 <br>
78 WARNING: After sending a query command, do not send any other commands until all of the servo pulse widths have been received back from the SSC-32. If you do, this may corrupt the servo pulse widths being sent, and you might get some garbage values.</span></p>
79 <hr width="95%" color="#808080">
80 <p align="center"><span class="headmd"><a name="stopall">Stop All Command</a></span></p>
81 <p>Hex 0xA2 (Dec 162) is the stop all command, which immediately stops all servos where they are. It does not require any additional bytes.</p>
82 <hr width="95%" color="#808080">
83 <p align="center"><span class="headmd"><a name="ssc32ex">Atom / SSC-32 Binary Test Example</a></span></p>
84 <div class="code">
85 <blockquote>
86 <span class="comment"><p>' Atom / SSC-32 Extended Binary Command Test<br>
87 '**********************************************************************<br>
88 'Extended binary commands.<br>
89 '<br>
90 'Commands 0x80-0x9F are group move servo number 0-31.Â&nbsp; The next 2 bytes<br>
91 'must be pulse width for the servo:<br>
92 'Â&nbsp;Â&nbsp;Â&nbsp; 0x80+servoNum, pwHigh, pwLow<br>
93 '<br>
94 'Command 0xA0 is the group move servo speed, which must immediately<br>
95 'follow the pulse width:<br>
96 'Â&nbsp;Â&nbsp;Â&nbsp; 0xA0, spdHigh, spdLow<br>
97 '<br>
98 'Command 0xA1 is the group move time, which must follow all of the<br>
99 'pulse widths and speeds:<br>
100 'Â&nbsp;Â&nbsp;Â&nbsp; 0xA1, timeHigh, timeLow<br>
101 '<br>
102 'Command 0xA2 is the stop all command, 1 byte<br>
103 'Â&nbsp;Â&nbsp;Â&nbsp; 0xA2</p>
104 <p>'**********************************************************************</p></span>
105 <p>servonum var byte<br>
106 servopw var word<br>
107 servospd var word<br>
108 movetime var word</p>
109 <p><span class="comment">'**** Move to initial position ****<br>
110 'Same as #0P2000 #31P1600 T0<br>
111 '2000 = 0x07D0<br>
112 '1600 = 0x0640</span><br>
113 serout p0,i38400,[0x80,0x07,0xD0,0x81,0x06,0x40,0xA1,0x00,0x00]</p>
114 </blockquote>
115 <p> start:</p>
116 <blockquote>
117 <p><span class="comment">'Same as #0P1000 #31P1400 T2000</span></p>
118 <p>servonum=0<br>
119 servopw = 1000<br>
120 serout p0,i38400,[0x80+servonum,servopw.highbyte,servopw.lowbyte]<br>
121 servonum=31<br>
122 servopw = 1400<br>
123 serout p0,i38400,[0x80+servonum,servopw.highbyte,servopw.lowbyte]<br>
124 movetime = 2000<br>
125 serout p0,i38400,[0xA1,movetime.highbyte,movetime.lowbyte]<br>
126 pause 2500</p>
127 <p><span class="comment">'Same as #0P2000 #31P1600 T1500</span><br>
128 servonum=0<br>
129 servopw = 2000<br>
130 serout p0,i38400,[0x80+servonum,servopw.highbyte,servopw.lowbyte]<br>
131 servonum=31<br>
132 servopw = 1600<br>
133 serout p0,i38400,[0x80+servonum,servopw.highbyte,servopw.lowbyte]<br>
134 movetime = 1500<br>
135 serout p0,i38400,[0xA1,movetime.highbyte,movetime.lowbyte]<br>
136 pause 2500</p>
137 <p><span class="comment">'Same as #0P1000S500 #31P1400 T100<br>
138 '(Even though the move time is 100ms, this move will take 2 seconds because<br>
139 'servo0 needs to move 1000us and is limited to 500us/second.)</span></p>
140 <p>servonum=0<br>
141 servopw = 1000<br>
142 servospd = 500<br>
143 serout p0,i38400,[0x80+servonum,servopw.highbyte,servopw.lowbyte]<br>
144 serout p0,i38400,[0xA0,servospd.highbyte,servospd.lowbyte]<br>
145 servonum=31<br>
146 servopw = 1400<br>
147 serout p0,i38400,[0x80+servonum,servopw.highbyte,servopw.lowbyte]<br>
148 movetime = 100<br>
149 serout p0,i38400,[0xA1,movetime.highbyte,movetime.lowbyte]<br>
150 pause 2500</p>
151 <p><span class="comment">'Same as #0P2000 #31P1600 T2000</span><br>
152 servonum=0<br>
153 servopw = 2000<br>
154 serout p0,i38400,[0x80+servonum,servopw.highbyte,servopw.lowbyte]<br>
155 servonum=31<br>
156 servopw = 1600<br>
157 serout p0,i38400,[0x80+servonum,servopw.highbyte,servopw.lowbyte]<br>
158 movetime = 2000<br>
159 serout p0,i38400,[0xA1,movetime.highbyte,movetime.lowbyte]<br>
160 <span class="comment">'Pause only 500ms, so the move will not be complete after the pause</span><br>
161 pause 500</p>
162 <p><span class="comment">'**** Stop the previous move part way ****<br>
163 'Same as STOP</span><br>
164 serout p0,i38400,[0xA2]<br>
165 pause 2500</p>
166 <p><span class="comment">'**** Finish the move ****<br>
167 'Same as #0P2000 #31P1600 T1500</span><br>
168 servonum=0<br>
169 servopw = 2000<br>
170 serout p0,i38400,[0x80+servonum,servopw.highbyte,servopw.lowbyte]<br>
171 servonum=31<br>
172 servopw = 1600<br>
173 serout p0,i38400,[0x80+servonum,servopw.highbyte,servopw.lowbyte]<br>
174 movetime = 1500<br>
175 serout p0,i38400,[0xA1,movetime.highbyte,movetime.lowbyte]<br>
176 pause 2500<br>
177 goto start</p>
178 </blockquote>
179 </div>
180 </div>
181 </body>
182 {{/html}}
Copyright RobotShop 2018