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><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
7 <html><head><meta name="qrichtext" content="1" /><style type="text/css">
8 p, li { white-space: pre-wrap; }
9 </style></head><body style=" font-family:'Tahoma'; font-size:8pt; font-weight:400; font-style:normal;">
10 <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Serial command parser and message transmitter</p></body></html></documentation>
11 <attribute name="attr1" type="" visibility="0x00" properties="0x00"/>
12 <operation name="ctor" type="void" visibility="0x00" properties="0x01"/>
14 <state name="Operational">
17 <initial target="../1">
20 <state name="Parsing">
21 <entry>me->parser = me->menu;</entry>
24 <choice guard="isterm(pa.msg.ch)">
26 <choice guard="me->parser != me->menu" target="../../../..">
27 <action>transmitNACK();
33 uint8_t ch = (SerialRxMsg *)(&PAR(me))->ch;
35 while (me->menu->ch) {
36 if (me->menu->ch != ch) {
40 /* match ch in menu */
45 <state name="TerminatingNACK">
47 <exit>me->vidx=0;</exit>
49 <choice guard="isterm(pa.msg.ch)" target="../../../1">
50 <action>transmitNACK();</action>
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"/>
64 <state_glyph ref="0/2" node="511,361,25,11">
67 <state_glyph ref="0/3" node="543,343,57,11"/>
68 <tran_glyph ref="0/1/0" conn="543,322,3,-1,13">
71 <choice_glyph ref="0/1/0/0" conn="556,322,5,-1,16">
72 <text box="1,-2,14,2"/>
74 <choice_glyph ref="0/1/0/0/0" conn="572,322,5,1,30">
75 <text box="2,-4,19,4"/>
77 <tran_glyph ref="0/2/0" conn="511,368,3,-1,10">
80 <choice_glyph ref="0/2/0/0" conn="521,368,5,3,19,-39,3">
81 <text box="1,0,15,5"/>
83 <initial_glyph ref="0/0" conn="539,314,4,3,3,4">
84 <text box="2,-1,6,2"/>
86 <choice_glyph ref="0/1/0/1" conn="556,322,4,-1,8,16">
87 <text box="1,1,27,6"/>
92 <class name="UI" superclass="../../0/1">
93 <documentation><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
94 <html><head><meta name="qrichtext" content="1" /><style type="text/css">
95 p, li { white-space: pre-wrap; }
96 </style></head><body style=" font-family:'Tahoma'; font-size:8pt; font-weight:400; font-style:normal;">
97 <p style="-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';"></p></body></html></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 *)&AO_UI, (QStateHandler)&UI_initial);
102 SerialCommand_ctor(&AO_UI.serialCommand, (QActive *)&AO_UI, menu, menuSignal, AO_UI.txBuffer, UI_TX_BUFFER_LENGTH, 0, 9600);
106 <initial target="../1">
112 <tran trig="SERIAL_RX_DATA">
113 <action>serialDispatch(&me->serialCommand, SERIAL_RX_DATA_SIG, Q_PAR(me));</action>
115 <tran trig="SERIAL_TX_EMPTY">
116 <action>serialDispatch(&me->serialCommand, SERIAL_TX_EMPTY_SIG, Q_PAR(me));</action>
118 <tran trig="COMMAND_FAIL">
119 <action>serialNACK(&me->serialCommand, 0);</action>
121 <tran trig="COMMAND_AZIMUTH">
122 <action>QActive_post((QActive *)&AO_azimuth, SET_BASE_SPEED_SIG, Q_PAR(me));
123 QActive_post((QActive *)&AO_azimuth, SET_ACCELERATION_SIG,
124 me->serialCommand.vargs[1].v.param);
125 QActive_post((QActive *)&AO_azimuth, SET_SLEW_SPEED_SIG,
126 me->serialCommand.vargs[2].v.param);
127 QActive_post((QActive *)&AO_azimuth, SET_TOTAL_STEPS_SIG,
128 me->serialCommand.vargs[3].v.param);
129 serialReleaseVargs(&me->serialCommand);
130 serialACK(&me->serialCommand, 1);</action>
132 <tran trig="COMMAND_AZIMUTH_BASE">
133 <action>QActive_post((QActive *)&AO_azimuth, SET_BASE_SPEED_SIG, Q_PAR(me));
134 serialACK(&me->serialCommand, 1);</action>
136 <tran trig="COMMAND_AZIMUTH_SLEW">
137 <action>QActive_post((QActive *)&AO_azimuth, SET_SLEW_SPEED_SIG, Q_PAR(me));
138 serialACK(&me->serialCommand, 1);</action>
140 <tran trig="COMMAND_AZIMUTH_ACCELERATION">
141 <action>QActive_post((QActive *)&AO_azimuth, SET_ACCELERATION_SIG, Q_PAR(me));
142 serialACK(&me->serialCommand, 1);</action>
144 <tran trig="COMMAND_AZIMUTH_STEPS">
145 <action>QActive_post((QActive *)&AO_azimuth, SET_TOTAL_STEPS_SIG, Q_PAR(me));
146 serialACK(&me->serialCommand, 1);</action>
148 <tran trig="COMMAND_ELEVATION">
149 <action>QActive_post((QActive *)&AO_elevation, SET_BASE_SPEED_SIG, Q_PAR(me));
150 QActive_post((QActive *)&AO_elevation, SET_ACCELERATION_SIG,
151 me->serialCommand.vargs[1].v.param);
152 QActive_post((QActive *)&AO_elevation, SET_SLEW_SPEED_SIG,
153 me->serialCommand.vargs[2].v.param);
154 QActive_post((QActive *)&AO_elevation, SET_TOTAL_STEPS_SIG,
155 me->serialCommand.vargs[3].v.param);
156 serialReleaseVargs(&me->serialCommand);
157 serialACK(&me->serialCommand, 1);</action>
159 <tran trig="COMMAND_ELEVATION_BASE">
160 <action>QActive_post((QActive *)&AO_elevation, SET_BASE_SPEED_SIG, Q_PAR(me));
161 serialACK(&me->serialCommand, 1);</action>
163 <tran trig="COMMAND_ELEVATION_SLEW">
164 <action>QActive_post((QActive *)&AO_elevation, SET_SLEW_SPEED_SIG, Q_PAR(me));
165 serialACK(&me->serialCommand, 1);</action>
167 <tran trig="COMMAND_ELEVATION_ACCELERATION">
168 <action>QActive_post((QActive *)&AO_elevation, SET_ACCELERATION_SIG, Q_PAR(me));
169 serialACK(&me->serialCommand, 1);</action>
171 <tran trig="COMMAND_ELEVATION_STEPS">
172 <action>QActive_post((QActive *)&AO_elevation, SET_TOTAL_STEPS_SIG, Q_PAR(me));
173 serialACK(&me->serialCommand, 1);</action>
175 <tran trig="SERIAL_RX_ERROR">
176 <action>serialDispatch(&me->serialCommand, SERIAL_RX_ERROR_SIG, Q_PAR(me));</action>
178 <tran trig="SERIAL_TX_COMPLETE">
179 <action>serialDispatch(&me->serialCommand, SERIAL_TX_COMPLETE_SIG, Q_PAR(me));</action>
181 <tran trig="COMMAND_START_AZIMUTH">
182 <action>QActive_post((QActive *)&AO_azimuth, START_LINEAR_SLEW_SIG, 0);
183 serialACK(&me->serialCommand, 1);</action>
185 <tran trig="COMMAND_START_ELEVATION">
186 <action>QActive_post((QActive *)&AO_elevation, START_LINEAR_SLEW_SIG, 0);
187 serialACK(&me->serialCommand, 1);</action>
189 <tran trig="COMMAND_START_AZ_EL">
190 <action>QActive_post((QActive *)&AO_azimuth, START_LINEAR_SLEW_SIG, 0);
191 QActive_post((QActive *)&AO_elevation, START_LINEAR_SLEW_SIG, 0);
192 serialACK(&me->serialCommand, 1);</action>
194 <tran trig="COMMAND_AZIMUTH_CLOCKWISE">
195 <action>QActive_post((QActive *)&AO_azimuth, SET_DIRECTION_UP_CW_SIG, 0);
196 serialACK(&me->serialCommand, 1);</action>
198 <tran trig="COMMAND_AZIMUTH_CCW">
199 <action>QActive_post((QActive *)&AO_azimuth, SET_DIRECTION_DOWN_CCW_SIG, 0);
200 serialACK(&me->serialCommand, 1);</action>
202 <tran trig="COMMAND_ELEVATION_UP">
203 <action>QActive_post((QActive *)&AO_elevation, SET_DIRECTION_UP_CW_SIG, 0);
204 serialACK(&me->serialCommand, 1);</action>
206 <tran trig="COMMAND_ELEVATION_DOWN">
207 <action>QActive_post((QActive *)&AO_elevation, SET_DIRECTION_DOWN_CCW_SIG, 0);
208 serialACK(&me->serialCommand, 1);</action>
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"/>
216 <tran_glyph ref="1/2" conn="6,16,3,-1,55">
217 <text box="1,0,29,4"/>
219 <tran_glyph ref="1/3" conn="6,22,3,-1,55">
220 <text box="1,0,55,19"/>
222 <tran_glyph ref="1/4" conn="6,42,3,-1,55">
223 <text box="1,0,51,6"/>
225 <tran_glyph ref="1/5" conn="6,49,3,-1,55">
226 <text box="1,0,51,6"/>
228 <tran_glyph ref="1/13" conn="6,102,3,-1,48">
229 <text box="1,0,48,6"/>
231 <tran_glyph ref="1/1" conn="6,108,3,-1,48">
232 <text box="1,0,49,5"/>
234 <tran_glyph ref="1/14" conn="6,114,3,-1,48">
235 <text box="1,0,53,5"/>
237 <tran_glyph ref="1/0" conn="6,96,3,-1,48">
238 <text box="1,0,49,6"/>
240 <tran_glyph ref="1/6" conn="6,56,3,-1,55">
241 <text box="1,0,51,7"/>
243 <tran_glyph ref="1/7" conn="6,63,3,-1,55">
244 <text box="1,0,51,6"/>
246 <tran_glyph ref="1/8" conn="121,22,1,-1,-55">
247 <text box="-53,0,51,18"/>
249 <tran_glyph ref="1/9" conn="121,42,1,-1,-55">
250 <text box="-53,0,51,6"/>
252 <tran_glyph ref="1/10" conn="121,49,1,-1,-55">
253 <text box="-53,0,51,6"/>
255 <tran_glyph ref="1/11" conn="121,56,1,-1,-55">
256 <text box="-53,0,52,6"/>
258 <tran_glyph ref="1/12" conn="121,63,1,-1,-55">
259 <text box="-53,0,52,7"/>
261 <tran_glyph ref="1/15" conn="6,84,3,-1,55">
262 <text box="1,0,51,6"/>
264 <tran_glyph ref="1/16" conn="121,84,1,-1,-55">
265 <text box="-53,0,51,6"/>
267 <tran_glyph ref="1/17" conn="121,91,1,-1,-55">
268 <text box="-53,0,51,7"/>
270 <tran_glyph ref="1/18" conn="6,70,3,-1,55">
271 <text box="1,0,54,6"/>
273 <tran_glyph ref="1/19" conn="6,77,3,-1,55">
274 <text box="1,0,50,6"/>
276 <tran_glyph ref="1/20" conn="121,70,1,-1,-55">
277 <text box="-53,0,53,7"/>
279 <tran_glyph ref="1/21" conn="121,77,1,-1,-55">
280 <text box="-53,0,50,6"/>
285 <class name="Stepper" superclass="../../0/1">
286 <documentation><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
287 <html><head><meta name="qrichtext" content="1" /><style type="text/css">
288 p, li { white-space: pre-wrap; }
289 </style></head><body style=" font-family:'Tahoma'; font-size:8pt; font-weight:400; font-style:normal;">
290 <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">A common stepper motor HSM for azimuth and elevation motion</p></body></html></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 *)&AO_azimuth, (QStateHandler)&Stepper_initial);
308 BSP_initStepTimer3((QActive *)&AO_azimuth);
309 BSP_initAzimuthFault((QActive *)&AO_azimuth);
310 /* Configure AO_elevation Stepper */
311 AO_elevation.queueStepTime = BSP_nextStepTimer4;
312 AO_elevation.setDirection = BSP_elevationDirection;
313 QActive_ctor((QActive *)&AO_elevation, (QStateHandler)&Stepper_initial);
314 BSP_initStepTimer4((QActive *)&AO_elevation);
315 BSP_initElevationFault((QActive *)&AO_elevation);</code>
318 <initial target="../1">
321 <state name="operational">
322 <entry>initialiseStepperData(me);
325 <initial target="../2">
328 <state name="LinearAccelerator">
329 <entry>setupLinearAccelerator(me);
330 (*me->setDirection)(me->direction);
333 <initial target="../3">
336 <tran trig="STEPPER_FAULT" target="../../2"/>
337 <state name="LinearDecelerate">
338 <entry>decelerationStepPeriod(me);
339 (*me->queueStepTime)(me->stepTimer);</entry>
341 <tran trig="NEXT_STEP_TIME">
342 <action>me->slewStepCount++;
343 me->stepPosition += me->direction;</action>
344 <choice guard="me->slewStepCount < me->totalSlewSteps">
345 <action>decelerationStepPeriod(me);
346 (*me->queueStepTime)(me->stepTimer);</action>
348 <choice guard="else" target="../../../../2">
353 <state name="LinearAccelerate">
354 <entry>(*me->queueStepTime)(me->stepTimer);
355 accelerationStepPeriod(me);</entry>
357 <tran trig="NEXT_STEP_TIME">
358 <action>me->slewStepCount++;
359 me->stepPosition += me->direction;</action>
360 <choice guard="else" target="../../../2">
363 <choice guard="me->slewStepCount < me->decelerationStep">
365 <choice guard="me->stepTimer > me->slewTimer">
366 <action>(*me->queueStepTime)(me->stepTimer);
367 accelerationStepPeriod(me);</action>
369 <choice guard="else" target="../../../../4">
370 <action>me->stepTimer = me->slewTimer;
371 me->decelerationStep =
372 me->totalSlewSteps - me->slewStepCount;</action>
377 <state name="LinearConstantSpeed">
378 <entry>(*me->queueStepTime)(me->stepTimer);</entry>
380 <tran trig="NEXT_STEP_TIME">
381 <action>me->slewStepCount++;
382 me->stepPosition += me->direction;</action>
383 <choice guard="me->slewStepCount < me->decelerationStep">
384 <action>(*me->queueStepTime)(me->stepTimer);</action>
386 <choice guard="else" target="../../../2">
392 <state name="Stopped">
395 <tran trig="SET_BASE_SPEED">
396 <action>/* Calculate and store (double)basePeriod */
397 UParam p; p.param = Q_PAR(me);
399 AZIMUTH_CLOCK_DBL / p.dbl; </action>
401 <tran trig="SET_SLEW_SPEED">
402 <action>/* Calculate and store (uint32_t)slewPeriod */
403 UParam p; p.param = Q_PAR(me);
404 me->slewTimer = (uint32_t)
405 (AZIMUTH_CLOCK_DBL / p.dbl);</action>
407 <tran trig="SET_ACCELERATION">
408 <action>/* Calculate and store derived factor */
409 UParam p; p.param = Q_PAR(me);
410 me->accelerationFactor = p.dbl
412 / AZIMUTH_CLOCK_DBL;</action>
414 <tran trig="SET_TOTAL_STEPS">
415 <action>UParam p; p.param = Q_PAR(me);
416 me->totalSlewSteps = p.uint32;</action>
418 <tran trig="START_LINEAR_SLEW">
419 <choice guard="me->totalSlewSteps > 0" target="../../../1">
423 <tran trig="SET_DIRECTION_UP_CW">
424 <action>me->direction = 1;</action>
426 <tran trig="SET_DIRECTION_DOWN_CCW">
427 <action>me->direction = -1;</action>
431 <state_diagram size="207,143">
432 <state_glyph ref="1" node="3,6,201,133">
433 <text box="0,2,30,8"/>
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"/>
439 <state_glyph ref="1/1/2" node="45,68,61,19">
440 <text box="0,2,32,6"/>
442 <state_glyph ref="1/1/3" node="42,19,64,24">
443 <text box="0,2,36,7"/>
445 <state_glyph ref="1/1/4" node="45,47,61,19">
446 <text box="0,2,36,8"/>
448 <initial_glyph ref="0" conn="9,3,5,0,4,3">
449 <text box="1,0,6,2"/>
451 <tran_glyph ref="1/2/0" conn="6,24,3,-1,28">
452 <text box="1,0,32,9"/>
454 <tran_glyph ref="1/2/1" conn="6,34,3,-1,28">
455 <text box="1,0,29,9"/>
457 <tran_glyph ref="1/2/2" conn="6,44,3,-1,28">
458 <text box="1,0,29,11"/>
460 <tran_glyph ref="1/2/3" conn="6,56,3,-1,28">
461 <text box="1,0,27,6"/>
463 <tran_glyph ref="1/2/4" conn="17,73,2,-1,9">
464 <text box="1,1,19,2"/>
466 <initial_glyph ref="1/1/0" conn="75,16,5,0,4,3">
467 <text box="1,0,6,2"/>
469 <tran_glyph ref="1/1/3/0" conn="42,28,3,-1,24">
470 <text box="1,0,23,7"/>
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"/>
475 <choice_glyph ref="1/1/3/0/1" conn="66,28,5,-1,11,6">
476 <text box="1,-2,52,2"/>
478 <tran_glyph ref="1/2/5" conn="6,63,3,-1,28">
479 <text box="1,0,24,4"/>
481 <tran_glyph ref="1/2/6" conn="6,68,3,-1,28">
482 <text box="1,0,27,5"/>
484 <choice_glyph ref="1/1/3/0/1/0" conn="77,34,5,-1,27">
485 <text box="1,-6,27,6"/>
487 <choice_glyph ref="1/1/3/0/1/1" conn="77,34,4,0,13">
488 <text box="1,1,28,8"/>
490 <tran_glyph ref="1/1/4/0" conn="45,58,3,-1,26">
491 <text box="1,0,25,7"/>
493 <choice_glyph ref="1/1/4/0/0" conn="71,58,5,-1,28">
494 <text box="1,-4,31,4"/>
496 <choice_glyph ref="1/1/4/0/1" conn="71,58,4,0,10">
497 <text box="1,4,10,4"/>
499 <tran_glyph ref="1/1/2/0" conn="45,78,3,-1,26">
500 <text box="1,0,25,10"/>
502 <choice_glyph ref="1/1/2/0/0" conn="71,78,5,-1,29">
503 <text box="1,-6,49,7"/>
505 <choice_glyph ref="1/1/2/0/1" conn="71,78,4,2,11,-62,-16">
506 <text box="1,4,6,2"/>
508 <choice_glyph ref="1/2/4/0" conn="17,82,5,3,22">
509 <text box="1,-3,18,3"/>
511 <initial_glyph ref="1/0" conn="14,16,5,0,4,3">
512 <text box="1,0,6,2"/>
514 <tran_glyph ref="1/1/1" conn="39,86,3,2,-26,-13">
515 <text box="-21,-2,17,2"/>
521 <filesystem path=".">
522 <directory name="qm_code">
523 <file name="stepper.h">
525 // Product: Radiotelescope - Stepper Motor Controller
527 // Date: 25 November 2010
529 // +-----------------------+
530 // | d e c i s i o n s |
531 // +-----------------------|
532 // | a n d d e s i g n s |
533 // +-----------------------+
535 // Copyright (C) 2009 Decisions and Designs Pty Ltd. All rights reserved.
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 ("Copyleft").
544 // Contact information:
545 // Decisions and Designs Web site: http://www.decisions-and-designs.com.au
552 #include "bsp.h" /* for board specific STEP_PERIOD macro */
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)
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
571 #endif /* stepper_h */
576 // Product: Radiotelescope - Stepper Motor Controller
578 // Date: 25 November 2010
580 // +-----------------------+
581 // | d e c i s i o n s |
582 // +-----------------------|
583 // | a n d d e s i g n s |
584 // +-----------------------+
586 // Copyright (C) 2009 Decisions and Designs Pty Ltd. All rights reserved.
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 ("Copyleft").
595 // Contact information:
596 // Decisions and Designs Web site: http://www.decisions-and-designs.com.au
600 #include "radiotelescope.h"
601 #include "signals.h"
602 #include "serial_command.h"
603 #include "ui.h"
606 extern MenuSignal menuSignal[];
608 #define UI_TX_BUFFER_LENGTH 80
610 /* encapsulated delcaration of the UI active object ------------------------*/
613 /* global objects ----------------------------------------------------------*/
616 /* Active object definition ------------------------------------------------*/
617 $define(AOs::UI)</text>
619 <file name="stepper.c">
621 // Product: Radiotelescope - Stepper Motor Controller
623 // Date: 25 November 2010
625 // +-----------------------+
626 // | d e c i s i o n s |
627 // +-----------------------|
628 // | a n d d e s i g n s |
629 // +-----------------------+
631 // Copyright (C) 2009 Decisions and Designs Pty Ltd. All rights reserved.
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 ("Copyleft").
640 // Contact information:
641 // Decisions and Designs Web site: http://www.decisions-and-designs.com.au
645 #include "radiotelescope.h"
646 #include "signals.h"
647 #include "stepper.h"
648 #include "qpn_port.h"
649 #include "bsp.h"
651 /* Typedefs for pointers to (timer and direction) driver functions */
652 typedef uint8_t (*FPQueueStepTime)(uint32_t);
653 typedef void (*FPSetDirection)(int8_t);
655 /* declaration of the Stepper active object --------------------------------*/
656 $declare(AOs::Stepper)
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);
664 /* global objects ----------------------------------------------------------*/
666 Stepper AO_elevation;
668 /* Active object definition ------------------------------------------------*/
669 $define(AOs::Stepper)
672 void initialiseStepperData(Stepper *me)
674 me->basePeriod = (double)SLOW_STEP_PERIOD;
675 me->slewTimer = SLOW_STEP_PERIOD;
676 me->totalSlewSteps = 0;
677 me->accelerationFactor = 0.0;
680 void setupLinearAccelerator(Stepper *me)
682 me->stepPeriod = me->basePeriod;
683 me->stepTimer = (uint32_t)me->stepPeriod;
684 me->slewStepCount = 0;
685 me->decelerationStep = (me->totalSlewSteps + 1) / 2;
688 void accelerationStepPeriod(Stepper *me)
690 me->stepPeriod -= me->accelerationFactor
694 me->stepTimer = (uint32_t)me->stepPeriod;
697 void decelerationStepPeriod(Stepper *me)
699 me->stepPeriod += me->accelerationFactor
703 me->stepTimer = (uint32_t)me->stepPeriod;
709 // Product: Radiotelescope - Stepper Motor Controller
711 // Date: 25 November 2010
713 // +-----------------------+
714 // | d e c i s i o n s |
715 // +-----------------------|
716 // | a n d d e s i g n s |
717 // +-----------------------+
719 // Copyright (C) 2009 Decisions and Designs Pty Ltd. All rights reserved.
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 ("Copyleft").
728 // Contact information:
729 // Decisions and Designs Web site: http://www.decisions-and-designs.com.au
739 <file name="radiotelescope.h">
741 // Product: Radiotelescope - Stepper Motor Controller
743 // Date: 25 November 2010
745 // +-----------------------+
746 // | d e c i s i o n s |
747 // +-----------------------|
748 // | a n d d e s i g n s |
749 // +-----------------------+
751 // Copyright (C) 2009 Decisions and Designs Pty Ltd. All rights reserved.
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 ("Copyleft").
760 // Contact information:
761 // Decisions and Designs Web site: http://www.decisions-and-designs.com.au
765 #ifndef radiotelescope_h
766 #define radiotelescope_h
768 #include "qpn_port.h"
770 /* active objects ..........................................................*/
772 $declare(AOs::UI::ctor)
773 $declare(AOs::Stepper::ctor)
775 extern struct StepperTag AO_azimuth;
776 extern struct StepperTag AO_elevation;
777 extern struct UITag AO_UI;
779 #endif /* radiotelescope_h */</text>