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

Problem with RS485
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
karthickiw



Joined: 09 Aug 2007
Posts: 82
Location: TN, India

View user's profile Send private message Send e-mail

Problem with RS485
PostPosted: Tue Jun 28, 2011 9:24 am     Reply with quote

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

View user's profile Send private message Send e-mail

check circuit
PostPosted: Tue Jun 28, 2011 10:13 pm     Reply with quote

check my circuit connection is correct for ex_rs485.c program?
John P



Joined: 17 Sep 2003
Posts: 331

View user's profile Send private message

PostPosted: Wed Jun 29, 2011 6:42 am     Reply with quote

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

View user's profile Send private message Send e-mail

same problem
PostPosted: Wed Jun 29, 2011 7:16 am     Reply with quote

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();
         
     
   }
   
}

Crying or Very sad Crying or Very sad
karthickiw



Joined: 09 Aug 2007
Posts: 82
Location: TN, India

View user's profile Send private message Send e-mail

please help me friends
PostPosted: Thu Jun 30, 2011 12:34 am     Reply with quote

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

View user's profile Send private message Send e-mail

PCM Prgram
PostPosted: Fri Jul 01, 2011 10:02 pm     Reply with quote

PCM Programmer check this circuit is correct for ex_rs485.c program.. Crying or Very sad
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jul 01, 2011 10:23 pm     Reply with quote

I can test it and the code on Sunday.

What is your compiler version ?
karthickiw



Joined: 09 Aug 2007
Posts: 82
Location: TN, India

View user's profile Send private message Send e-mail

thanks PCM
PostPosted: Fri Jul 01, 2011 11:00 pm     Reply with quote

my compiler version

IDE,PCB,PCM,PCH,PCD - 4.104.

my circuit is correct?
temtronic



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

View user's profile Send private message

PostPosted: Sat Jul 02, 2011 5:12 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Jul 02, 2011 9:55 am     Reply with quote

You need to use Google a little more effectively...

A quick search using the term "rs485 resistors" found this National
Instruments web page about RS485 bias resistors:

http://www.ni.com/support/serial/resinfo.htm

Another place here:
https://secure.wikimedia.org/wikipedia/en/wiki/EIA-485

Read the info then fix your circuit.
_________________
Google and Forum Search are some of your best tools!!!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jul 04, 2011 5:28 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Jul 04, 2011 11:48 pm     Reply with quote

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

View user's profile Send private message Send e-mail

Thank you..
PostPosted: Tue Jul 12, 2011 5:52 am     Reply with quote

Thank CCS friends for helping. I got output. Ex_r485.c code is correct.

Thank you lot... Smile
xeta123



Joined: 20 Aug 2011
Posts: 3

View user's profile Send private message

Re: Thank you..
PostPosted: Sat Aug 20, 2011 3:51 am     Reply with quote

karthickiw wrote:
Thank CCS friends for helping. I got output. Ex_r485.c code is correct.

Thank you lot... Smile


Hey, facing the same problem here...What solved it?
xeta123



Joined: 20 Aug 2011
Posts: 3

View user's profile Send private message

Corrupt MAX487 Proteus Model
PostPosted: Mon Aug 22, 2011 3:42 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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