View previous topic :: View next topic |
Author |
Message |
karthickiw
Joined: 09 Aug 2007 Posts: 82 Location: TN, India
|
Problem with RS485 |
Posted: Tue Jun 28, 2011 9:24 am |
|
|
hai Friends,
I tried to work with RS485 using ex_rs485.c example file. when i simulate circuit using proteus software i don't get send data on my receiver terminal.. i don't know what is error in my circuit and example code(i don't modified any line on ex_rs485.c).. please check my circuit and example code is correct r not..
Code: |
/////////////////////////////////////////////////////////////////////////
//// EX_RS485_CHAT.C ////
//// ////
|
+++++++++++++++++++++++
Code removed.
Reason: Forum rule #10
10. Don't post the CCS example code or drivers, or ask for such code and drivers.
-- Forum Moderator
+++++++++++++++++++++++ |
|
|
karthickiw
Joined: 09 Aug 2007 Posts: 82 Location: TN, India
|
check circuit |
Posted: Tue Jun 28, 2011 10:13 pm |
|
|
check my circuit connection is correct for ex_rs485.c program? |
|
|
John P
Joined: 17 Sep 2003 Posts: 331
|
|
Posted: Wed Jun 29, 2011 6:42 am |
|
|
There should be a pullup resistor on one RS485 line, and a pulldown resistor on the other. Set them up so that when the line isn't being driven, the state is idle, i.e. the processors are receiving a high level on RX. When I wire RS485, I use 3 180 ohm resistors, which give about the right 120 impedance to the line and do the pull up/down function as well.
And I'm not understanding the circuit diagram. Why are the two little oscilloscope things connected to pins of the processor, not to any of the communication lines? |
|
|
karthickiw
Joined: 09 Aug 2007 Posts: 82 Location: TN, India
|
same problem |
Posted: Wed Jun 29, 2011 7:16 am |
|
|
Thanks John,
still my problem not solve. i add pull up and pull down resister on my circuit, then also data not send to receiver microcontroller.. i think my program is hang in below function..
Code: | void rs485_wait_for_bus(int1 clrwdt)
{
int16 i;
RCV_OFF();
for(i=0; i <= (rs485_wait_time*20); ++i)
{
if(!input(RS485_RX_PIN))
{
i = 0;
}
else
{
delay_us(50);
}
if(clrwdt)
restart_wdt();
}
} |
|
|
|
karthickiw
Joined: 09 Aug 2007 Posts: 82 Location: TN, India
|
please help me friends |
Posted: Thu Jun 30, 2011 12:34 am |
|
|
please help me friends.. i try more then one week.. i don't get output for example program itself.. i don't know, problem in example program or my circuit connection..please check my circuit is correct and give some idea.. |
|
|
karthickiw
Joined: 09 Aug 2007 Posts: 82 Location: TN, India
|
PCM Prgram |
Posted: Fri Jul 01, 2011 10:02 pm |
|
|
PCM Programmer check this circuit is correct for ex_rs485.c program.. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jul 01, 2011 10:23 pm |
|
|
I can test it and the code on Sunday.
What is your compiler version ? |
|
|
karthickiw
Joined: 09 Aug 2007 Posts: 82 Location: TN, India
|
thanks PCM |
Posted: Fri Jul 01, 2011 11:00 pm |
|
|
my compiler version
IDE,PCB,PCM,PCH,PCD - 4.104.
my circuit is correct? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9241 Location: Greensville,Ontario
|
|
Posted: Sat Jul 02, 2011 5:12 am |
|
|
Quick comments
1) Proteus is JUNK ! Your program compiles yet there are HUGE errors in the schematic.
If you physically wire up the real parts like the 'schematic'....
Hardware errors include...
NO Vdd, Vss shown for the PIC !
No caps in the crystal oscillator section.
Probable incorrect RS485 bus resistors.
RS485 control pins ( *RE and DE ) can be tied together and controlled by one I/O pin (that's may be how the driver code is cut, would have to see).
Download the MAX487 datasheet, it tells you the correct value of resistors for the 485 bus.
Download the PIC datasheet for the proper crystal caps.
Without seeing you entire code, I can't tell where your program errors are, but the CCS driver does work. |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Jul 04, 2011 5:28 pm |
|
|
I spent some more time on it and got it working a little bit more, but
not really working yet. If I spent another 4-6 hours on it, I might be
able to discover the reasons why it doesn't work. But I don't need
to do this project and I've got better things to do with my time. So I'm
not going to work on it anymore. |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Mon Jul 04, 2011 11:48 pm |
|
|
Quote: | i don't know, problem in example program or my circuit connection |
As been said, the circuit won't work as sketched. But I don't know, if it's the real circuit. I would assume, that the basic circuit function will be checked first. For the RS485 interface, there's at least a wrong pull-up/pull-down polarity, which can be sufficient to make the application fail. As also said, the resistor values are too low.
I also took a quick look at the RS485 driver provided by CCS and used in the present ex_rs485 application. In my opinion, the handling of the UART interface is strange. I don't believe that it's necessary to switch between a software and a hardware UART driver in operation for a standard RS485 application. I never came across it in various RS485 applications implemented with large choice of uPs. But I assume, that it works, though. |
|
|
karthickiw
Joined: 09 Aug 2007 Posts: 82 Location: TN, India
|
Thank you.. |
Posted: Tue Jul 12, 2011 5:52 am |
|
|
Thank CCS friends for helping. I got output. Ex_r485.c code is correct.
Thank you lot... |
|
|
xeta123
Joined: 20 Aug 2011 Posts: 3
|
Re: Thank you.. |
Posted: Sat Aug 20, 2011 3:51 am |
|
|
karthickiw wrote: | Thank CCS friends for helping. I got output. Ex_r485.c code is correct.
Thank you lot... |
Hey, facing the same problem here...What solved it? |
|
|
xeta123
Joined: 20 Aug 2011 Posts: 3
|
Corrupt MAX487 Proteus Model |
Posted: Mon Aug 22, 2011 3:42 am |
|
|
Okz guys the culprit was the proteus max 487 model itself.
The model fails to fulfill the datasheet condition:
http://www.embeddedj.co.th/downloads/sheets/ic/MAX485.pdf See page 10 under heading: Function Table
In receiving, when RE = DE = 0 and If voltage between A-B is zero ( when A-B both are high) RO should be high but the proteus model gives RO low. This causes the the program to stay in this routine forever
Code: |
void rs485_wait_for_bus(int1 clrwdt)
{
int16 i;
RCV_OFF();
for(i=0; i <= (rs485_wait_time*20); ++i)
{
if(!input(RS485_RX_PIN)) // always true because of bug in proteus model
i = 0;
else
delay_us(50);
if(clrwdt)
restart_wdt();
}
}
|
I have worked around with this in simulating in full duplex mode using two max487 at each side. |
|
|
|