Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

taking A/D results from pic 18f452 to computer hyperterminal

Status
Not open for further replies.

thivanka321

Newbie level 5
Joined
Mar 10, 2010
Messages
8
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
Sri Lanka
Activity points
1,338
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:
#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();
}
}

:cry:[/code]
 

Re: taking A/D results from pic 18f452 to computer hyperterm

Hi,

try this:
Code:
#include <usart.h>
#include <stdlib.h>
//Define a string:
char 	str[7];

//initialize the serial port :

// serial port 10Mhz clock, open USART 19200 baud 8/n/1
OpenUSART( USART_TX_INT_OFF &USART_RX_INT_OFF &USART_ASYNCH_MODE&USART_EIGHT_BIT &USART_CONT_RX &USART_BRGH_HIGH,32 );		// 32 for 19200	at 10MHz	page 173 of 18F452 datasheet

//convert the integer to a string and print:
itoa(ADCVALUE,str);
putsUSART(str);

:D
 

Re: taking A/D results from pic 18f452 to computer hyperterm

HI,

THANKS a lot and i'll try your code and let you know the results.thanks again.:D
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top