PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Display.c
1 #include "abdrive.h"
2 
3 void interpolation_table_setup();
4 
5 
6 #ifdef _monitor_
7  volatile char abd_str[128];
8 #endif
9 
10 //#define test_t_interval
11 #ifdef test_t_interval
12  volatile int rec_t[8000 / 4];
13 #endif
14 
15 
16 volatile int abd_record; // Record values to an array
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 short abd_spdrL[120];
53 short abd_spdmL[120];
54 short abd_spdrR[120];
55 short abd_spdmR[120];
56 
57 //static int a = 0;
58 volatile int r;
59 
60 int abd_eeAddr;
61 
62 //static volatile int trimctr;
63 //static volatile int dca, trimticks;
64 
65 static volatile int kp[6];
66 
67 static volatile int ridx;
68 
69 //static volatile int *pwL;
70 //static volatile int *pwR;
71 //static volatile int *spdL;
72 //static volatile int *spdR;
73 
74 static volatile int pcount;
75 static volatile unsigned int _sprOld;
76 
77 //static volatile int phsL;
78 //static volatile int phsR;
79 //static volatile int phs[L];
80 //static volatile int phs[R];
81 static volatile int phs[2];
82 
83 static volatile int phsr[2];
84 
85 //static int trimFunction;
86 //static int encoderFeedback;
87 
88 volatile int abd_blockGoto;
89 
90 // drive_trimset
91 //volatile int abd_trimF[2];
92 //volatile int abd_trimB[2];
93 
94 //volatile int abd_trimticksF;
95 //volatile int abd_trimticksB;
96 
97 volatile int abd_speedOld[2];
98 volatile int abd_stopCtr[2];
99 
100 volatile int abd_stopPulseReps[2];
101 // Measured distance left/right
102 volatile int abd_ticks[2];
103 // Target speed left/right
104 volatile int abd_speedT[2];
105 // Current requested speed
106 volatile int abd_speed[2];
107 
108 
109 volatile int abd_ticksi[2];
110 
111 
112 volatile int abd_ticksf[2];
113 
114 
115 volatile int abd_gotoFlag[2];
116 
117 volatile int abd_rampStep[3];
118 volatile int abd_speedLimit[4];
119 
120 volatile int abd_ticksGuard[2];
121 
122 // distance calculated
123 volatile int abd_dc[2];
124 
125 // distance calculated (accumulated)
126 volatile int abd_dca[2];
127 
128 // error distance
129 volatile int abd_ed[2];
130 
131 // proportional
132 volatile int abd_p[2];
133 
134 // integral
135 volatile int abd_i[2];
136 
137 // Accumulated errors L/R
138 volatile int abd_ea[2];
139 
140 
141 // servoPins
142 volatile int abd_sPin[2];
143 
144 // Encoder Pins
145 volatile int abd_ePin[2];
146 
147 // display
148 volatile int abd_elCnt[2]; // ?????? Instance count different
149 volatile int abd_cntrIdx[2];
150 
151 
152 // Center values
153 static volatile int cntrVal[2];
154 static volatile int ti[2];
155 static volatile int state[2];
156 // servo speeed interpolated
157 static volatile int ssi[2];
158 static volatile int drive[2];
159 
160 static volatile int speedPrev[2];
161 volatile int abd_nudgeCtr[2];
162 volatile int abd_nudgeInc[2]; // ??? remove ???
163 volatile int abd_distError[2];
164 
165 volatile int sign[2];
166 volatile int abd_dist[2];
167 
168 volatile int abd_ditherA[2];
169 volatile int abd_ditherAa[2];
170 volatile int abd_ditherAd[2];
171 volatile int abd_ditherAp[2];
172 
173 volatile int abd_ditherV[2];
174 volatile int abd_ditherVa[2];
175 volatile int abd_ditherVd[2];
176 volatile int abd_ditherVp[2];
177 
178 volatile int abd_speedi[2];
179 volatile int abd_speedd[2];
180 volatile int abd_dvFlag[2];
181 
182 
183 
184 
185 
186 
187 
188 //#ifdef interactive_development_mode
190 {
191  //
192  if(!abd_intTabSetup) interpolation_table_setup();
193 
194  print("\rINTERPOLATION TABLE DATA\r\r");
195 
196  print("=== LEFT SERVO ===\n\n");
197  print("Table Entries = %d\nZero Speed Index = %d\n\n", abd_elCnt[ABD_L], abd_cntrIdx[ABD_L]);
198  print("Index\tServo Drive\tEncoder Ticks/Second\n");
199  print("-----\t-----------\t--------------------\n");
200  for(int r = 0; r < abd_elCnt[ABD_L]; r++)
201  {
202  print("%d\t%d\t\t%d\n", r, abd_spdrL[r], abd_spdmL[r]);
203  }
204 
205  print("\n\n=== RIGHT SERVO ===\n\n");
206  print("Table Entries = %d\nZero Speed Index = %d\n\n", abd_elCnt[ABD_R], abd_cntrIdx[ABD_R]);
207  print("Index\tServo Drive\tEncoder Ticks/Second\n");
208  print("-----\t-----------\t--------------------\n");
209  for(int r = 0; r < abd_elCnt[ABD_R]; r++)
210  {
211  print("%d\t%d\t\t%d\n", r, abd_spdrR[r], abd_spdmR[r]);
212  }
213 
214  //getchar();
215  //#endif
216  //
217 }
218 //#endif // interactive_development_mode
219 
220 /*
221 //#ifdef interactive_development_mode
222 void drive_trimDisplay(void)
223 {
224  //
225  if(!abd_intTabSetup) interpolation_table_setup();
226 
227  print("trimFL %d, trimFR %d, trimBL %d, trimBR %d, trimticksF %d, trimticksB %d\n",
228  abd_trimF[L], abd_trimF[R], abd_trimB[L], abd_trimB[R], abd_trimticksF, abd_trimticksB);
229  //
230 }
231 //#endif // interactive_development_mode
232 */
233 
234 
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.
drive_displayInterpolation
void drive_displayInterpolation(void)
Displays the interpolation table stored in EEPROM by the calibration step. For more info,...
Definition: Display.c:189
abdrive.h
This library takes care of encoder monitoring and servo signaling, and provides a simple set of funct...