Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 06, 2016, 05:06:14 17:06


Login with username, password and session length


Pages: [1]
Print
Author Topic: DRIVE ADXL202 VIA PIC BASIC PRO?  (Read 2233 times)
0 Members and 1 Guest are viewing this topic.
hamid9543
Active Member
***
Offline Offline

Posts: 120

Thank You
-Given: 45
-Receive: 3


« on: July 30, 2008, 09:58:23 09:58 »

HI TO ALL MEMBER!
i want to drive adxl202 with 16f84a or 16f877 and compiler is picbasic pro or proton.
i read data sheet but i donot now how working and how read data from ADXL.
THX
Logged
mississippi1
Newbie
*
Offline Offline

Posts: 27

Thank You
-Given: 24
-Receive: 7


« Reply #1 on: July 30, 2008, 11:56:51 11:56 »

There is a pulsin instruction that gives you the time of the pulse. You can measure the high and the low time. After this you can do what you want with the values.
Logged
taos
Newbie
*
Offline Offline

Posts: 18

Thank You
-Given: 5
-Receive: 56


« Reply #2 on: July 31, 2008, 05:32:25 17:32 »

Hi!
Here you have a sample code with a 16F877 but from C language:

http://www.dunmire.org/projects/MEEPS/software/level.c

More info about ADXL202:
The ADXL202 outputs a PWM with 8ms periode. At 0 degree is puls / pause =1/2 (pulse 4ms / pause 4ms). If now the sensor is +90 degree (pulse 7ms / paus 1ms) and at -90 degree (pulse 1ms / pause 7ms). You can calculate the angle of the sensor with: x=(puls:pause)*var
Use your TMR0 counter and INTCON timer prescaler bits to set up an interrupt routine which at precise intervals samples the PIC input (ADXL202 output) pin for a high or low (1 or 0). Since you are working with ratios, just count the total of 1's and divide by total 0's, or vice-versa if required, to determine your angle. You can do some error checking by counting the total of 1's and 0's.

Or...since you know the the total period is 8ms, you can just count the number of 1's with a known interrupt interval and calculate.

Or....some PIC's have an edge-triggered hardware interrupt on some pins. When your pin goes high, do the interrupt routine by starting an internal timer, sampling the pin until it goes low. Your timer count at that point should give you enough information to make calculations, which you will have to do during the low pin time.

Regards,
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC