Posts: 2
Joined: Tue Sep 05, 2017 10:16 am

RS485 Pi to PC

Tue Sep 05, 2017 10:43 am

Hi all,
I'm a bit of newb to Pis but done plenty of stuff in the world of PCs (now a total Pi convert tho)

I'm trying to interface an RFID head to my Pi 3 using RS485 (with the AB electronics 485 board), didn't have too much luck (none); so decided to start with the basics and make sure I was getting sensible comms. I have a RS485-USB dongle on my PC (RS components 687-7837) connected to the pi board on about 12 inches of twisted pair, with the 120ohm resistor across the A-B lines as per instructions, its definitely needed as without it I get nothing.
The Pi is running latest Jessie and I've done all the stuff with turning off the console, swapping the ports about etc so my 485 is appearing on AMA0 (I assume it is all connecting OK as I am getting something out the other end -- bad assumption ?..)

I'm running python code (2.7) on the Pi to output 'x' on the UART :

import time

ser = serial.Serial(
port = '/dev/ttyAMA0',
baudrate = 4800,
parity = serial.PARITY_NONE,
stopbits = serial.STOPBITS_ONE,
bytesize = serial.EIGHTBITS,
timeout =1)

while True:

I'm using ComDebug on the windows PC to see what is coming in: ( and tried with putty and a visual studio c# app that i knocked up to try too)

All the baud rates etc match exactly.

I see 3 bytes coming in (HEX values) with each transmission from the Pi

But the bytes don't decode to the correct ascii.... its always the same data and I have played with every combination of baud/rts/xon/stop bits etc.

I've googled my heart out and I either don't understand the posts i find or I'm missing something somewhere.
Hope someone can point out the schoolboy error.....thanks for reading

Posts: 309
Joined: Fri Jan 01, 2016 10:27 pm

Re: RS485 Pi to PC

Mon Sep 18, 2017 2:20 am

I have done a lot of work with RS-485, and most of the problems can be traced to:
1) Bad timing on the “turnaround” line (transmit enable to receive enable).
2) Bad biasing, so the the idle state is floating, and the stop bit is never detected.

You really need to use a scope to see what is going on.

Posts: 2
Joined: Tue Sep 05, 2017 10:16 am

Re: RS485 Pi to PC

Mon Sep 18, 2017 6:04 pm

Thank you,
I'd got to similar conclusions - i.e. my signalling is wrong somewhere,
I'd read about biasing resistors but have no idea where to put them in my circuit...any advice gratefully received.
I'm looking at getting a scope, I was considering one of the USB PC based ones (Pico Scope) as I'm on a hobby budget and can't really justify the outlay for a bench top one, does anyone have thoughts/experience of them ? Don't want to waste cash on something that won't do the job..

Many thanks

Posts: 309
Joined: Fri Jan 01, 2016 10:27 pm

Re: RS485 Pi to PC

Tue Sep 19, 2017 4:43 am

It's unlikely to be a biasing problem, if your RS-485 converter is well designed, but it's possible.

Here is an article that talks about it:

http://blog.opto22.com/optoblog/rs-485- ... as-or-both

As for the scope - I don't have any experience with the pico scope, but I highly recommend Saleae: https://www.saleae.com

If you plan on doing more work like this in the future, it's a good investment. For this particular problem, maybe you can borrow a scope at a local school or "maker" shop.

Return to “Automation, sensing and robotics”

Who is online

Users browsing this forum: jdtsmith and 5 guests