Jeremy Ragsdale Guest
|
RS232 Comms with PC ????? |
Posted: Wed Feb 19, 2003 3:58 am |
|
|
<font face="Courier New" size=-1>Hello all,
I have a PIC16F876 talking to the PC via MAX233 chip. This seems to be working fine, I can see the PIC output at the terminal. My question is, I want to have a C or C++ programm on the PC to read the data comming from the PIC. For example I have 4 Analohue sources which I am sampling continuously, each time I sample a source I wish to recive the data in the PC and store the value in a variable. The code for the PIC is below which I belive is correct, I would appreciate it very much if anyone could help me out. Oh yea I om using Windows Platform, either NT/2000 or XP
Thanks in advance
Jeremy
#include <16f876.h>
#fuses HS,NOWDT,NOPROTECT,NOBROWNOUT,NOLVP,PUT
#use Delay(Clock=4000000)
#use rs232(baud=19200,xmit=pin_c6,rcv=pin_c7,parity=n,bits=8)
void main(void)
{
float sensor1,sensor2,sensor3,sensor4;
setup_adc(adc_clock_div_32);
setup_adc_ports(all_analog);
while(1)
{
set_adc_channel(1);
delay_us(10);
sensor1 = read_adc();
sensor1 = sensor1*.02;
printf("\%f",sensor1);
set_adc_channel(2);
delay_us(10);
sensor2 = read_adc();
sensor2 = sensor2*.02;
printf("\%f",sensor2);
set_adc_channel(3);
delay_us(10);
sensor3 = read_adc();
sensor3 = sensor3*.02;
printf("\%f",sensor3);
set_adc_channel(4);
delay_us(10);
sensor4 = read_adc();
sensor4 = sensor4*.02;
printf("\%f",sensor4);
delay_ms(100);
}
}</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 11863 |
|