Initial commit for stepper controller
[radiotelescope.git] / stepper_controller / arduino / stepper / stepper.qm
1 <?xml version="1.0" encoding="UTF-8"?>
2 <model version="1.0.01" framework="qpn">
3   <package name="Events" stereotype="0x01"/>
4   <package name="AOs" stereotype="0x02">
5     <class name="Serial" superclass="../../0/1">
6       <documentation>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
7 &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
8 p, li { white-space: pre-wrap; }
9 &lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Tahoma'; font-size:8pt; font-weight:400; font-style:normal;&quot;&gt;
10 &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Serial command parser and message transmitter&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</documentation>
11       <attribute name="attr1" type="" visibility="0x00" properties="0x00"/>
12       <operation name="ctor" type="void" visibility="0x00" properties="0x01"/>
13       <statechart>
14         <state name="Operational">
15           <entry/>
16           <exit/>
17           <initial target="../1">
18             <action/>
19           </initial>
20           <state name="Parsing">
21             <entry>me-&gt;parser = me-&gt;menu;</entry>
22             <exit/>
23             <tran trig="RX_CHAR">
24               <choice guard="isterm(pa.msg.ch)">
25                 <action/>
26                 <choice guard="me-&gt;parser != me-&gt;menu" target="../../../..">
27                   <action>transmitNACK();
28 </action>
29                 </choice>
30               </choice>
31               <choice guard="else">
32                 <action>{
33     uint8_t ch = (SerialRxMsg *)(&amp;PAR(me))-&gt;ch; 
34
35     while (me-&gt;menu-&gt;ch) {
36         if (me-&gt;menu-&gt;ch != ch) {
37             me-&gt;menu++;
38             continue;
39         }
40         /* match ch in menu */
41         </action>
42               </choice>
43             </tran>
44           </state>
45           <state name="TerminatingNACK">
46             <entry/>
47             <exit>me-&gt;vidx=0;</exit>
48             <tran trig="RX_CHAR">
49               <choice guard="isterm(pa.msg.ch)" target="../../../1">
50                 <action>transmitNACK();</action>
51               </choice>
52             </tran>
53           </state>
54           <state name="state1">
55             <entry/>
56             <exit/>
57           </state>
58         </state>
59         <state_diagram size="604,381">
60           <state_glyph ref="0" node="486,309,116,69"/>
61           <state_glyph ref="0/1" node="543,314,50,19">
62             <text box="0,2,18,4"/>
63           </state_glyph>
64           <state_glyph ref="0/2" node="511,361,25,11">
65             <text box="0,2,5,2"/>
66           </state_glyph>
67           <state_glyph ref="0/3" node="543,343,57,11"/>
68           <tran_glyph ref="0/1/0" conn="543,322,3,-1,13">
69             <text box="1,0,9,2"/>
70           </tran_glyph>
71           <choice_glyph ref="0/1/0/0" conn="556,322,5,-1,16">
72             <text box="1,-2,14,2"/>
73           </choice_glyph>
74           <choice_glyph ref="0/1/0/0/0" conn="572,322,5,1,30">
75             <text box="2,-4,19,4"/>
76           </choice_glyph>
77           <tran_glyph ref="0/2/0" conn="511,368,3,-1,10">
78             <text box="1,0,9,2"/>
79           </tran_glyph>
80           <choice_glyph ref="0/2/0/0" conn="521,368,5,3,19,-39,3">
81             <text box="1,0,15,5"/>
82           </choice_glyph>
83           <initial_glyph ref="0/0" conn="539,314,4,3,3,4">
84             <text box="2,-1,6,2"/>
85           </initial_glyph>
86           <choice_glyph ref="0/1/0/1" conn="556,322,4,-1,8,16">
87             <text box="1,1,27,6"/>
88           </choice_glyph>
89         </state_diagram>
90       </statechart>
91     </class>
92     <class name="UI" superclass="../../0/1">
93       <documentation>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
94 &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
95 p, li { white-space: pre-wrap; }
96 &lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Tahoma'; font-size:8pt; font-weight:400; font-style:normal;&quot;&gt;
97 &lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2';&quot;&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</documentation>
98       <attribute name="serialCommand" type="SerialCommand" visibility="0x02" properties="0x00"/>
99       <attribute name="txBuffer[UI_TX_BUFFER_LENGTH]" type="char" visibility="0x02" properties="0x00"/>
100       <operation name="ctor" type="void" visibility="0x00" properties="0x01">
101         <code>QActive_ctor((QActive *)&amp;AO_UI, (QStateHandler)&amp;UI_initial);
102 SerialCommand_ctor(&amp;AO_UI.serialCommand, (QActive *)&amp;AO_UI, menu, menuSignal, AO_UI.txBuffer, UI_TX_BUFFER_LENGTH, 0, 9600);
103 </code>
104       </operation>
105       <statechart>
106         <initial target="../1">
107           <action/>
108         </initial>
109         <state name="User">
110           <entry/>
111           <exit/>
112           <tran trig="SERIAL_RX_DATA">
113             <action>serialDispatch(&amp;me-&gt;serialCommand, SERIAL_RX_DATA_SIG, Q_PAR(me));</action>
114           </tran>
115           <tran trig="SERIAL_TX_EMPTY">
116             <action>serialDispatch(&amp;me-&gt;serialCommand, SERIAL_TX_EMPTY_SIG, Q_PAR(me));</action>
117           </tran>
118           <tran trig="COMMAND_FAIL">
119             <action>serialNACK(&amp;me-&gt;serialCommand, 0);</action>
120           </tran>
121           <tran trig="COMMAND_AZIMUTH">
122             <action>QActive_post((QActive *)&amp;AO_azimuth, SET_BASE_SPEED_SIG, Q_PAR(me));
123 QActive_post((QActive *)&amp;AO_azimuth, SET_ACCELERATION_SIG,
124 me-&gt;serialCommand.vargs[1].v.param);
125 QActive_post((QActive *)&amp;AO_azimuth, SET_SLEW_SPEED_SIG,
126 me-&gt;serialCommand.vargs[2].v.param);
127 QActive_post((QActive *)&amp;AO_azimuth, SET_TOTAL_STEPS_SIG,
128 me-&gt;serialCommand.vargs[3].v.param);
129 serialReleaseVargs(&amp;me-&gt;serialCommand);
130 serialACK(&amp;me-&gt;serialCommand, 1);</action>
131           </tran>
132           <tran trig="COMMAND_AZIMUTH_BASE">
133             <action>QActive_post((QActive *)&amp;AO_azimuth, SET_BASE_SPEED_SIG, Q_PAR(me));
134 serialACK(&amp;me-&gt;serialCommand, 1);</action>
135           </tran>
136           <tran trig="COMMAND_AZIMUTH_SLEW">
137             <action>QActive_post((QActive *)&amp;AO_azimuth, SET_SLEW_SPEED_SIG, Q_PAR(me));
138 serialACK(&amp;me-&gt;serialCommand, 1);</action>
139           </tran>
140           <tran trig="COMMAND_AZIMUTH_ACCELERATION">
141             <action>QActive_post((QActive *)&amp;AO_azimuth, SET_ACCELERATION_SIG, Q_PAR(me));
142 serialACK(&amp;me-&gt;serialCommand, 1);</action>
143           </tran>
144           <tran trig="COMMAND_AZIMUTH_STEPS">
145             <action>QActive_post((QActive *)&amp;AO_azimuth, SET_TOTAL_STEPS_SIG, Q_PAR(me));
146 serialACK(&amp;me-&gt;serialCommand, 1);</action>
147           </tran>
148           <tran trig="COMMAND_ELEVATION">
149             <action>QActive_post((QActive *)&amp;AO_elevation, SET_BASE_SPEED_SIG, Q_PAR(me));
150 QActive_post((QActive *)&amp;AO_elevation, SET_ACCELERATION_SIG,
151 me-&gt;serialCommand.vargs[1].v.param);
152 QActive_post((QActive *)&amp;AO_elevation, SET_SLEW_SPEED_SIG,
153 me-&gt;serialCommand.vargs[2].v.param);
154 QActive_post((QActive *)&amp;AO_elevation, SET_TOTAL_STEPS_SIG,
155 me-&gt;serialCommand.vargs[3].v.param);
156 serialReleaseVargs(&amp;me-&gt;serialCommand);
157 serialACK(&amp;me-&gt;serialCommand, 1);</action>
158           </tran>
159           <tran trig="COMMAND_ELEVATION_BASE">
160             <action>QActive_post((QActive *)&amp;AO_elevation, SET_BASE_SPEED_SIG, Q_PAR(me));
161 serialACK(&amp;me-&gt;serialCommand, 1);</action>
162           </tran>
163           <tran trig="COMMAND_ELEVATION_SLEW">
164             <action>QActive_post((QActive *)&amp;AO_elevation, SET_SLEW_SPEED_SIG, Q_PAR(me));
165 serialACK(&amp;me-&gt;serialCommand, 1);</action>
166           </tran>
167           <tran trig="COMMAND_ELEVATION_ACCELERATION">
168             <action>QActive_post((QActive *)&amp;AO_elevation, SET_ACCELERATION_SIG, Q_PAR(me));
169 serialACK(&amp;me-&gt;serialCommand, 1);</action>
170           </tran>
171           <tran trig="COMMAND_ELEVATION_STEPS">
172             <action>QActive_post((QActive *)&amp;AO_elevation, SET_TOTAL_STEPS_SIG, Q_PAR(me));
173 serialACK(&amp;me-&gt;serialCommand, 1);</action>
174           </tran>
175           <tran trig="SERIAL_RX_ERROR">
176             <action>serialDispatch(&amp;me-&gt;serialCommand, SERIAL_RX_ERROR_SIG, Q_PAR(me));</action>
177           </tran>
178           <tran trig="SERIAL_TX_COMPLETE">
179             <action>serialDispatch(&amp;me-&gt;serialCommand, SERIAL_TX_COMPLETE_SIG, Q_PAR(me));</action>
180           </tran>
181           <tran trig="COMMAND_START_AZIMUTH">
182             <action>QActive_post((QActive *)&amp;AO_azimuth, START_LINEAR_SLEW_SIG, 0);
183 serialACK(&amp;me-&gt;serialCommand, 1);</action>
184           </tran>
185           <tran trig="COMMAND_START_ELEVATION">
186             <action>QActive_post((QActive *)&amp;AO_elevation, START_LINEAR_SLEW_SIG, 0);
187 serialACK(&amp;me-&gt;serialCommand, 1);</action>
188           </tran>
189           <tran trig="COMMAND_START_AZ_EL">
190             <action>QActive_post((QActive *)&amp;AO_azimuth, START_LINEAR_SLEW_SIG, 0);
191 QActive_post((QActive *)&amp;AO_elevation, START_LINEAR_SLEW_SIG, 0);
192 serialACK(&amp;me-&gt;serialCommand, 1);</action>
193           </tran>
194           <tran trig="COMMAND_AZIMUTH_CLOCKWISE">
195             <action>QActive_post((QActive *)&amp;AO_azimuth, SET_DIRECTION_UP_CW_SIG, 0);
196 serialACK(&amp;me-&gt;serialCommand, 1);</action>
197           </tran>
198           <tran trig="COMMAND_AZIMUTH_CCW">
199             <action>QActive_post((QActive *)&amp;AO_azimuth, SET_DIRECTION_DOWN_CCW_SIG, 0);
200 serialACK(&amp;me-&gt;serialCommand, 1);</action>
201           </tran>
202           <tran trig="COMMAND_ELEVATION_UP">
203             <action>QActive_post((QActive *)&amp;AO_elevation, SET_DIRECTION_UP_CW_SIG, 0);
204 serialACK(&amp;me-&gt;serialCommand, 1);</action>
205           </tran>
206           <tran trig="COMMAND_ELEVATION_DOWN">
207             <action>QActive_post((QActive *)&amp;AO_elevation, SET_DIRECTION_DOWN_CCW_SIG, 0);
208 serialACK(&amp;me-&gt;serialCommand, 1);</action>
209           </tran>
210         </state>
211         <state_diagram size="174,125">
212           <state_glyph ref="1" node="6,6,115,115"/>
213           <initial_glyph ref="0" conn="11,3,5,0,5,3">
214             <text box="1,0,4,2"/>
215           </initial_glyph>
216           <tran_glyph ref="1/2" conn="6,16,3,-1,55">
217             <text box="1,0,29,4"/>
218           </tran_glyph>
219           <tran_glyph ref="1/3" conn="6,22,3,-1,55">
220             <text box="1,0,55,19"/>
221           </tran_glyph>
222           <tran_glyph ref="1/4" conn="6,42,3,-1,55">
223             <text box="1,0,51,6"/>
224           </tran_glyph>
225           <tran_glyph ref="1/5" conn="6,49,3,-1,55">
226             <text box="1,0,51,6"/>
227           </tran_glyph>
228           <tran_glyph ref="1/13" conn="6,102,3,-1,48">
229             <text box="1,0,48,6"/>
230           </tran_glyph>
231           <tran_glyph ref="1/1" conn="6,108,3,-1,48">
232             <text box="1,0,49,5"/>
233           </tran_glyph>
234           <tran_glyph ref="1/14" conn="6,114,3,-1,48">
235             <text box="1,0,53,5"/>
236           </tran_glyph>
237           <tran_glyph ref="1/0" conn="6,96,3,-1,48">
238             <text box="1,0,49,6"/>
239           </tran_glyph>
240           <tran_glyph ref="1/6" conn="6,56,3,-1,55">
241             <text box="1,0,51,7"/>
242           </tran_glyph>
243           <tran_glyph ref="1/7" conn="6,63,3,-1,55">
244             <text box="1,0,51,6"/>
245           </tran_glyph>
246           <tran_glyph ref="1/8" conn="121,22,1,-1,-55">
247             <text box="-53,0,51,18"/>
248           </tran_glyph>
249           <tran_glyph ref="1/9" conn="121,42,1,-1,-55">
250             <text box="-53,0,51,6"/>
251           </tran_glyph>
252           <tran_glyph ref="1/10" conn="121,49,1,-1,-55">
253             <text box="-53,0,51,6"/>
254           </tran_glyph>
255           <tran_glyph ref="1/11" conn="121,56,1,-1,-55">
256             <text box="-53,0,52,6"/>
257           </tran_glyph>
258           <tran_glyph ref="1/12" conn="121,63,1,-1,-55">
259             <text box="-53,0,52,7"/>
260           </tran_glyph>
261           <tran_glyph ref="1/15" conn="6,84,3,-1,55">
262             <text box="1,0,51,6"/>
263           </tran_glyph>
264           <tran_glyph ref="1/16" conn="121,84,1,-1,-55">
265             <text box="-53,0,51,6"/>
266           </tran_glyph>
267           <tran_glyph ref="1/17" conn="121,91,1,-1,-55">
268             <text box="-53,0,51,7"/>
269           </tran_glyph>
270           <tran_glyph ref="1/18" conn="6,70,3,-1,55">
271             <text box="1,0,54,6"/>
272           </tran_glyph>
273           <tran_glyph ref="1/19" conn="6,77,3,-1,55">
274             <text box="1,0,50,6"/>
275           </tran_glyph>
276           <tran_glyph ref="1/20" conn="121,70,1,-1,-55">
277             <text box="-53,0,53,7"/>
278           </tran_glyph>
279           <tran_glyph ref="1/21" conn="121,77,1,-1,-55">
280             <text box="-53,0,50,6"/>
281           </tran_glyph>
282         </state_diagram>
283       </statechart>
284     </class>
285     <class name="Stepper" superclass="../../0/1">
286       <documentation>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
287 &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
288 p, li { white-space: pre-wrap; }
289 &lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Tahoma'; font-size:8pt; font-weight:400; font-style:normal;&quot;&gt;
290 &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;A common stepper motor HSM for azimuth and elevation motion&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</documentation>
291       <attribute name="basePeriod" type="double" visibility="0x02" properties="0x00"/>
292       <attribute name="slewTimer" type="uint32_t" visibility="0x02" properties="0x00"/>
293       <attribute name="totalSlewSteps" type="uint32_t" visibility="0x02" properties="0x00"/>
294       <attribute name="accelerationFactor" type="double" visibility="0x02" properties="0x00"/>
295       <attribute name="stepPeriod" type="double" visibility="0x02" properties="0x00"/>
296       <attribute name="stepTimer" type="uint32_t" visibility="0x02" properties="0x00"/>
297       <attribute name="slewStepCount" type="uint32_t" visibility="0x02" properties="0x00"/>
298       <attribute name="decelerationStep" type="uint32_t" visibility="0x02" properties="0x00"/>
299       <attribute name="stepPosition" type="int32_t" visibility="0x02" properties="0x00"/>
300       <attribute name="direction" type="int8_t" visibility="0x02" properties="0x00"/>
301       <attribute name="queueStepTime" type="FPQueueStepTime" visibility="0x02" properties="0x00"/>
302       <attribute name="setDirection" type="FPSetDirection" visibility="0x02" properties="0x00"/>
303       <operation name="ctor" type="void" visibility="0x00" properties="0x01">
304         <code>/* Configure AO_azimuth Stepper */
305 AO_azimuth.queueStepTime = BSP_nextStepTimer3;
306 AO_azimuth.setDirection = BSP_azimuthDirection;
307 QActive_ctor((QActive *)&amp;AO_azimuth, (QStateHandler)&amp;Stepper_initial);
308 BSP_initStepTimer3((QActive *)&amp;AO_azimuth);
309 BSP_initAzimuthFault((QActive *)&amp;AO_azimuth);
310 /* Configure AO_elevation Stepper */
311 AO_elevation.queueStepTime = BSP_nextStepTimer4;
312 AO_elevation.setDirection = BSP_elevationDirection;
313 QActive_ctor((QActive *)&amp;AO_elevation, (QStateHandler)&amp;Stepper_initial);
314 BSP_initStepTimer4((QActive *)&amp;AO_elevation);
315 BSP_initElevationFault((QActive *)&amp;AO_elevation);</code>
316       </operation>
317       <statechart>
318         <initial target="../1">
319           <action/>
320         </initial>
321         <state name="operational">
322           <entry>initialiseStepperData(me);
323 </entry>
324           <exit/>
325           <initial target="../2">
326             <action/>
327           </initial>
328           <state name="LinearAccelerator">
329             <entry>setupLinearAccelerator(me);
330 (*me-&gt;setDirection)(me-&gt;direction);
331 </entry>
332             <exit/>
333             <initial target="../3">
334               <action/>
335             </initial>
336             <tran trig="STEPPER_FAULT" target="../../2"/>
337             <state name="LinearDecelerate">
338               <entry>decelerationStepPeriod(me);
339 (*me-&gt;queueStepTime)(me-&gt;stepTimer);</entry>
340               <exit/>
341               <tran trig="NEXT_STEP_TIME">
342                 <action>me-&gt;slewStepCount++;
343 me-&gt;stepPosition += me-&gt;direction;</action>
344                 <choice guard="me-&gt;slewStepCount &lt;  me-&gt;totalSlewSteps">
345                   <action>decelerationStepPeriod(me);
346 (*me-&gt;queueStepTime)(me-&gt;stepTimer);</action>
347                 </choice>
348                 <choice guard="else" target="../../../../2">
349                   <action/>
350                 </choice>
351               </tran>
352             </state>
353             <state name="LinearAccelerate">
354               <entry>(*me-&gt;queueStepTime)(me-&gt;stepTimer);
355 accelerationStepPeriod(me);</entry>
356               <exit/>
357               <tran trig="NEXT_STEP_TIME">
358                 <action>me-&gt;slewStepCount++;
359 me-&gt;stepPosition += me-&gt;direction;</action>
360                 <choice guard="else" target="../../../2">
361                   <action/>
362                 </choice>
363                 <choice guard="me-&gt;slewStepCount &lt; me-&gt;decelerationStep">
364                   <action/>
365                   <choice guard="me-&gt;stepTimer &gt; me-&gt;slewTimer">
366                     <action>(*me-&gt;queueStepTime)(me-&gt;stepTimer);
367 accelerationStepPeriod(me);</action>
368                   </choice>
369                   <choice guard="else" target="../../../../4">
370                     <action>me-&gt;stepTimer = me-&gt;slewTimer;
371 me-&gt;decelerationStep =
372 me-&gt;totalSlewSteps - me-&gt;slewStepCount;</action>
373                   </choice>
374                 </choice>
375               </tran>
376             </state>
377             <state name="LinearConstantSpeed">
378               <entry>(*me-&gt;queueStepTime)(me-&gt;stepTimer);</entry>
379               <exit/>
380               <tran trig="NEXT_STEP_TIME">
381                 <action>me-&gt;slewStepCount++;
382 me-&gt;stepPosition += me-&gt;direction;</action>
383                 <choice guard="me-&gt;slewStepCount &lt;  me-&gt;decelerationStep">
384                   <action>(*me-&gt;queueStepTime)(me-&gt;stepTimer);</action>
385                 </choice>
386                 <choice guard="else" target="../../../2">
387                   <action/>
388                 </choice>
389               </tran>
390             </state>
391           </state>
392           <state name="Stopped">
393             <entry/>
394             <exit/>
395             <tran trig="SET_BASE_SPEED">
396               <action>/* Calculate and store (double)basePeriod */
397 UParam p; p.param = Q_PAR(me);
398 me-&gt;basePeriod =
399 AZIMUTH_CLOCK_DBL / p.dbl; </action>
400             </tran>
401             <tran trig="SET_SLEW_SPEED">
402               <action>/* Calculate and store (uint32_t)slewPeriod */
403 UParam p; p.param = Q_PAR(me);
404 me-&gt;slewTimer = (uint32_t)
405 (AZIMUTH_CLOCK_DBL / p.dbl);</action>
406             </tran>
407             <tran trig="SET_ACCELERATION">
408               <action>/* Calculate and store derived factor */
409 UParam p; p.param = Q_PAR(me);
410 me-&gt;accelerationFactor = p.dbl
411 / AZIMUTH_CLOCK_DBL
412 / AZIMUTH_CLOCK_DBL;</action>
413             </tran>
414             <tran trig="SET_TOTAL_STEPS">
415               <action>UParam p; p.param = Q_PAR(me);
416 me-&gt;totalSlewSteps = p.uint32;</action>
417             </tran>
418             <tran trig="START_LINEAR_SLEW">
419               <choice guard="me-&gt;totalSlewSteps &gt; 0" target="../../../1">
420                 <action/>
421               </choice>
422             </tran>
423             <tran trig="SET_DIRECTION_UP_CW">
424               <action>me-&gt;direction = 1;</action>
425             </tran>
426             <tran trig="SET_DIRECTION_DOWN_CCW">
427               <action>me-&gt;direction = -1;</action>
428             </tran>
429           </state>
430         </state>
431         <state_diagram size="207,143">
432           <state_glyph ref="1" node="3,6,201,133">
433             <text box="0,2,30,8"/>
434           </state_glyph>
435           <state_glyph ref="1/2" node="6,19,30,54"/>
436           <state_glyph ref="1/1" node="39,11,70,80">
437             <text box="0,2,34,6"/>
438           </state_glyph>
439           <state_glyph ref="1/1/2" node="45,68,61,19">
440             <text box="0,2,32,6"/>
441           </state_glyph>
442           <state_glyph ref="1/1/3" node="42,19,64,24">
443             <text box="0,2,36,7"/>
444           </state_glyph>
445           <state_glyph ref="1/1/4" node="45,47,61,19">
446             <text box="0,2,36,8"/>
447           </state_glyph>
448           <initial_glyph ref="0" conn="9,3,5,0,4,3">
449             <text box="1,0,6,2"/>
450           </initial_glyph>
451           <tran_glyph ref="1/2/0" conn="6,24,3,-1,28">
452             <text box="1,0,32,9"/>
453           </tran_glyph>
454           <tran_glyph ref="1/2/1" conn="6,34,3,-1,28">
455             <text box="1,0,29,9"/>
456           </tran_glyph>
457           <tran_glyph ref="1/2/2" conn="6,44,3,-1,28">
458             <text box="1,0,29,11"/>
459           </tran_glyph>
460           <tran_glyph ref="1/2/3" conn="6,56,3,-1,28">
461             <text box="1,0,27,6"/>
462           </tran_glyph>
463           <tran_glyph ref="1/2/4" conn="17,73,2,-1,9">
464             <text box="1,1,19,2"/>
465           </tran_glyph>
466           <initial_glyph ref="1/1/0" conn="75,16,5,0,4,3">
467             <text box="1,0,6,2"/>
468           </initial_glyph>
469           <tran_glyph ref="1/1/3/0" conn="42,28,3,-1,24">
470             <text box="1,0,23,7"/>
471           </tran_glyph>
472           <choice_glyph ref="1/1/3/0/0" conn="66,28,4,3,17,-24,28,3">
473             <text box="1,7,6,2"/>
474           </choice_glyph>
475           <choice_glyph ref="1/1/3/0/1" conn="66,28,5,-1,11,6">
476             <text box="1,-2,52,2"/>
477           </choice_glyph>
478           <tran_glyph ref="1/2/5" conn="6,63,3,-1,28">
479             <text box="1,0,24,4"/>
480           </tran_glyph>
481           <tran_glyph ref="1/2/6" conn="6,68,3,-1,28">
482             <text box="1,0,27,5"/>
483           </tran_glyph>
484           <choice_glyph ref="1/1/3/0/1/0" conn="77,34,5,-1,27">
485             <text box="1,-6,27,6"/>
486           </choice_glyph>
487           <choice_glyph ref="1/1/3/0/1/1" conn="77,34,4,0,13">
488             <text box="1,1,28,8"/>
489           </choice_glyph>
490           <tran_glyph ref="1/1/4/0" conn="45,58,3,-1,26">
491             <text box="1,0,25,7"/>
492           </tran_glyph>
493           <choice_glyph ref="1/1/4/0/0" conn="71,58,5,-1,28">
494             <text box="1,-4,31,4"/>
495           </choice_glyph>
496           <choice_glyph ref="1/1/4/0/1" conn="71,58,4,0,10">
497             <text box="1,4,10,4"/>
498           </choice_glyph>
499           <tran_glyph ref="1/1/2/0" conn="45,78,3,-1,26">
500             <text box="1,0,25,10"/>
501           </tran_glyph>
502           <choice_glyph ref="1/1/2/0/0" conn="71,78,5,-1,29">
503             <text box="1,-6,49,7"/>
504           </choice_glyph>
505           <choice_glyph ref="1/1/2/0/1" conn="71,78,4,2,11,-62,-16">
506             <text box="1,4,6,2"/>
507           </choice_glyph>
508           <choice_glyph ref="1/2/4/0" conn="17,82,5,3,22">
509             <text box="1,-3,18,3"/>
510           </choice_glyph>
511           <initial_glyph ref="1/0" conn="14,16,5,0,4,3">
512             <text box="1,0,6,2"/>
513           </initial_glyph>
514           <tran_glyph ref="1/1/1" conn="39,86,3,2,-26,-13">
515             <text box="-21,-2,17,2"/>
516           </tran_glyph>
517         </state_diagram>
518       </statechart>
519     </class>
520   </package>
521   <filesystem path=".">
522     <directory name="qm_code">
523       <file name="stepper.h">
524         <text>//
525 // Product: Radiotelescope - Stepper Motor Controller
526 // Version: 0.1
527 // Date:    25 November 2010
528 //
529 //                      +-----------------------+
530 //                      |   d e c i s i o n s   |
531 //                      +-----------------------|
532 //                      | a n d   d e s i g n s |
533 //                      +-----------------------+
534 //
535 // Copyright (C) 2009 Decisions and Designs Pty Ltd. All rights reserved.
536 //
537 // This software may be distributed and modified under the terms of the GNU
538 // General Public License version 2 (GPL) as published by the Free Software
539 // Foundation and appearing in the file GPL.TXT included in the packaging of
540 // this file. Please note that GPL Section 2[b] requires that all works based
541 // on this software must also be made publicly available under the terms of
542 // the GPL (&quot;Copyleft&quot;).
543 //
544 // Contact information:
545 // Decisions and Designs Web site: http://www.decisions-and-designs.com.au
546 // e-mail:                         [email protected]
547 //
548
549 #ifndef stepper_h
550 #define stepper_h
551
552 #include &quot;bsp.h&quot; /* for board specific STEP_PERIOD macro */
553
554 /* Stepping definitions */
555 #define SLOW_STEP_PERIOD STEP_PERIOD(500000L)
556 #define MIN_SETUP_TIME STEP_PERIOD(1000L) 
557 #define MID_SET_TIME   0x8000   
558 #define MAX_SETUP_TIME (0xffff - PULSE_TIME)
559 #define PULSE_TIME     STEP_PERIOD(100L)
560
561 #define STEPPER_SIGS()          \
562     NEXT_STEP_TIME_SIG,         \
563     SET_ACCELERATION_SIG,       \
564     SET_BASE_SPEED_SIG,         \
565     SET_SLEW_SPEED_SIG,         \
566     SET_TOTAL_STEPS_SIG,        \
567     SET_DIRECTION_UP_CW_SIG,    \
568     SET_DIRECTION_DOWN_CCW_SIG, \
569     START_LINEAR_SLEW_SIG
570
571 #endif                                                         /* stepper_h */
572 </text>
573       </file>
574       <file name="ui.c">
575         <text>//
576 // Product: Radiotelescope - Stepper Motor Controller
577 // Version: 0.1
578 // Date:    25 November 2010
579 //
580 //                      +-----------------------+
581 //                      |   d e c i s i o n s   |
582 //                      +-----------------------|
583 //                      | a n d   d e s i g n s |
584 //                      +-----------------------+
585 //
586 // Copyright (C) 2009 Decisions and Designs Pty Ltd. All rights reserved.
587 //
588 // This software may be distributed and modified under the terms of the GNU
589 // General Public License version 2 (GPL) as published by the Free Software
590 // Foundation and appearing in the file GPL.TXT included in the packaging of
591 // this file. Please note that GPL Section 2[b] requires that all works based
592 // on this software must also be made publicly available under the terms of
593 // the GPL (&quot;Copyleft&quot;).
594 //
595 // Contact information:
596 // Decisions and Designs Web site: http://www.decisions-and-designs.com.au
597 // e-mail:                         [email protected]
598 //
599
600 #include &quot;radiotelescope.h&quot;
601 #include &quot;signals.h&quot;
602 #include &quot;serial_command.h&quot;
603 #include &quot;ui.h&quot;
604
605 extern Menu menu[];
606 extern MenuSignal menuSignal[];
607
608 #define UI_TX_BUFFER_LENGTH 80
609
610 /* encapsulated delcaration of the UI active object ------------------------*/ 
611 $declare(AOs::UI)
612
613 /* global objects ----------------------------------------------------------*/
614 UI AO_UI;
615
616 /* Active object definition ------------------------------------------------*/
617 $define(AOs::UI)</text>
618       </file>
619       <file name="stepper.c">
620         <text>//
621 // Product: Radiotelescope - Stepper Motor Controller
622 // Version: 0.1
623 // Date:    25 November 2010
624 //
625 //                      +-----------------------+
626 //                      |   d e c i s i o n s   |
627 //                      +-----------------------|
628 //                      | a n d   d e s i g n s |
629 //                      +-----------------------+
630 //
631 // Copyright (C) 2009 Decisions and Designs Pty Ltd. All rights reserved.
632 //
633 // This software may be distributed and modified under the terms of the GNU
634 // General Public License version 2 (GPL) as published by the Free Software
635 // Foundation and appearing in the file GPL.TXT included in the packaging of
636 // this file. Please note that GPL Section 2[b] requires that all works based
637 // on this software must also be made publicly available under the terms of
638 // the GPL (&quot;Copyleft&quot;).
639 //
640 // Contact information:
641 // Decisions and Designs Web site: http://www.decisions-and-designs.com.au
642 // e-mail:                         [email protected]
643 //
644
645 #include &quot;radiotelescope.h&quot;
646 #include &quot;signals.h&quot;
647 #include &quot;stepper.h&quot;
648 #include &quot;qpn_port.h&quot;
649 #include &quot;bsp.h&quot;
650
651 /* Typedefs for pointers to (timer and direction) driver functions */ 
652 typedef uint8_t (*FPQueueStepTime)(uint32_t);
653 typedef void (*FPSetDirection)(int8_t); 
654
655 /* declaration of the Stepper active object --------------------------------*/ 
656 $declare(AOs::Stepper)
657
658 /* FP for support code */
659 void initialiseStepperData(Stepper *me);
660 void setupLinearAccelerator(Stepper *me);
661 void accelerationStepPeriod(Stepper *me);
662 void decelerationStepPeriod(Stepper *me);
663
664 /* global objects ----------------------------------------------------------*/
665 Stepper AO_azimuth;
666 Stepper AO_elevation;
667
668 /* Active object definition ------------------------------------------------*/
669 $define(AOs::Stepper)
670
671 /* Support code */
672 void initialiseStepperData(Stepper *me)
673 {
674     me-&gt;basePeriod = (double)SLOW_STEP_PERIOD;
675     me-&gt;slewTimer = SLOW_STEP_PERIOD;
676     me-&gt;totalSlewSteps = 0;
677     me-&gt;accelerationFactor = 0.0;
678 }
679
680 void setupLinearAccelerator(Stepper *me)
681 {
682     me-&gt;stepPeriod = me-&gt;basePeriod;
683     me-&gt;stepTimer = (uint32_t)me-&gt;stepPeriod;
684     me-&gt;slewStepCount = 0;
685     me-&gt;decelerationStep = (me-&gt;totalSlewSteps + 1) / 2;
686 }
687
688 void accelerationStepPeriod(Stepper *me)
689 {
690     me-&gt;stepPeriod -=   me-&gt;accelerationFactor
691                       * me-&gt;stepPeriod
692                       * me-&gt;stepPeriod
693                       * me-&gt;stepPeriod;
694     me-&gt;stepTimer = (uint32_t)me-&gt;stepPeriod;
695 }
696
697 void decelerationStepPeriod(Stepper *me)
698 {
699     me-&gt;stepPeriod +=   me-&gt;accelerationFactor
700                       * me-&gt;stepPeriod
701                       * me-&gt;stepPeriod
702                       * me-&gt;stepPeriod; 
703     me-&gt;stepTimer = (uint32_t)me-&gt;stepPeriod;
704 }
705 </text>
706       </file>
707       <file name="ui.h">
708         <text>//
709 // Product: Radiotelescope - Stepper Motor Controller
710 // Version: 0.1
711 // Date:    25 November 2010
712 //
713 //                      +-----------------------+
714 //                      |   d e c i s i o n s   |
715 //                      +-----------------------|
716 //                      | a n d   d e s i g n s |
717 //                      +-----------------------+
718 //
719 // Copyright (C) 2009 Decisions and Designs Pty Ltd. All rights reserved.
720 //
721 // This software may be distributed and modified under the terms of the GNU
722 // General Public License version 2 (GPL) as published by the Free Software
723 // Foundation and appearing in the file GPL.TXT included in the packaging of
724 // this file. Please note that GPL Section 2[b] requires that all works based
725 // on this software must also be made publicly available under the terms of
726 // the GPL (&quot;Copyleft&quot;).
727 //
728 // Contact information:
729 // Decisions and Designs Web site: http://www.decisions-and-designs.com.au
730 // e-mail:                         [email protected]
731 //
732
733 #ifndef ui_h
734 #define ui_h
735
736 #endif                                                             /* ui_h */
737 </text>
738       </file>
739       <file name="radiotelescope.h">
740         <text>//
741 // Product: Radiotelescope - Stepper Motor Controller
742 // Version: 0.1
743 // Date:    25 November 2010
744 //
745 //                      +-----------------------+
746 //                      |   d e c i s i o n s   |
747 //                      +-----------------------|
748 //                      | a n d   d e s i g n s |
749 //                      +-----------------------+
750 //
751 // Copyright (C) 2009 Decisions and Designs Pty Ltd. All rights reserved.
752 //
753 // This software may be distributed and modified under the terms of the GNU
754 // General Public License version 2 (GPL) as published by the Free Software
755 // Foundation and appearing in the file GPL.TXT included in the packaging of
756 // this file. Please note that GPL Section 2[b] requires that all works based
757 // on this software must also be made publicly available under the terms of
758 // the GPL (&quot;Copyleft&quot;).
759 //
760 // Contact information:
761 // Decisions and Designs Web site: http://www.decisions-and-designs.com.au
762 // e-mail:                         [email protected]
763 //
764
765 #ifndef radiotelescope_h
766 #define radiotelescope_h
767
768 #include &quot;qpn_port.h&quot;
769
770 /* active objects ..........................................................*/
771
772 $declare(AOs::UI::ctor)
773 $declare(AOs::Stepper::ctor)
774
775 extern struct StepperTag AO_azimuth;
776 extern struct StepperTag AO_elevation;
777 extern struct UITag AO_UI;
778
779 #endif                                                  /* radiotelescope_h */</text>
780       </file>
781     </directory>
782   </filesystem>
783 </model>

UCC git Repository :: git.ucc.asn.au