![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
talamahahahe
Joined: 15 Feb 2015 Posts: 39
|
Can not receive data from slave |
Posted: Fri Aug 14, 2015 10:31 am |
|
|
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 :( |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9177 Location: Greensville,Ontario
|
|
Posted: Fri Aug 14, 2015 11:03 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
talamahahahe
Joined: 15 Feb 2015 Posts: 39
|
|
Posted: Fri Aug 14, 2015 12:28 pm |
|
|
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 ??? |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|