View previous topic :: View next topic |
Author |
Message |
GUEST Guest
|
READING ADC VALUE THROUGH RS232 |
Posted: Fri Mar 03, 2006 11:08 am |
|
|
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
|
|
Posted: Fri Mar 03, 2006 11:18 am |
|
|
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 |
Posted: Fri Mar 03, 2006 11:29 am |
|
|
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
|
|
Posted: Fri Mar 03, 2006 12:05 pm |
|
|
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
|
|
|
|