CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

READING ADC VALUE THROUGH RS232

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
GUEST
Guest







READING ADC VALUE THROUGH RS232
PostPosted: Fri Mar 03, 2006 11:08 am     Reply with quote

I wanted to see what the value when I use read_adc() command. So, I connect the TX pin from PIC16F876A through the RS232 port, so data can be displayed on HyperTerminal. However, the data I received was really weird and funky. Can someone show me how to make it shows by string and decimal number? Thank you
Ttelmah
Guest







PostPosted: Fri Mar 03, 2006 11:18 am     Reply with quote

First, you need an RS232 line driver/inverter in the signal, otherwise you will see garbage. Hopefully you have this?.
The data is a pure 'binary' number. To turn this into something 'readable', use printf. So assuming the adc_value, was in a 16bit variable called 'adc_value', you could use:
printf("%5ld\n\r",adc_value);

The '\n\r' bit is a line feed and carriage return, so the numbers would print like:
10
20
25
30
etc...

Best Wishes
GUEST
Guest







READING ADC VALUE THROUGH RS232
PostPosted: Fri Mar 03, 2006 11:29 am     Reply with quote

In my header I have the driver already. For example,

#use RS232(.....)

printf("The value is: %f\n", value);

but it still didn't work for me. anything else that I can do to show

The value is: 3.5
rberek



Joined: 10 Jan 2005
Posts: 207
Location: Ottawa, Canada

View user's profile Send private message

PostPosted: Fri Mar 03, 2006 12:05 pm     Reply with quote

1) As ttelmah mentioned, do you have a MAX232 line driver IC between the PIC and the RS232 cable to the PC? If not stop here and install one properly.


2) Otherwise, do you have the baud rate, stop bits, parity and flow control set correctly in Hyperterminal? The most common setting is baudrate-N-1 with hardware flow control set to none.
_________________
The difference between genius and stupidity is that genius has its limits...
GUest
Guest







PostPosted: Mon Mar 06, 2006 4:59 am     Reply with quote

Are you sure your HW is connected properly?

You connection should be something lik the following, check out this sonicdej's post...
http://ccsinfo.com/forum/viewtopic.php?t=25905&sid=2f78398b693979fae1bb2398898dcb93
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group