hamza
Posts: 76
Joined: Fri Apr 03, 2015 7:16 pm

rs485

Thu May 21, 2015 11:42 pm

hi

how can I configure the rpi pins (Tx,RX) gpio14,gpio 15 to RS-485???is there supported library??

danjperron
Posts: 3502
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: rs485

Fri May 22, 2015 12:36 am

For Rs-485 you need an external pin to indicate the direction of signal and the internal ttl serial only have rx and tx.

Because USB to RS-485 adapter is so cheap you should consider it!

I did post some try out with different adapters type.

viewtopic.php?p=563861#p563861

At the beginning of that post you will get a document about a water detect module. In the document I use a small PIC cpu to switch the direction of the rs-485 driver.

There is some adapter on the market that switch the direction when the transmit signal go TTL low (SPACE) but that method doesn't work well since there is no output when transmit TTL HIGH (MARK). So I use a small cpu to detect a transmission and switch to receive when the TTL stay high for ~2 character long.



Daniel

Skidmark
Posts: 20
Joined: Sat May 23, 2015 10:46 pm
Location: Tulsa. Oklahoma

Re: rs485

Wed May 27, 2015 4:29 pm

Your post on the RS-485 seems to come the closest to what I'm looking for so I have a few questions for you. The "cheeper" adapter/converter you are referring to. Exactly which converter is that. Can you be exact please. Also do you have any 'C' or 'C++' code for connecting to the converter?

I'm a seasoned Windows developer, but not Linux and need some start up help. If I can just get started with getting a RS-485 converter installed on the Pi and some basic code help I can run with from there I think.

Thanks much.

Al

danjperron
Posts: 3502
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: rs485

Wed May 27, 2015 7:18 pm

This is the one I use.
http://www.dx.com/p/usb-to-rs485-adapte ... een-296620

And that one work fine.
http://www.dx.com/p/usb-to-rs485-module-black-221402

P.S. They are not isolated. so the ground have to be the same.

I do have some code in github.

https://github.com/danjperron/PIC_MULTI_10_IO

Skidmark
Posts: 20
Joined: Sat May 23, 2015 10:46 pm
Location: Tulsa. Oklahoma

Re: rs485

Fri May 29, 2015 2:54 pm

I've downloaded your code and will look at it. The code title implies PIC (very familiar with PIC products) but I'm only interested in the RBP code that communicates with the 485 converter. Which module has the RBP code that opens the 485 converter port and communicates with it?

Thanks Al

danjperron
Posts: 3502
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: rs485

Fri May 29, 2015 3:22 pm

You will find C code for the Raspberry Pi in configPIC.c
And python code for webiopi in Webrelais.py and PicModule.py. The last one is the class to access the module.

I do have a document in google drive.

https://docs.google.com/document/d/1lXs ... sp=sharing

Traducted from my french version
https://docs.google.com/document/d/1JIR ... sp=sharing

Skidmark
Posts: 20
Joined: Sat May 23, 2015 10:46 pm
Location: Tulsa. Oklahoma

Re: rs485

Tue Jun 16, 2015 5:43 pm

I received my USB RS-485 converter and hope to get busy coding as soon as I can. Does the RBP already have the driver included or do I need to download it form somewhere? If so where.

Does you code show how to turn the line around to transmit?

Thanks once more.

Al

danjperron
Posts: 3502
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: rs485

Tue Jun 16, 2015 6:36 pm

When the usb dongle will be connected to the Raspberry Pi, it will be recognized.

something like /dev/ttyUSB0


I used minimal modbus but I thing it is automatic. There is no need to set the direction of the signal.

Return to “Beginners”