PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
abcalibrate.c
1 #include "abcalibrate.h"
2 #include "servo.h"
3 #include "simpletools.h"
4 #include "simpletext.h"
5 #include "fdserial.h"
6 
7 /*
8 #define _ActivityBot_EE_Start_ 63418
9 #define _ActivityBot_EE_Pins_ 12
10 #define _ActivityBot_EE_Trims_ 28
11 #define _ActivityBot_EE_Left_ 52
12 #define _ActivityBot_EE_Right_ 1052
13 #define _ActivityBot_EE_End_ 63418 + 2052
14 */
15 
16 void cal_drive_pins(int servoPinLeft, int servoPinRight, int encPinLeft, int encPinright);
17 void cal_drive_speeds(int left, int right);
18 void cal_drive_setramp(int left, int right);
19 void cal_drive_sleep();
20 void cal_drive_stop();
21 void cal_drive_display(void);
22 
23 
24 static int ticksRprev;
25 
26 static int spdr[150];
27 static int spdm[150];
28 static int a = 0;
29 static int r = 0;
30 
31 volatile int ticksL;
32 volatile int ticksR;
33 volatile int tcL;
34 volatile int tcR;
35 
36 int us;
37 
38 static int eeAddr;
39 
40 static volatile int sPinL = 12, sPinR = 13, rampLeft, rampRight; // Global variables
41 static volatile int ePinL = 14, ePinR = 15;
42 
43 
45 {
46 
47  #ifdef xbee_abcalibrate_debug
48  fdserial *xbee = fdserial_open(11, 10, 0, 9600);
49  writeChar(xbee, CLS);
50  #endif
51 
52  //dprint(xbee, "%cPress any key...\n", CLS);
53  //readChar(xbee);
54 
55  freqout(4, 2000, 3000);
56  cal_drive_pins(sPinL, sPinR, ePinL, ePinR);
57 
58  eeAddr = _ActivityBot_EE_Start_ + _ActivityBot_EE_Trims_;
59  ee_putInt(0, eeAddr + 0);
60  ee_putInt(0, eeAddr + 4);
61  ee_putInt(0, eeAddr + 8);
62  ee_putInt(0, eeAddr + 12);
63  ee_putInt(0, eeAddr + 16);
64  ee_putInt(0, eeAddr + 20);
65 
66  int speed = -200;
67  int i = 0;
68  int dt = CLKFREQ/2;
69  int t = CNT;
70  int step = 6;
71  int tcLav = 0;
72 
73  //int eeBaseAddr = 32768;
74  //int eeAddrInc = 4;
75  //int eeIdx = eeBaseAddr + 16;
76 
77  int ticksLprev = ticksL;
78  do
79  {
80  speed += step;
81  TryAgainLeft:
82 
83  #ifdef xbee_abcalibrate_debug
84  dprint(xbee,"a = %d, speed = %d, ",
85  a, speed);
86  #endif
87 
88  cal_drive_speeds(speed, 0);
89  pause(200);
90  ticksLprev = ticksL;
91  tcLav = 0;
92  spdr[a] = speed;
93  for(int i = 0; i < 10; i++)
94  {
95  while(ticksL <= ticksLprev + 1)
96  {
97  if((CNT - t) > dt)
98  {
99  tcL = 0;
100  t = CNT;
101  break;
102  }
103  if((tcL == 0)&&(i>0)) break;
104  }
105  //if(tcL > 0) tcL = -tcL;
106  tcLav += tcL;
107  //ticksLprev = ticksL;
108  t = CNT;
109  if((tcL < 20)&&(step == 5))
110  {
111  //speed -= step;
112  //speed += 2;
113  step = 2;
114  }
115  if(tcL > 20) step = 5;
116  }
117  tcLav /= 10;
118  if(tcLav > 210 || tcLav < 0) goto TryAgainLeft;
119  spdm[a] = tcLav;
120 
121  #ifdef xbee_abcalibrate_debug
122  dprint(xbee,"ticksL = %d, tcL = %d, \n",
123  ticksL, tcLav);
124  #endif
125  a++;
126  } while(speed < 200);
127 
128 
129  /* TEST CODE - MUST BE COMMENTED OUT */
130 
131 
132  //spdm[38] = 0;
133  //spdm[33] = 150;
134 
135 
136  /* /TEST CODE - MUST BE COMMENTED OUT */
137 
138 
139 
140 
141  //drive_stop();
142  cal_drive_speeds(0, 0);
143 
144  // <2013.09.02 removed>
145  /*
146  for(r = 0; r < a; r++)
147  {
148  dprint(xbee,"r = %d, spdr = %d, spdm = %d, \n", r, spdr[r], spdm[r]);
149  }
150  */
151  // </2013.09.02 removed>
152 
153 
154  // <2013.09.02 added>
155 
156  #ifdef xbee_abcalibrate_debug
157  dprint(xbee,"Before\n");
158  for(r = 0; r < a; r++)
159  {
160  dprint(xbee,"r = %d, spdr = %d, spdm = %d, \n", r, spdr[r], spdm[r]);
161  }
162  #endif
163 
164  // Look for and correct any measurement errors
165  for(r = 1; r < a-1; r++)
166  {
167  if((spdm[r] > spdm[r-1] + 30) && (spdm[r] > spdm[r+1] + 30)) spdm[r] = (spdm[r+1] + spdm[r-1])/2;
168  //if((spdm[r] < spdm[r-1] - 30) && (spdm[r] < spdm[r-1] - 30)) spdm[r] = (spdm[r+1] + spdm[r-1])/2;
169  }
170 
171  // Look for and correct stray zeros
172  for(r = 1; r < a-1; r++)
173  {
174  if((spdm[r] == 0) && (spdm[r+1] != 0) && (spdm[r-1] != 0)) spdm[r] = (spdm[r+1] + spdm[r-1])/2;
175  }
176 
177  #ifdef xbee_abcalibrate_debug
178  dprint(xbee,"After\n");
179  for(r = 0; r < a; r++)
180  {
181  dprint(xbee,"r = %d, spdr = %d, spdm = %d, \n", r, spdr[r], spdm[r]);
182  }
183  #endif
184 
185  // </2013.09.02 added>
186 
187 
188 
189  #ifdef xbee_abcalibrate_debug
190  dprint(xbee,"r = %d\n", r);
191  #endif
192 
193  int zstart = 0;
194  int zend = 0;
195  int lcnt;
196 
197  for(r = 0; r < a; r++)
198  {
199  if((spdm[r]==0)&&(zstart==0)) zstart = r;
200  if((zstart!=0)&&(spdm[r]!=0)&&(zend==0)) zend = r;
201  }
202 
203  #ifdef xbee_abcalibrate_debug
204  dprint(xbee,"zstart = %d, zend = %d\n", zstart, zend);
205  #endif
206 
207 
208  lcnt = r;
209 
210  for(r = 1; r < lcnt-1; r++)
211  {
212  if((spdm[r] < 0)||(spdm[r] > 200)) spdm[r] = (spdm[r+1] + spdm[r-1])/2;
213  }
214 
215  spdr[zstart] = (spdr[zstart] + spdr[zend - 1])/2;
216 
217  int subval = zend - zstart - 1;
218 
219  for(r = zend; r < lcnt; r++)
220  {
221  spdr[r - subval] = spdr[r];
222  spdm[r - subval] = spdm[r];
223  }
224 
225  a -= subval;
226 
227  #ifdef xbee_abcalibrate_debug
228  for(r = 0; r < a; r++)
229  {
230  dprint(xbee,"r = %d, spdr = %d, spdm = %d, \n", r, spdr[r], spdm[r]);
231  }
232  #endif
233 
234  lcnt = r;
235 
236  #ifdef xbee_abcalibrate_debug
237  dprint(xbee,"lcnt = %d\n", lcnt);
238  dprint(xbee,"zstart = %d\n", zstart);
239  #endif
240 
241  eeAddr = _ActivityBot_EE_Start_ + _ActivityBot_EE_Left_;
242 
243  #ifdef xbee_abcalibrate_debug
244  print("left eeAddr = %d\n", eeAddr);
245  #endif
246 
247  ee_putInt(lcnt, eeAddr);
248  eeAddr+=4;
249  ee_putInt(zstart, eeAddr);
250  eeAddr += 4;
251  for(r = 0; r < lcnt; r++)
252  {
253  //ee_putInt(spdr[r], eeAddr);
254  //eeAddr+=4;
255  ee_putByte((char) spdr[r], eeAddr);
256  eeAddr++;
257  pause(10);
258  ee_putByte((char) (spdr[r] >> 8), eeAddr);
259  eeAddr++;
260  pause(10);
261  ee_putByte((char) (spdr[r] >> 16), eeAddr);
262  eeAddr++;
263  pause(10);
264  ee_putByte((char) (spdr[r] >> 24), eeAddr);
265  eeAddr++;
266  pause(10);
267 
268 
269  //ee_putInt(spdm[r], eeAddr);
270  //eeAddr += 4;
271  ee_putByte((char) spdm[r], eeAddr);
272  eeAddr++;
273  pause(10);
274  ee_putByte((char) (spdm[r] >> 8), eeAddr);
275  eeAddr++;
276  pause(10);
277  ee_putByte((char) (spdm[r] >> 16), eeAddr);
278  eeAddr++;
279  pause(10);
280  ee_putByte((char) (spdm[r] >> 24), eeAddr);
281  eeAddr++;
282  pause(10);
283 
284  }
285 
286 
287  // <2013.09.02 removed>
288  /*
289  for(r = 0; r < 120; r++)
290  {
291  spdr[r] = 0;
292  spdm[r] = 0;
293  }
294  */
295  // </2013.09.02 removed>
296 
297 
298  eeAddr = _ActivityBot_EE_Start_ + _ActivityBot_EE_Left_;
299 
300  #ifdef xbee_abcalibrate_debug
301  print("left eeAddr = %d\n", eeAddr);
302  #endif
303 
304  lcnt = ee_getInt(eeAddr);
305  eeAddr += 4;
306  zstart = ee_getInt(eeAddr);
307  eeAddr += 4;
308 
309  // <2013.09.02 removed>
310  /*
311  for(r = 0; r < lcnt; r++)
312  {
313  spdr[r] = ee_getInt(eeAddr);
314  eeAddr+=4;
315  spdm[r] = ee_getInt(eeAddr);
316  eeAddr += 4;
317  }
318  */
319  // </2013.09.02 removed>
320 
321 
322 
323  // <2013.09.02 added>
324  for(r = 0; r < lcnt; r++)
325  {
326  if(spdr[r] != ee_getInt(eeAddr)) ee_putInt(spdr[r], eeAddr);
327  eeAddr+=4;
328  if(spdm[r] != ee_getInt(eeAddr)) ee_putInt(spdm[r], eeAddr);
329  eeAddr += 4;
330  }
331  // </2013.09.02 added>
332 
333  #ifdef xbee_abcalibrate_debug
334  for(r = 0; r < lcnt; r++)
335  {
336  dprint(xbee,"r = %d, spdr = %d, spdm = %d, \n", r, spdr[r], spdm[r]);
337  }
338  dprint(xbee,"\n\nDONE!!!\n\n");
339  #endif
340 
341 
342 
343 
344  /*============= RIGHT SIDE =============*/
345 
346 
347 
348  speed = -200;
349  step = 5;
350  i = 0;
351  dt = CLKFREQ/2;
352  t = CNT;
353  int tcRav = 0;
354 
355  ticksR = 0;
356  ticksRprev = ticksR;
357 
358  a = 0;
359 
360  do
361  {
362  speed += step;
363  TryAgainRight:
364 
365  #ifdef xbee_abcalibrate_debug
366  dprint(xbee,"a = %d, speed = %d, ",
367  a, speed);
368  #endif
369 
370  cal_drive_speeds(0, speed);
371  pause(200);
372  ticksRprev = ticksR;
373  tcRav = 0;
374  spdr[a] = speed;
375  for(int i = 0; i < 10; i++)
376  {
377  while(ticksR <= ticksRprev + 1)
378  {
379  if((CNT - t) > dt)
380  {
381  tcR = 0;
382  t = CNT;
383  break;
384  }
385  if((tcR == 0)&&(i>0)) break;
386  }
387  //if(tcL > 0) tcL = -tcL;
388  tcRav += tcR;
389  //ticksLprev = ticksL;
390  t = CNT;
391  if((tcR < 20)&&(step == 5))
392  {
393  //speed -= step;
394  //speed += 2;
395  step = 2;
396  }
397  if(tcR > 20) step = 5;
398  }
399  tcRav /= 10;
400  if(tcRav > 210 || tcRav < 0) goto TryAgainRight;
401  spdm[a] = tcRav;
402 
403  #ifdef xbee_abcalibrate_debug
404  dprint(xbee,"ticksR = %d, tcR = %d, \n",
405  ticksR, tcRav);
406  #endif
407 
408  a++;
409  } while(speed < 200);
410 
411  cal_drive_stop();
412 
413 
414 
415 
416 
417 
418  // <2013.09.02 removed>
419  /*
420  for(r = 0; r < a; r++)
421  {
422  dprint(xbee,"r = %d, spdr = %d, spdm = %d, \n", r, spdr[r], spdm[r]);
423  }
424  */
425  // </2013.09.02>
426 
427 
428  // <2013.09.02>
429 
430  #ifdef xbee_abcalibrate_debug
431  dprint(xbee,"Before\n");
432  for(r = 0; r < a; r++)
433  {
434  dprint(xbee,"r = %d, spdr = %d, spdm = %d, \n", r, spdr[r], spdm[r]);
435  }
436  #endif
437 
438  // Look for and correct any measurement errors
439  for(r = 1; r < a-1; r++)
440  {
441  if((spdm[r] > spdm[r-1] + 30) && (spdm[r] > spdm[r+1] + 30)) spdm[r] = (spdm[r+1] + spdm[r-1])/2;
442  //if((spdm[r] < spdm[r-1] - 30) && (spdm[r] < spdm[r-1] - 30)) spdm[r] = (spdm[r+1] + spdm[r-1])/2;
443  }
444 
445  // Look for and correct stray zeros
446  for(r = 1; r < a-1; r++)
447  {
448  if((spdm[r] == 0) && (spdm[r+1] != 0) && (spdm[r-1] != 0)) spdm[r] = (spdm[r+1] + spdm[r-1])/2;
449  }
450 
451  #ifdef xbee_abcalibrate_debug
452  dprint(xbee,"After\n");
453  for(r = 0; r < a; r++)
454  {
455  dprint(xbee,"r = %d, spdr = %d, spdm = %d, \n", r, spdr[r], spdm[r]);
456  }
457  #endif
458 
459  // </2013.09.02>
460 
461 
462 
463 
464 
465 
466 
467 
468  #ifdef xbee_abcalibrate_debug
469  dprint(xbee,"r = %d\n", r);
470  #endif
471 
472  zstart = 0;
473  zend = 0;
474  int rcnt;
475 
476  for(r = 0; r < a; r++)
477  {
478  if((spdm[r]==0)&&(zstart==0)) zstart = r;
479  if((zstart!=0)&&(spdm[r]!=0)&&(zend==0)) zend = r;
480  }
481 
482  #ifdef xbee_abcalibrate_debug
483  dprint(xbee,"zstart = %d, zend = %d\n", zstart, zend);
484  #endif
485 
486  rcnt = r;
487 
488  for(r = 1; r < rcnt-1; r++)
489  {
490  if((spdm[r] < 0)||(spdm[r] > 200)) spdm[r] = (spdm[r+1] + spdm[r-1])/2;
491  }
492 
493 // dprint(xbee,"\n\n
494 
495 
496  spdr[zstart] = (spdr[zstart] + spdr[zend - 1])/2;
497 
498  subval = zend - zstart - 1;
499 
500  for(r = zend; r < rcnt; r++)
501  {
502  spdr[r - subval] = spdr[r];
503  spdm[r - subval] = spdm[r];
504  }
505 
506  a -= subval;
507 
508  #ifdef xbee_abcalibrate_debug
509  for(r = 0; r < a; r++)
510  {
511  dprint(xbee,"r = %d, spdr = %d, spdm = %d, \n", r, spdr[r], spdm[r]);
512  }
513  #endif
514 
515  rcnt = r;
516 
517  #ifdef xbee_abcalibrate_debug
518  dprint(xbee,"rcnt = %d\n", rcnt);
519  dprint(xbee,"zstart = %d\n", zstart);
520  #endif
521 
522  eeAddr = _ActivityBot_EE_Start_ + _ActivityBot_EE_Right_;
523  ee_putInt(rcnt, eeAddr);
524  eeAddr+=4;
525  ee_putInt(zstart, eeAddr);
526  eeAddr += 4;
527  for(r = 0; r < rcnt; r++)
528  {
529  //ee_putInt(spdr[r], eeAddr);
530  //eeAddr+=4;
531  ee_putByte((char) spdr[r], eeAddr);
532  eeAddr++;
533  pause(10);
534  ee_putByte((char) (spdr[r] >> 8), eeAddr);
535  eeAddr++;
536  pause(10);
537  ee_putByte((char) (spdr[r] >> 16), eeAddr);
538  eeAddr++;
539  pause(10);
540  ee_putByte((char) (spdr[r] >> 24), eeAddr);
541  eeAddr++;
542  pause(10);
543 
544 
545  //ee_putInt(spdm[r], eeAddr);
546  //eeAddr += 4;
547  ee_putByte((char) spdm[r], eeAddr);
548  eeAddr++;
549  pause(10);
550  ee_putByte((char) (spdm[r] >> 8), eeAddr);
551  eeAddr++;
552  pause(10);
553  ee_putByte((char) (spdm[r] >> 16), eeAddr);
554  eeAddr++;
555  pause(10);
556  ee_putByte((char) (spdm[r] >> 24), eeAddr);
557  eeAddr++;
558  pause(10);
559  }
560 
561  eeAddr = _ActivityBot_EE_Start_ + _ActivityBot_EE_Right_;
562 
563  #ifdef xbee_abcalibrate_debug
564  print("right eeAddr = %d\n", eeAddr);
565  #endif
566 
567  rcnt = ee_getInt(eeAddr);
568  eeAddr += 4;
569  zstart = ee_getInt(eeAddr);
570  eeAddr += 4;
571 
572  // <2013.09.02 added>
573  //
574  for(r = 0; r < rcnt; r++)
575  {
576  if(spdr[r] != ee_getInt(eeAddr)) ee_putInt(spdr[r], eeAddr);
577  eeAddr+=4;
578  if(spdm[r] != ee_getInt(eeAddr)) ee_putInt(spdm[r], eeAddr);
579  eeAddr += 4;
580  }
581  //
582  // </2013.09.02>
583 
584 
585 
586  // // <2013.09.02 removed>
587  eeAddr = _ActivityBot_EE_Start_ + _ActivityBot_EE_Right_;
588 
589  rcnt = ee_getInt(eeAddr);
590  eeAddr += 4;
591  zstart = ee_getInt(eeAddr);
592  eeAddr += 4;
593 
594 
595  for(r = 0; r < 120; r++)
596  {
597  spdr[r] = 0;
598  spdm[r] = 0;
599  }
600  // // </2013.09.02>
601 
602 
603  // // <2013.09.02 removed>
604  for(r = 0; r < rcnt; r++)
605  {
606  spdr[r] = ee_getInt(eeAddr);
607  eeAddr+=4;
608  spdm[r] = ee_getInt(eeAddr);
609  eeAddr += 4;
610  }
611  // // </2013.09.02>
612 
613 
614 
615 
616  #ifdef xbee_abcalibrate_debug
617  for(r = 0; r < rcnt; r++)
618  {
619  dprint(xbee,"r = %d, spdr = %d, spdm = %d, \n", r, spdr[r], spdm[r]);
620  }
621 
622  ee_putStr("ActivityBot", 12, _ActivityBot_EE_Start_);
623  dprint(xbee,"\n\nDONE!!!\n\n");
624  #endif
625 
626 
627  // <2013.09.02 added>
628  for(i = 0; i <=16; i++) ee_putByte(0xFF, i);
629  // </2013.09.02>
630 
631 }
632 
633 
634 static int cog = 0;
635 static int stack[(160 + (400 * 4)) / 4];
636 
637 volatile int tcL;
638 volatile int tcR;
639 static volatile int tiL;
640 static volatile int* sspAddrL;
641 static volatile int* sspAddrR;
642 static volatile int* ssrAddrL;
643 static volatile int* ssrAddrR;
644 volatile int ticksL = 0;
645 volatile int ticksR = 0;
646 static volatile int speedL;
647 static volatile int speedR;
648 static volatile int tfL;
649 static volatile int cL;
650 static volatile int tR;
651 static volatile int tiR;
652 static volatile int tfR;
653 static volatile int cR;
654 static volatile int stateL;
655 static volatile int stateR;
656 static volatile int dirL;
657 static volatile int ssReqL;
658 
659 void cal_encoders(void *par);
660 
661 void cal_drive_pins(int servoPinLeft, int servoPinRight, int encPinLeft, int encPinRight) // drivePins function
662 {
663  sPinL = servoPinLeft; // Local to global assignments
664  sPinR = servoPinRight;
665  ePinL = encPinLeft;
666  ePinR = encPinRight;
667 }
668 
669 void cal_drive_speeds(int left, int right) // driveSpeeds function
670 {
671  servo_speed(sPinL, left); // Use vals in servoSpeed calls
672  servo_speed(sPinR, -right);
673 
674  speedL = left;
675  speedR = right;
676 
677  /*
678  if((!ssrAddrL)&&(!ssrAddrR))
679  {
680  sspAddrL = servo_paddr(sPinL);
681  sspAddrR = servo_paddr(sPinR);
682  ssrAddrL = servo_raddr(sPinL);
683  ssrAddrR = servo_raddr(sPinR);
684  }
685  */
686  if(!cog)
687  {
688  cog = 1 + cogstart(cal_encoders, NULL, stack, sizeof(stack));
689  }
690 }
691 
692 
693 void cal_drive_display(void)
694 {
695  static int ticksLprev;
696  static int ticksRprev;
697  //print("ticksL = %d, ticksR = %d\n",
698  // ticksL - ticksLprev, ticksR - ticksRprev);
699  ticksLprev = ticksL;
700  ticksRprev = ticksR;
701 }
702 
703 void cal_drive_setramp(int left, int right) // driveRampSteps function
704 {
705  servo_setramp(sPinL, left); // Use vals in rampStep calls
706  servo_setramp(sPinR, right);
707 }
708 
709 void cal_drive_sleep() // driveSleep function
710 {
711  servo_set(sPinL, 0); // Put servos to sleep
712  servo_set(sPinR, 0);
713 }
714 
715 void cal_drive_stop() // driveStop function
716 {
717  servo_stop(); // Stop the servo processor
718 }
719 
720 
721 void cal_encoders(void *par)
722 {
723  stateL = (INA >> ePinL) & 1;
724  stateR = (INA >> ePinR) & 1;
725 
726  cL = -1;
727  cR = -1;
728  unsigned int sl, sr;
729  tiL = CNT;
730  tiR = CNT;
731 // int dt = CLKFREQ/50;
732 // int t = cnt;
733 
734  while(1)
735  {
736  if(((INA >> ePinL) & 1) != stateL)
737  {
738  stateL = (~stateL) & 1;
739  if(stateL == 1)
740  {
741  //if((CNT - tiL) > (CLKFREQ/220))
742  if((CNT - tiL) > (CLKFREQ/400))
743  {
744  tcL = ((2*CLKFREQ)/(CNT - tiL)); //added
745  tiL = CNT;
746  }
747  }
748  ticksL++;
749  }
750 
751  if(((INA >> ePinR) & 1) != stateR)
752  {
753  stateR = (~stateR) & 1;
754  if(stateR == 1)
755  {
756  //if((CNT - tiR) > (CLKFREQ/220))
757  if((CNT - tiR) > (CLKFREQ/400))
758  {
759  tcR = ((2*CLKFREQ)/(CNT - tiR)); //added
760  tiR = CNT;
761  }
762  }
763  ticksR++;
764  }
765  }
766 }
767 
768 
769 
770 
771 
772 
773 void cal_servoPins(int servoPinLeft, int servoPinRight) // drivePins function
774 {
775  sPinL = servoPinLeft; // Local to global assignments
776  sPinR = servoPinRight;
777 
778  int eeAddr = _ActivityBot_EE_Start_ + _ActivityBot_EE_Pins_;
779  unsigned char pinInfo[8] = {'s', 'p', 'L', 12, ' ', 'R', 13, ' '};
780  pinInfo[3] = (char) servoPinLeft;
781  pinInfo[6] = (char) servoPinRight;
782  ee_putStr(pinInfo, 8, eeAddr);
783 }
784 
785 
786 //To-do: Make write to EEPROM
787 void cal_encoderPins(int encPinLeft, int encPinRight) // drivePins function
788 {
789  ePinL = encPinLeft;
790  ePinR = encPinRight;
791 
792  int eeAddr = 8 + _ActivityBot_EE_Start_ + _ActivityBot_EE_Pins_;
793  unsigned char pinInfo[8] = {'e', 'p', 'L', 14, ' ', 'R', 15, ' '};
794  pinInfo[3] = (char) encPinLeft;
795  pinInfo[6] = (char) encPinRight;
796 
797  ee_putStr(pinInfo, 8, eeAddr);
798 }
799 
ee_getInt
int ee_getInt(int addr)
Get an int value from a certain address in the Propeller Chip's dedicated EEPROM. If you are fetching...
Definition: eeprom_getInt.c:24
INA
#define INA
Use to read the pins when corresponding DIRA bits are 0.
Definition: propeller1.h:153
servo_stop
void servo_stop(void)
Stops the servo process and frees a cog.
Definition: servo.c:197
ee_putByte
void ee_putByte(unsigned char value, int addr)
Store a byte value at a certain address in the Propeller Chip's dedicated EEPROM.
Definition: eeprom_putByte.c:24
us
int us
Propeller system clock ticks in 1 millisecond (us).
Definition: abcalibrate.c:36
CLS
#define CLS
CLS character (16) clears SimpleIDE's screen, erasing all characters and placing the cursor in the to...
Definition: simpletools.h:363
ee_putInt
void ee_putInt(int value, int addr)
Store an int value at a certain address in the Propeller Chip's dedicated EEPROM. An int value occupi...
Definition: eeprom_putInt.c:24
freqout
void freqout(int pin, int msTime, int frequency)
Use same cog to send square wave of a certain frequency for a certain amount of time....
Definition: freqout.c:10
pause
void pause(int time)
Delay cog from moving on to the next statement for a certain length of time.
Definition: libws2812.c:125
fdserial_open
fdserial * fdserial_open(int rxpin, int txpin, int mode, int baudrate)
Open a full duplex serial connection.
Definition: fdserial.c:20
dprint
int dprint(text_t *device, const char *format,...) __attribute__((format(printf
Print format "..." args to the device The output is limited to 256 bytes.
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
_ActivityBot_EE_Start_
#define _ActivityBot_EE_Start_
ActivityBot EEPROM calibration data start address.
Definition: abcalibrate.h:58
ee_putStr
void ee_putStr(unsigned char *s, int n, int addr)
Store a string of byte values starting at a certain address in the Propeller Chip's dedicated EEPROM.
Definition: eeprom_putStr.c:25
servo.h
Control up to 14 servos in another core. For up to 28, add the servoAux library to your project....
cal_servoPins
void cal_servoPins(int servoPinLeft, int servoPinRight)
Set the ActivityBot's servo pin connections to something other than the default P12 (left servo) and ...
Definition: abcalibrate.c:773
print
int print(const char *format,...) __attribute__((format(printf
Print format "..." args to the default simple terminal device. The output is limited to 256 bytes.
servo_speed
int servo_speed(int pin, int speed)
Set Parallax Continuous Rotation servo speed.
Definition: servo.c:51
CLKFREQ
#define CLKFREQ
Returns the current clock frequency.
Definition: propeller.h:46
simpletext.h
This library provides a collection of functions for communicating with text devices such as SimpleIDE...
writeChar
void writeChar(text_t *device, char c)
Send a character to the device.
Definition: writeChar.c:11
text_struct
Structure that contains data used by simple text device libraries.
Definition: simpletext.h:81
CNT
#define CNT
The system clock count.
Definition: propeller1.h:151
char
servo_set
int servo_set(int pin, int time)
Sets servo control signal to servo connected to a given pin for microsecond pulse durations.
Definition: servo.c:57
abcalibrate.h
This library has a function you can call to calibrate your ActivityBot. Example code that uses this l...
servo_setramp
int servo_setramp(int pin, int stepSize)
Set the maximum change in control signal a servo will change in a given 20 ms time period.
Definition: servo.c:100
cal_encoderPins
void cal_encoderPins(int encPinLeft, int encPinRight)
Set the ActivityBot's servo pin connections to something other than the default P14 (left encoder) an...
Definition: abcalibrate.c:787
cal_activityBot
void cal_activityBot()
Run the ActivityBot calibration function. Let it run until the P26 and P27 lights turn off....
Definition: abcalibrate.c:44
cogstart
int cogstart(void(*func)(void *), void *par, void *stack, size_t stacksize)
Start a new propeller LMM function/thread in another COG.
fdserial.h
This library supports creating and managing one or more full duplex serial connections with periphera...