??? 11/10/05 07:31 Read: times |
#103509 - ISR Responding to: ???'s previous message |
thanx for all the help maarten. u have certainly helped a lot. i think i am actually measuring movement now!
i just want to know if im doing things right. i am going to include some definitions and my ISR below. // definitions sbit DX = P0^6; // define PWM port pin - [DOUTX on accelerometer] sbit DY = P0^7; // define PWM port pin - [DOUTY on accelerometer] unsigned int xVal1, xVal2, pulseX1, pulseX2, xMove; char XReading1 = 1; // this only so i know when i have taken first pulse width and when i have taken 2nd pulse width void PCA_ISR (void) interrupt 9 { if (CCF0) { if (DX) { // process rising edge xVal1 = PCA0CPL0; xVal1 += PCA0CPH0<<8; } else { // process falling edge xVal2 = PCA0CPL0; xVal2 += PCA0CPH0<<8; if (XReading1) { pulseX1 = xVal2 - xVal1; // 1st pulse width } else { pulseX2 = xVal2 - xVal1; // 2nd pulse width } if (!XReading1) { // when subtracting 2 pulse widths from each other // you will measure movement, according to // man-down PDF i read xMove = abs(pulseX1 - pulseX2); } XReading1 = !XReading1; } CCF0 = 0; // clear compare indicator } else if (CF) { CF = 0; } } when i have no motion, the xMove value never goes above 17, as soon as i move the board around, it goes above that. so i must be measuring movement. i just want to know if im doing this correctly. another thing, CEX1 which is on PO.7, i also use PCA0CP0 to measure the pulse width? i added DY in the ISR using the same code as i do for DX, just naming the variables as 'y' where neccesary, and when moving the board around, i do get different values on xMove & yMove. |
Topic | Author | Date |
PWM | 01/01/70 00:00 | |
for the PCA | 01/01/70 00:00 | |
pulse width | 01/01/70 00:00 | |
input or output ? | 01/01/70 00:00 | |
input | 01/01/70 00:00 | |
output != input | 01/01/70 00:00 | |
ISR | 01/01/70 00:00 | |
CEX1 | 01/01/70 00:00 | |
Tilt sensor![]() | 01/01/70 00:00 |