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

Can not receive data from slave

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



Joined: 15 Feb 2015
Posts: 39

View user's profile Send private message

Can not receive data from slave
PostPosted: Fri Aug 14, 2015 10:31 am     Reply with quote

i communicate rs485 with 2 PIC 16f887 in real board. Master send data to slave is OK but slave can not send data to master. Slave read temperater from ds18b20 and send data back to master . Both of simulation in proteus and in real board is failure. :( Please help me

This is my simple code master:
Code:

#include <16f887.h>
#fuses hs,nowdt,nolvp,noprotect,put
#use delay(clock=16M)
#include <lib_lcd.c>
#define RS485_ID  0x40 
#include <rs485.c>
unsigned int i,data_send[12]={"Hello world"},result,data_get[16];
float Temperature;

void main()
{
   set_tris_b(0x0f);port_b_pullups(0x0f);
   lcd_init();
   rs485_init();
   while(true)
   {
      if(rs485_get_message(Temperature,0))
      {
         lcd_gotoxy(1,1);printf(lcd_putc,"%f",Temperature);
      }
   }
}

This is code for slave
Code:

#include <16f887.h>
#fuses hs,nowdt,nolvp,noprotect,put
#use delay(clock=16M)
#include <lib_lcd.c>
#define RS485_ID  0x20 
#include <rs485.c>
#include <lib_ds18b20_old.c>
unsigned int i,data_send[12]={"Sang Nguyen"},result,data_get[16];
float Temperature;

void main()
{
   unsigned int low_value,high_value;
   set_tris_b(0x0f);port_b_pullups(0x0f);
   lcd_init();
   rs485_init();
   while(true)
   {
      Temperature=ds18b20_read();
      rs485_send_message(0x40,12,Temperature);
      lcd_gotoxy(1,1);printf(lcd_putc,"%f",Temperature);
   }
}
And this is connection


code read temperature ds18b20 tested ok but slave can't send temperature to pic :(
temtronic



Joined: 01 Jul 2010
Posts: 9245
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Aug 14, 2015 11:03 am     Reply with quote

possible problems....
1) no pullup and pull down resistors on the RS485 'network'. Check any book/site/etc. about how to properly configure RS485 for answers

2) RS485 driver not configured correctly for individual control of the RS486 driver chips. You'll have to look at the driver for coments on how to do it.

3) there are of course a couple dozen or so things 'wrong' with the 'schematic' you've posted.

Jay
talamahahahe



Joined: 15 Feb 2015
Posts: 39

View user's profile Send private message

PostPosted: Fri Aug 14, 2015 12:28 pm     Reply with quote

First thank for your comment.
When i just use 1 resistor between A B, it runs ok but when i use pull up and pull down, it not run. In driver rs485.c i was re-configure actually i was send and receive data well. I use button, when push button on master, master will send data to slave and when push button on slave, slave will send data to master. Everything is ok, but i dont know how can slave send data while it receive,... and whether functions in rs485.c have support for float variant ???
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