thivanka321
Newbie level 5
i came across this problem while i' m doing my final year project.
i'm using MMA7260Q accelerometer to detect acceleration in the X,Y and Z direction.
as out put of this sensor it gives 3 analogue signals proportional to X, Y and Z acceleration.
i need to convert these three analogue signals to digital using pic 18f452 (which has 10 bit A/D module) and transmit this values to computer hyper terminal through serial port(DB9).
i wrote code in C18 , to display A/D convert results by LEDs,which are connected to 10 terminals(port B and Port C) in pic.
but i really wanted is, sent these converted digital values to computer hyper terminal through serial port.
can some one please sent me c18 codes to transmit above digital data to pc hyper terminal.
i have 2 day more to finish this project.please reply me soon.
(I'm using 10mhz oscillator with pic)
here are codes i l've already written to display through LEDS.
[/code]
i'm using MMA7260Q accelerometer to detect acceleration in the X,Y and Z direction.
as out put of this sensor it gives 3 analogue signals proportional to X, Y and Z acceleration.
i need to convert these three analogue signals to digital using pic 18f452 (which has 10 bit A/D module) and transmit this values to computer hyper terminal through serial port(DB9).
i wrote code in C18 , to display A/D convert results by LEDs,which are connected to 10 terminals(port B and Port C) in pic.
but i really wanted is, sent these converted digital values to computer hyper terminal through serial port.
can some one please sent me c18 codes to transmit above digital data to pc hyper terminal.
i have 2 day more to finish this project.please reply me soon.
(I'm using 10mhz oscillator with pic)
here are codes i l've already written to display through LEDS.
Code:
#include <stdio.h>
#include<P18F452.h>
#include<delays.h>
#include<adc.h>
void adconvert (void)
{
Delay10TCYx(1);
ADCON0bits.GO=1;
while(ADCON0bits.DONE==1)
{
PORTB=ADRESL;
PORTD=ADRESH;
Delay10TCYx(10);
}
}
void main (void)
{
TRISB=0;
TRISD=0;
TRISAbits.TRISA0=1;
TRISAbits.TRISA1=1;
TRISAbits.TRISA3=1;
ADCON0=0x81;//fosc 32,initial AN0 channel,AD on
ADCON1=0x84;//right justified,AN0,AN2,AN3 analogue
while(1)
{
ADCON0bits.CHS2=0;
ADCON0bits.CHS1=0;
ADCON0bits.CHS0=0;
adconvert();
ADCON0bits.CHS2=0;
ADCON0bits.CHS1=0;
ADCON0bits.CHS0=1;
adconvert();
ADCON0bits.CHS2=0;
ADCON0bits.CHS1=1;
ADCON0bits.CHS0=1;
adconvert();
}
}
[/code]