I am trying design a circuit as the Tx line for several Pololu devices back to a microcontroller. To accommodate expansion in my project I want to be able to connect up to four slave devices back to a microcontroller. My understanding is that Pololu devices pull the Tx line high which means I will need to employ logic gates to allow all devices to share a common Rx input on the Master device. All slave devices will have its’ own device number so ther is no concern about overlapping transmissions.
The approach I am thinking about taking is using two NAND gates and an NOR gate. Any input not tied to a device would have to be tied high. The basic idea is sketched in the attached diagram.
I have a couple of questions.
Am I on the right path with this idea or is there a better way?
One concern I have is whether the gates can switch fast enough. Is that a legitimate concern or not something I need to worry about.
What else am I missing?
Obviously I am new at this so any advice is gladly accepted.
Your idea should work, but a simpler way is to use a series of AND gates or a quad-input AND. You can see some guidelines here.
It is a legitimate concern, but almost any logic gate should be far faster than what you need. You can check the speed in the datasheet to make sure that is substantially less than a single bit time.
- You probably know this, but make sure that you wait for the entire response to a command to be received before causing another device to send, or there will be a collision.
- If you are connecting to large numbers of devices, you might need to buffer your TX line (e.g. with one of those AND gates) depending on the speed and your microcontroller’s output characteristics.
- A device failure or an intentional reset could cause its TX line to float, which might confuse your microcontroller. If this could be an issue for you, consider adding pull-up resistors to bring of the device’s TX lines high.
- Be careful to follow the appropriate sequence of commands for baud rate detection if old (0x80) and new (0xAA) Pololu devices are on the same line, and consider going to a fixed baud rate if possible.
How many devices are you planning to connect, and what are you doing with them? We would be interested to hear about how it goes!
Thanks Jan for the advice. At the moment I have just two devices the TReX and the Micro Maestro (literally arrived while typing this). My goal is pretty open ended, build a robot to learn about electronics. You know, “Expand Your Mind”. I’m doing this with my kids. They came up with the requirements and name. It is called Fetch the WatenBot (play on our last name). The requirements are 1) wander automously around the floor; 2) Find and return an IR beacon (Fetch); and 3) Listen to voice commands.
Since I’m new to the game I am taking it one step at a time. I prototyped a simple differential drive robot from a BasicStamp, Ping sensor, and Pololu Low-Voltage Dual Serial Motor Controller. It was able to meet requirement #1 and am now ramping that up. I am building my next robot using the TReX as the motor driver, the Micro Maestro for my servo’s (Ping is on a servo turrent), and BasicStamp for controller. I will also be adding some additional sensors and am considerion using the Micro Maestro to act as ADC for the analog signal from the sensors. Once I get the scaled up version to run around without banging into anything I will start on the fetching part of the project.
My name is not Jan, but that sounds like a great project! A single AND gate should work for just two devices - but another possibility is that with the Basic Stamp you could just connect the two devices to two different I/O lines, right? Have you succeeded in establishing bidirectional communication with both devices independently? Are you planning to use the TReX’s R/C override features in your setup?
Sorry about that Paul. I have another thread going and lost track of who I was responding too.
I’ve been thinking about connecting them to separate I/O’s on the stamp. There were a couple of reasons I was considering the other approach.
- The BasicStamp can only read one I/O at a time.
- As projects grow I/O’s become precious.
- Pololu devices can share a line.
- I already know how to do it by connecting to separate I/O’s
- Greater learning experience figuring out how to daisy chain them.
With that said, if down the road I need to free up I/O’s I know it is possible.
I will be connecting my Spektrum DX7 to the TReX.
That is all true (especially the learning experience part) but you will still only be able to read from one device at a time if they are on the same line, and the commands will be longer. I do not want to talk you out of it - just want to make sure you understand the alternative!
Good luck and please keep us posted about how it goes!