Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Forums > General Electronics Chat


General Electronics Chat This forum is for general chat about electronics, eg: Dont know what a part does? Dont know how to read a circuit? Want to get an opinion?

Reply
 
Thread Tools Display Modes
Old 26th April 2006, 05:57 AM   (permalink)
Default how to read accelerometer's signals with pic16f684?

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.
dh_87 is offline   Reply With Quote
Old 26th April 2006, 08:31 AM   (permalink)
akg
Default

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.
__________________
Gods own Country
Incredible !ndia

www.flickr.com/photos/_akg/

"Give a man a fish, and he will eat for a day. Teach that man to fish, and he will eat for a lifetime."
akg is online now   Reply With Quote
Old 26th April 2006, 08:54 AM   (permalink)
Default

Quote:
Originally Posted by akg
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
dh_87 is offline   Reply With Quote
Old 26th April 2006, 11:13 AM   (permalink)
akg
Default

Quote:
Originally Posted by dh_87
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 ..the following is concept code ..

Code:
;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
hope this helps
__________________
Gods own Country
Incredible !ndia

www.flickr.com/photos/_akg/

"Give a man a fish, and he will eat for a day. Teach that man to fish, and he will eat for a lifetime."
akg is online now   Reply With Quote
Old 26th April 2006, 12:35 PM   (permalink)
Default

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.
__________________
Mark Higgins
DirtyLude is offline   Reply With Quote
Old 26th April 2006, 02:59 PM   (permalink)
hyedenny
Default

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.
  Reply With Quote
Old 28th April 2006, 12:59 PM   (permalink)
Default

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.

Here's what I have done,

Timer0: OPTION_REG
Interrupts: INTCON, IOCA
PortA & PortC: ANSEL, TRISA, TRISC

Can you guys help me check if there's anything missing?. Thanks!
dh_87 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes




All times are GMT. The time now is 02:23 PM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.