My school project is about rc aircraft. I am trying to use the pic16f684 to read the signals from mesmic 2125 accelerometer using assembly language.
The accelerometer is used to sense angle so the pic will execute a command according to the angles. The commands i can find are all in basic stamp and c-programming languages. The pic is to be programmed in assembly language using the Mplab v7.31 compiler.
1)How to read the accelerometer's X-out and Y-out signals in assembly language?
2)Is there a need to connect the T-out of the accelerometer to the pic?
3)What are the assembly languages available for reading the signals from the accelerometer?
4)How do we use the pic to generate the waveform to actuate the servo movements?
5)Which timer in the pic is suitable for the accelerometer? It have timer0, timer1 and timer2 modules.
I am stuck with these questions. Thanks for those who help out.
in the datasheet , its says that , the chip has 3 o/ps X out, Yout and Tout , and the X/Y out is a PWM wave (100Hz) proportional to A , so u need to decode the pulse width of the wave to the acce: , for that first lock on to the high going part (an interrupt ?) , and count (start a timer ) until it goes low . that is T1 , and u know T2 , and calculate.
in the datasheet , its says that , the chip has 3 o/ps X out, Yout and Tout , and the X/Y out is a PWM wave (100Hz) proportional to A , so u need to decode the pulse width of the wave to the acce: , for that first lock on to the high going part (an interrupt ?) , and count (start a timer ) until it goes low . that is T1 , and u know T2 , and calculate.
ok...i understand about the calculations on T1 and T2 already.
could u please show me a simple program to elaborate more on what u said about decoding the pulse width? Thx
ok...i understand about the calculations on T1 and T2 already.
could u please show me a simple program to elaborate more on what u said about decoding the pulse width? Thx
;say portb,0 receives one i/p
; configure timer1 (16bit) .. say 4Mhz clock
loop1 btfss portb,0 ; polling to see when 0 goes high
goto loop1 ; this is loop until 0 goes high
bsf t1con,tmr1on ;start the timer
loop2 btfsc portb,0 ; wait it become low
goto loop2
bcf t1con,tmr1on ;stop timer
; now up duration in Timer 1 registers
This is like an RC helicopter or plane? I think that the inertial forces of movement and the vibration from the motor might make your accelerometer data useless in trying to find the angle. I've found that using an accelerometer alone in my vehicle datalogger is not as accurate as I would like due to the lean when accelerating, decelerating, and turning. A plane would be much worse.
A gyro would be a better option. There are several small digital output gyro's out there.
dirtylude is correct - even if the data were accurate, using the x and y axis data alone will be useless because in a (level) coordinated turn, the x,y acceleration should be zero.
Hi guys. Thanks for the replies. On the accelerometer issue, Im using it on a electric plane so there are huge reductions in vibrations. Actually I initially also didn't know about this shortcoming of the accelerometer. Thanks to you guys for the warning.
I want to ask about something else.
The initialisation needed to implement timer, interrupts, portA & portC.