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 CCS Technical Support

MASTER Slave communicaton

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







MASTER Slave communicaton
PostPosted: Thu Jul 12, 2007 2:23 am     Reply with quote

PLZ some one can help me?
- LM35 is conected to Slave controller(PIC16f877)
-slave is sending the temperature value to master controller(pic16f877) as string string via RS232.
-master on reciving this string on soft-port will send this string to PC on hardport.
-slave also attach its adress with the string.

ON master side i have to seprate the adress and temp value for my control logic.

PLZ can some one help me by giving me the code of
-how the slave will send string(temperatur + adress)
-how the master will receive the string
-how the master will saperate the adress and teperature value
atta
Guest







PostPosted: Fri Jul 13, 2007 1:56 pm     Reply with quote

Code:
printf ("%3.1fslave1\r",(float)temperatur);
\\slave is sending temperature value

************************************************************
master will receive following string i want to separate temperature value and slave1 from this string.
i am using following code at master side to separate temperature value and slave1 from this string.

Code:
fgets (string1,COM_A);
    fprintf (PC, string1);
     
    temp1=strtod(string1,&ptr1);
    delay_ms (1000); 
    fprintf (PC,"temperature(Slave) = ");   
    fprintf (PC,"%3.1f", (float)temp1);

************************************************************
the above code works if slave send sitring by this way

Code:
printf("25.5A\r");
Guest








PostPosted: Fri Jul 13, 2007 2:24 pm     Reply with quote

PLZ help me where is the problem in the above code
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jul 13, 2007 2:46 pm     Reply with quote

It's not clear to me exactly what you want to do. You need to show
the string that your master will receive, and then show the two extracted
sub-strings that you want to get.

It may be that you want the C language equivalent of MID$ in Basic.
If so, see this thread.
http://www.ccsinfo.com/forum/viewtopic.php?t=27121
atta
Guest







PostPosted: Fri Jul 13, 2007 3:01 pm     Reply with quote

actuly i want to use this function



Code:
float result;
char str[12]="123.45hello";

char *ptr;

result=strtod(str,&ptr);

//result is 123.45 and ptr is "hello"


********************************
slave send the following command to master
Code:

temperature=read_adc ();
printf ("%3.1fA\n\r",(float)temperature);

*****************************
master on receiving this string has to send the result to PC seriallly by using the following code
Code:
fgets (string1,COM_A);// from slave
   
     
    result=strtod(string1,&ptr1);

     
    fprintf (PC,"%6.2f", (float)result);//to PC
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