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

How to Establish RS-485 communication

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



Joined: 12 Aug 2010
Posts: 119

View user's profile Send private message

How to Establish RS-485 communication
PostPosted: Wed Nov 10, 2010 4:32 am     Reply with quote

hi,

I want to establish Rs-485 communication, I went through the modbus site and got some idea about it, moreover, I did go through the modbus example provided with the complier..however i did not understand much.

I need to send my analog values using 485. I need to make a slave and the master will be PC.

Please suggest something, wherein I can read more documents, understand the communication and proceed ahead.

Thanks,

Sid
temtronic



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

View user's profile Send private message

PostPosted: Wed Nov 10, 2010 6:18 am     Reply with quote

Sounds like your project is to have a PC get an analog reading from a PIC.
If so you certainly do not need MODBUS protocol for that program!

Start simple, program the PIC to 'echo' anything it receives back to the PC. Examples are in the compiler examples folder...
Big stumbling block will be the PC. Unless it has a real RS232 comport, you'll have to use a USB-RS232 interface or something else. Be sure to use a 'max232' chip with the PIC.
There are plenty of examples with the compiler for communications, you just have to start small and build upon what you learn.
Once you have the communications working, code and add the 'read the analog' segment to the communications segment. Again, examples are in the examples folder.
The more time and effort you spend reading, coding, testing, re-reading....etc. the better you'll understand these neat little PICs !
Sid2286



Joined: 12 Aug 2010
Posts: 119

View user's profile Send private message

PostPosted: Wed Nov 10, 2010 10:48 pm     Reply with quote

Thanks for the reply,

I have tried establishing communication successfully, however, I'm finding it difficult to implement modbus. I don't understand the holding registers, CRC etc. I would like to learn the basics of modbus, so please suggest to me something wherein I can understand the fundamentals of modbus.

thanks,
Sid
arunb



Joined: 08 Sep 2003
Posts: 492
Location: India

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

PostPosted: Wed Nov 10, 2010 10:58 pm     Reply with quote

If you have just one master and a slave in the network then you may not need RS 485, as RS 485 is meant for several slaves connected to a master(s).

Also if the distance between the PC and the slave is not much (say less than 5 feet), then RS 232 may be OK.

Search in google for RS 485/RS 232 projects there are numerous examples there, also search this forum.

For RS 485 you need an interface IC like the SN75176. On the PC side a RS232-RS485 converter is also required. A simple one can be made using a RS232 IC and the SN75176.

I suggest you start by reading up on the basics, its possible RS 232 may do the job for you, this will reduce the hardware components and complexity of the project.

thanks
a
Sid2286



Joined: 12 Aug 2010
Posts: 119

View user's profile Send private message

PostPosted: Thu Nov 11, 2010 5:08 am     Reply with quote

thanks for your reply,

Well i have a distance that is more than 15 feet and needs to connect my PC to multiple devices. the device is an analog receiver and i need to transmit them to PC via 485, Rs-232 is not possible in this case.

My PC will be master and my Device will be slave.

So i read quite a few forums and got a fair bit of idea about 485 communication and modbus protocol.

However, reading through the Modbus code provided with the examples with picc it was difficult to understand.

Do revert back if someone can suggest me where I can learn more about the communication and protocol.

Thanks,
Sid
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Nov 11, 2010 12:41 pm     Reply with quote

Use Google with the following search string. There's tons of stuff on
Modbus out there:
Quote:
modbus tutorial
jds-pic



Joined: 17 Sep 2003
Posts: 205

View user's profile Send private message

PostPosted: Thu Nov 11, 2010 3:09 pm     Reply with quote

Sid2286 wrote:
thanks for your reply,
Well i have a distance that is more than 15 feet and needs to connect my PC to multiple devices. the device is an analog receiver and i need to transmit them to PC via 485, Rs-232 is not possible in this case.
My PC will be master and my Device will be slave.

sid,

if you decide not to implement Modbus you can use a very simple PC-master polling protocol to handle querying multiple slave PICs hanging off of a 2 or 4 wire RS458 network.

see, for example,
http://losdos.dyndns.org/public/pic-uC/cbus-protocol-spec-draft-rev1.pdf
and
http://www.ccsinfo.com/forum/viewtopic.php?t=25980
and
http://www.ccsinfo.com/forum/viewtopic.php?t=33756

jds-pic
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