AtomSoft
Well-Known Member
I have a Accelerometer Module with a MX2125 Chip on board and it supposed to pulse out like a PWM but instead of PWM i was woundering with a multimeter i read 2.5v on a level surface can i use a A/D Conversion to get the values instead?
Here is the code i tried to create ... the only thing is when its level even if its not moving i get different values sometimes.... I assuming its a unstable power type issue.. should i just add a capactior? I was using this on a junebug in debug mode....
Here is the code i tried to create ... the only thing is when its level even if its not moving i get different values sometimes.... I assuming its a unstable power type issue.. should i just add a capactior? I was using this on a junebug in debug mode....
Code:
list p=18F1320
include <p18F1320.inc>
CONFIG OSC = INTIO1, WDT = OFF, LVP = OFF, DEBUG = ON
Axis_Port Equ PORTA ; Set Axis_Port to Equal PortB
Axis_Tris Equ TRISA ; Set Axis_Tris to Equal TrisB
X_Axis Equ 1 ; Set X_Axis to Equal 1
Y_Axis Equ 2 ; Set Y_Axis to Equal 4
org 0x0000 ; Beggining of Program
Init
movlw 0x72 ; 8MHz clock select
movwf OSCCON ; Move to OSCILLATOR CONTROL REGISTER
clrf Axis_Tris ; Set All Output
bsf Axis_Tris, X_Axis ; Set Axis_Tris.X_Axis as input
bsf Axis_Tris, Y_Axis ; Set Axis_Tris.Y_Axis as input
clrf ADCON1
movlw b'00000101' ; Enable A/D, AN1
movwf ADCON0
Main
bsf ADCON0,GO ; Start A/D conversion
AD_Loop
btfsc ADCON0,DONE ; Check if done. If not goto adloop else skip loop
goto AD_Loop
goto Main ; Loop back to main
End