PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
servoPins.c
1 #include "abdrive.h"
2 
3 void interpolation_table_setup();
4 
5 #ifdef _monitor_
6  volatile char abd_str[128];
7 #endif
8 
9 //#define test_t_interval
10 #ifdef test_t_interval
11  volatile int rec_t[8000 / 4];
12 #endif
13 
14 
15 volatile int abd_record; // Record values to an array
16 
17 
18 void drive_com(int arrayLcnt, int arrayRcnt,
19  int centerL, int centerR,
20  short *pwAddrL, short *pwAddrR,
21  short *spdAddrL, short *spdAddrR);
22 //void drive_set(int left, int right);
23 void abd_encoders(void *par);
24 //void interpolate(int* ltmp, int* rtmp);
25 void interpolation_table_setup();
26 //void servos_diffDrive(void);
27 //void drive_record(int startStop);
28 //void drive_displayControlSystem(int start, int end);
29 void set_drive_speed(int left, int right);
30 void interpolate2(int *ltmp, int *rtmp);
31 //void drive_rampStep2(int left, int right);
32 void abd_sample(void);
33 
34 
35 // Servo pulse counter
36 volatile unsigned int _servoPulseReps;
37 volatile int abd_dsr; // Distance sampling rate
38 volatile int abd_zeroDelay;
39 volatile int abd_us;
40 volatile int abd_intTabSetup;
41 
42 //static int cog;
43 //static int servoCog2 = 0;
44 //static unsigned int stack[44 + 252];
45 //static unsigned int stack[44 + 352];
46 //static unsigned int servoStack[(160 + (150 * 4)) / 4];
47 
48 int abd_spdrL[120];
49 int abd_spdmL[120];
50 int abd_spdrR[120];
51 int abd_spdmR[120];
52 
53 //static int a = 0;
54 volatile int r;
55 
56 int abd_eeAddr;
57 
58 static volatile int trimctr;
59 static volatile int dca, trimticks;
60 
61 static volatile int kp[6];
62 
63 static volatile int ridx;
64 
65 //static volatile int *pwL;
66 //static volatile int *pwR;
67 //static volatile int *spdL;
68 //static volatile int *spdR;
69 
70 static volatile int pcount;
71 static volatile unsigned int _sprOld;
72 
73 //static volatile int phsL;
74 //static volatile int phsR;
75 //static volatile int phs[L];
76 //static volatile int phs[R];
77 static volatile int phs[2];
78 
79 static volatile int phsr[2];
80 
81 //static int trimFunction;
82 //static int encoderFeedback;
83 
84 volatile int abd_blockGoto;
85 
86 // drive_trimset
87 volatile int abd_trimF[2];
88 volatile int abd_trimB[2];
89 
90 volatile int abd_trimticksF;
91 volatile int abd_trimticksB;
92 
93 volatile int abd_speedOld[2];
94 volatile int abd_stopCtr[2];
95 
96 volatile int abd_stopPulseReps[2];
97 // Measured distance left/right
98 volatile int abd_ticks[2];
99 // Target speed left/right
100 volatile int abd_speedT[2];
101 // Current requested speed
102 volatile int abd_speed[2];
103 
104 
105 volatile int abd_ticksi[2];
106 
107 
108 volatile int abd_ticksf[2];
109 
110 
111 volatile int abd_gotoFlag[2];
112 
113 volatile int abd_rampStep[3];
114 volatile int abd_speedLimit[4];
115 
116 volatile int abd_ticksGuard[2];
117 
118 // distance calculated
119 volatile int abd_dc[2];
120 
121 // distance calculated (accumulated)
122 volatile int abd_dca[2];
123 
124 // error distance
125 volatile int abd_ed[2];
126 
127 // proportional
128 volatile int abd_p[2];
129 
130 // integral
131 volatile int abd_i[2];
132 
133 // Accumulated errors L/R
134 volatile int abd_ea[2];
135 
136 
137 // servoPins
138 volatile int abd_sPin[2];
139 
140 // Encoder Pins
141 volatile int abd_ePin[2];
142 
143 // display
144 volatile int abd_elCnt[2]; // ?????? Instance count different
145 volatile int abd_cntrIdx[2];
146 
147 
148 // Center values
149 static volatile int cntrVal[2];
150 static volatile int ti[2];
151 static volatile int state[2];
152 // servo speeed interpolated
153 static volatile int ssi[2];
154 static volatile int drive[2];
155 
156 static volatile int speedPrev[2];
157 volatile int abd_nudgeCtr[2];
158 volatile int abd_nudgeInc[2]; // ??? remove ???
159 volatile int abd_distError[2];
160 
161 volatile int sign[2];
162 volatile int abd_dist[2];
163 
164 volatile int abd_ditherA[2];
165 volatile int abd_ditherAa[2];
166 volatile int abd_ditherAd[2];
167 volatile int abd_ditherAp[2];
168 
169 volatile int abd_ditherV[2];
170 volatile int abd_ditherVa[2];
171 volatile int abd_ditherVd[2];
172 volatile int abd_ditherVp[2];
173 
174 volatile int abd_speedi[2];
175 volatile int abd_speedd[2];
176 volatile int abd_dvFlag[2];
177 
178 
179 
180 void interpolation_table_setup(void);
181 
182 volatile int abd_sPinL, abd_sPinR; // Global variables
183 volatile int abd_ePinL, abd_ePinR;
184 volatile int abd_us;
185 volatile int abd_intTabSetup;
186 
187 
188 void drive_servoPins(int servoPinLeft, int servoPinRight) // drivePins function
189 {
190  //abd_sPinL = servoPinLeft; // Local to global assignments
191  //abd_sPinR = servoPinRight;
192  //if(!abd_us) abd_us = CLKFREQ/1000000;
193 
194  int eeAddr = _ActivityBot_EE_Start_ + _ActivityBot_EE_Pins_;
195  unsigned char pinInfo[8] = {'s', 'p', 'L', 12, ' ', 'R', 13, ' '};
196  pinInfo[3] = (char) servoPinLeft;
197  pinInfo[6] = (char) servoPinRight;
198 
199  ee_putStr(pinInfo, 8, eeAddr);
200  /*
201  if(!abd_intTabSetup)
202  {
203  interpolation_table_setup();
204  }
205  */
206 }
207 
208 void drive_encoderPins(int encPinLeft, int encPinRight) // drivePins function
209 {
210  //abd_ePinL = encPinLeft;
211  //abd_ePinR = encPinRight;
212  //if(!abd_us) abd_us = CLKFREQ/1000000;
213 
214  int eeAddr = 8 + _ActivityBot_EE_Start_ + _ActivityBot_EE_Pins_;
215  unsigned char pinInfo[8] = {'e', 'p', 'L', 14, ' ', 'R', 15, ' '};
216  pinInfo[3] = (char) encPinLeft;
217  pinInfo[6] = (char) encPinRight;
218 
219  ee_putStr(pinInfo, 8, eeAddr);
220 
221  /*
222  if(!abd_intTabSetup)
223  {
224  interpolation_table_setup();
225  }
226  */
227 }
228 
229 void drive_pins(int servoPinLeft, int servoPinRight, int encPinLeft, int encPinRight) // drivePins function
230 {
231  drive_servoPins(servoPinLeft, servoPinRight);
232  drive_encoderPins(encPinLeft, encPinRight);
233 }
234 
235 
236 
drive_encoderPins
void drive_encoderPins(int encPinLeft, int encPinRight)
Set encoder pins to values other than the default P14 for left encoder and P15 for right encoder....
Definition: servoPins.c:208
_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
drive_pins
void drive_pins(int left, int right)
Set up left and right wheel servo pin connections.
Definition: servodiffdrive.c:6
char
drive_servoPins
void drive_servoPins(int servoPinLeft, int servoPinRight)
Set servo pins to values other than the default P12 for left servo and P13 for right servo....
Definition: servoPins.c:188
abdrive.h
This library takes care of encoder monitoring and servo signaling, and provides a simple set of funct...