Teensy 3.1, help on moving from I2c to RS-485/Modbus?

Status
Not open for further replies.

sansbury

New member
Hello,

I'm working on a project for an open-source modular robotic joint that could be used to build different kinematic configurations like PUMA, SCARA, or pretty much anything composed of angular joints. This project log on Hackaday.io is a little behind the current state but gives some general sense of what I'm up to.

The approach I'm following uses an individual controller for each joint. The idea is that you can daisy chain as many joints together as you need, and then have one master unit which calculates what each joint should do and talks to them via a serial bus. The idea here is that the joints are very modular, and all the application-specific logic can be implemented on the master.

Currently, I have one Arduino Uno serving as a master and a pair of Teensy 3.1s as slave joint controllers attempting to communicate via I2C using the Wire library, and I'm having problems that appear to be due to wire lengths. Basically if I unplug one, comms work fine, if I plug it back in to the breadboard, the whole thing gets unstable. I haven't tried futzing with wire lengths because I've got a total of maybe 15"/30cm of wire now and the real application will require 2-3x as much.

Rather than trying to make I2C work I am thinking about switching to RS-485 seeing as it seems to have been designed for precisely this kind of thing. My own experience is very Arduino-centric so I'm not quite sure where to start with this. I've been googling around for a sort of hello-world example of getting two boards talking via RS-485 but haven't found one just yet.

Any pointers would be greatly appreciated!
 
Two suggestions:

1) Use the Serial1/2/3.transmitterEnable option that Paul has enabled for RS485 communications. That way, the RS485 TX pin is held high for only the duration of the transmission and you don't have to twiddle the thumbs of the MCU until the serial buffer is empty. It's automagical.

2) Easytransfer makes it easy to send well defined datagrams. You tell the master and the slave what to expect, they handle the rest. No CRC, etc. Radiohead makes it easy to send less-well-defined ones, offers CRC, and so on, but takes more to master.
 
Status
Not open for further replies.
Back
Top