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

RS232 Comms with PC ?????

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







RS232 Comms with PC ?????
PostPosted: Wed Feb 19, 2003 3:58 am     Reply with quote

<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
Steve H
Guest







Re: RS232 Comms with PC ?????
PostPosted: Wed Feb 19, 2003 10:12 am     Reply with quote

If you search Google you can find many examples of RS232 code in C.

Also I think P.H. Anderson has code posted on his website (search this board for Anderson to find his link).

I have VB code posted on my website.

Steve H.
___________________________
This message was ported from CCS's old forum
Original Post ID: 11887
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