I have a good background working with high voltage, which for me means over 10,000 volts, but I have many gaps when it comes to the lower voltage realm in which RC control boards and H-bridges live. When working on my first real robot, a BB-8 droid, I stumbled when designing a board to convert varying polarities from an RC receiver board into positive voltages only for an Arduino.

Today’s question is, how do you convert a negative voltage into a positive one?

In the end I came up with something that works, but I’m sure there’s a more elegant solution, and perhaps an obvious one to those more skilled in this low voltage realm. What follows is my journey to come up with this board. What I have works, but it still nibbles at my brain and I’d love to see the Hackaday community’s skill and experience applied to this simple yet perplexing design challenge.

The Problem

I have an RC receiver that I’ve taken from a toy truck. When it was in the truck, it controlled two DC motors: one for driving backwards and forwards, and the other for steering left and right. That means the motors are told to rotate either clockwise or counterclockwise as needed. To make a DC motor rotate in one direction you connect the two wires one way, and to make it rotate in the other direction you reverse the two wires, or you reverse the polarity. None of the output wires are common inside the RC receiver, something I discovered the hard way as you’ll see below.

I wasn’t using the RC receiver with the toy truck. I extracted it from the truck and was using it to control my BB-8 droid. My BB-8 droid has two motors configured as what in the BB-8 builders world is called a hamster drive, though is more widely known as a tank drive or differential drive (see the illustrations). Rotate both wheels in the same direction with respect to the droid and the droid moves in that direction. Reverse both wheels and it drives in the opposite direction. Make the wheels rotate in opposite directions and it turns on the spot.

The motors in my BB-8 are drill motors and are controlled by two H-bridge boards. An Arduino does pulse width modulation to the H-bridge boards for speed control, and controls which direction the motors should turn. Finally, the RC receiver is what tells the Arduino what to do. But a converter board, the subject of this article, is needed between the RC receiver and the Arduino. Note that the Arduino is necessary also for countering when the BB-8 droid wobbles and for synchronizing sounds with the movement, but those aren’t addressed here.

Since there are two motors and two directions for each motor, the RC receiver needs to control four pins on the Arduino to make the two drill motors behave as follows: motor 1/clockwise, motor 1/counterclockwise, motor 2/clockwise, motor 2/counterclockwise. And whatever voltages the receiver puts on those pins has to be relative to the Ardunio’s ground.

And herein lies the problem. The Arduino expects positive voltages with respect to its ground on all those pins. So I needed a way to map the RC receiver’s two sets of motor control wires, which can have either positive or negative voltages across them, to the Arduino pins which only want positive voltages. And remember, none of those RC receiver wires are common inside the receiver.

My Fumbling First Approach

Now, keep in mind, electronics is a general interest of mine and except for what we were taught in high school physics class, I’m self-taught. That means I’ve “read ahead” but much of my knowledge has been determined by what projects I’ve done. So I have gaps in my knowledge. I’d never turned negative voltages into positive before. It sounded simple enough. Searching online didn’t help though. The closest I got was in two old posts in forums where the answers were “It’s easy to do. I can do it with a single resistor.” But there was no further explanation and I didn’t ask my own question anywhere at that point.

Instead I came up with my own approach with just one set of wires from the RC receiver first. The wires coming from the receiver were blue and brown and could have either polarity depending on which way the receiver is being told to rotate the motor: clockwise or counterclockwise. That meant I needed two diodes to create two possible paths for the different polarities the brown wire could be: positive or negative. I then added a battery for the one path that was negative, to turn it into a positive.

Next, I put a PNP transistor between the positive of the battery and the receiver. With no signal from the RC transmitter, the transistor’s base is negative with respect to the emitter, but not enough to turn the transistor on. That’s because the battery’s negative is connected to the receiver’s blue wire and since there’s no signal from the transmitter, the brown wire is also at the same potential as the blue wire, and with battery negative.

The idea was that when the transmitter sent a signal to make that brown wire negative with respect to the blue wire, it would become even more negative and turn on the PNP transistor. A positive signal would then go from the battery, through the transistor to the Arduino.

The most obvious problem was that the Arduino wanted to see 3 volts to register as a HIGH input, meaning the battery would have to be at least 3 volts and so even with no signal from the transmitter, that would be -3 volts to the transistor, turning it on when it wasn’t supposed to be on.

And so I immediately thought of using a relay instead. I’d use the current running through the negative path to energize the relay, closing a switch that was completely independent of the RC receiver. The Arduino has a 5V output pin, so I made that switch close a circuit between the 5V pin and the Arduino’s pin 7, giving pin 7 the needed positive voltage.

The 1 in the circle in the schematic shows where I wanted to put a resistor in order to limit the current going through the relay’s coil. However, I tried with resistors all the way down to 4.7 ohms but the coil didn’t have enough current to close the switch. With no resistor, it worked and the current was 70mA. The relay’s coil was rated for 3V/120mA so I left it.

Using a relay did seem very heavy-handed, but it was the only solution I could come up with and I already had the relay in stock.

The next step was to add a second relay, doing the same for the second set of wires coming from the RC receiver for the second motor.

But the behavior was seemingly sporadic. And keep in mind that there was a whole dual H-bridge circuit that was also connected to the Arduino’s ground. I’d worked with relays a lot before, and the RC receiver came from a commercially made and functional toy so I had no reason to suspect that. On the other hand, I’d made the H-bridge circuit from scratch since I already had most of the parts, and I was new to H-bridges and MOSFETs. So at first I spent a good two weeks of spare time thinking my problem was with the H-bridge and drill motor side. I’m sure we’ve all experienced the same blindness, thinking the most likely culprit is the part you had a hand in.

But at some point I disconnected the H-bridge and tested just the RC receiver circuit, watching the voltages at the Arduino pins while I remotely turned on both “motors” in both directions in all combinations (no motors were connected at the time though). The only odd behavior I saw was when I turned the motors on in opposite directions.

Notice in the schematic that I’d connected together both blue wires coming from the RC receiver. Up to that point I’d been assuming that the blue wires were common inside the receiver and that it was only the brown wires that switched from positive to negative with respect to the blue wires. From the behavior I was seeing it looked like both wires were switching polarity, possibly around some other internal common reference.

So I added a third relay on one of the positive paths of one of the sets of wires. That meant the corresponding blue wire no longer needed to be grounded, keeping both of the receiver’s blue wires separate. Note that I didn’t bother putting in a fourth relay for the remaining positive path, and it turned out to not be necessary. At that point the circuits worked great and continue to do so.

And so I ask, is there a better way to convert the RC receiver output to something the Arduino can use? Relays require power, so it would be nice if there was a solution that didn’t require any extra power. My relay solution seems very early 1900s. Or maybe it’s a good solution after all, but just one of many. Let us know in the comments below.

EDIT:

I was asked in the comments for a high resolution photo of the RC receiver circuit board. It’s a little too big to embed (don’t want to slow down phone users) so here’s a link (warning: 5MB).

81 thoughts on “Ask Hackaday: How Do You Convert Negative Voltages To Positive?”

1. Mark Smith says:

Your diagrams are little more advanced than I’m used to, but I’m curious why you’re not just opting for a simple motor speed controller? Those of us who have built R2-D2’s and some have built BB-8’s just use dimension engineering ESC’s and most of what you’re talking about is handled.

1. Steven Dufresne says:

Mostly, I wasn’t familiar with ESCs when I started all this. But also, I have to go through the Arduino to sync up motor activity with sounds (e.g. when rotating on the spot it’s usually panning at the surrounding gawking kids and so I have it emit sounds when the rotation begins). The Arduino also does speed control to handle wobble when the droid stops. I’m new to ESCs but from what I read I didn’t see how they be used with an Arduino.

1. Mark Smith says:

For BB-8 this stuff is more or less already solved and open sourced by a guy that 3D printed 90+% of his build.. James Bruton / XRobots. Search it on youtube and you’ll find links to all his code.
For more simple/generic “tank”-like control (ie-R2, that doesn’t need inertial monitoring anywhere near as complex), look into the SHADOW and Padawan systems on astromech.net under the electronics subforum.

1. Steven Dufresne says:

Yup, James has done a nice job. There are also a few nice axle drive ones. One open source one of those is Ed Zarick’s http://www.edsjunk.net/wordpress/eds-bb-8-build-guide/. But making a BB-8 isn’t really what I wanted to do. I was more driven by the engineering challenge, so following someone else’s verbatim didn’t interest me, (Plus James and I started out around the same time. I just took a lot longer.)

2. N1JPL says:

To me it looks like the RC receiver already has two H-Bridges to control the motors of the toy truck. So I am not sure why you need to make things so complicated.

1. McErer says:

Because the goal is to transform a ‘normal’ drive into a differential drive.

2. wartoaster says:

On a Hackaday post: “I am not sure why you need to make things so complicated.”

Got me a good chuckle

3. FirmwareHacker says:

If it were me, I wouldn’t use the analog output of the receiver. All you really need is the RF deck in the Rx. You don’t need the decoder or the power train, so I would look for the raw pulse train from the RF deck to the decoder and send that to the Arduino and decode it there. This also let’s you do any kind of mixing, failsafe, etc, that you deem apropriate for your application.

I did something like that years ago in a cheap fixed wing r/c toy. It was using an Elan uC and I found a pin compatible AVR that I could just plug into the circuit and I wrote the decoder myself.
It all depends on how comfortable with low level firmware. I don’t know what the Arduino environment has, as I write in C and Assy for the AVR family.

1. Splud says:

I’m working on the broad assumption that the original receiver lacks any sort of balance or anti-wobble logic, and you may be using uprated motors (that the original receiver unit may not be able to drive reliably). Basically, you just want the inputs from it so you don’t have to build your own remote circuit. I’d start by checking whether the battery ground and any one of the outputs have the desired voltage when that output is driven – thing of the two wires for one as “left” and “right” and the other as “forward” and “reverse” when one of either pair is positive relative to battery ground. Don’t read the two pins together – just one pin to ground. If that’s good, you should be able to use it just by tying the receiver ground to the Arduino ground.

The next easiest approach would be to open up the RF receiver and isolate the two half-H bridges inside (backtracing from the output wiring) and tap into the INPUTS to those. Drive the receiver power ground common to your Arduino, and whichever H-bridge input is high defines the motor direction. This presupposes that the receiver unit can be opened up and isn’t potted or an ASIC (h-bridge integrated inside the receiver IC chip), but that isn’t the norm for cheap toys.

Also, in a reply below where there’s mention of the receiver running 5V and the Ardunino running 9V (7V minimum), if you bypass the regulator on the Arduino (i.e. don’t use the input power plug, but instead plug your regulated 5V into the GND and +V header pins), you could supply both the receiver and Arduino from the same supply. An added benefit is that your device would have ONE power switch.

Alternatively, so long as the receiver doesn’t use much power, you could power your Arduino via it’s current input, and power the receiver from the +5V and GND off of the Arduino headers (realize that most of the juice in the receiver battery configuration would have been intended for driving motors). Speaking of which, how are you providing power for your motors? Not directly off of the Arduino I/O pins I hope?

1. Steven Dufresne says:

The motors are being powered through a second H-bridge that the Arduino sends PWM to. That’s fed by drill batteries, one for each drill motor.
And your assumptions are correct. I need the Arduino for the anti-wobble logic since the BB-8 droid wobbles a lot when stopping, but also the starting of the motors is also a signal for the Arduino to play sounds.

4. McErer says:

I assume you’re using the same power supply for the receiver and the arduino? If so, use the common ground as a reference, and diodes / pull down resistors on each one of the ‘motor’ wires. The H-bridge won’t produce negative voltages when powered by a battery, it only commutes the direction of the current through the motor.

1. steelman says:

+1

2. Dolosus says:

Very much this. If the receiver and the Arduino can run on the same supply, it should be possible to read the H-bridge outputs with a pulldown resistor. If the receiver has its own H-bridges, it’s probably not outputting “negative voltage” it’s just swapping which motor output pin is VDD and GND.

3. So a bridge rectifier, in parallel, will do the trick.

4. markten says:

+1

Unless the receiver is doing some PWM on it’s own, the solution should really be this simple. The H-bridge either connects the output to GND or VDD. It isn’t creating “negative voltage” it’s just changing which end of the motor is connected to the same “positive voltage”. As long as both chips are using the same supply, a pulldown resistor and a digital read is all you need.

1. McErer says:

A small cap parallel to the resistor would take care of the PWM signal. Even better, 4 analog inputs of the Arduino could be used to read the PWM-equivalent analog value!

5. Steven Dufresne says:

Sadly, they’re on different supplies. The receiver’s using 5 volts and the Arduino’s on 9 volts (7 volt minimum).

1. Dax says:

You can still connect their grounds.

As long as the two power systems aren’t connected, the H-bridge output is floating and appears as an AC signal, and you can tie it to any voltage you want on the Arduino’s circuit. If you connect one of the H-bridge outputs to the Arduino’s ground, then you’ll get negative and positive voltages from the other output – however, all the other output channels then depend on the state of that channel.

If instead you tie the reciever’s power ground to the Arduino power ground, then all the H-bridge outputs simply toggle between 0…+5V relative to the Arduino.

1. Dax says:

Besides, since you’re only using the Arduino to control another H-bridge, what you actually need is to add a push-pull amplifier stage to each of the reciever’s output channels. You could add another H-bridge chips, but you can skip that and simply add a bunch of beefy FETs with proper current handling capacity to it.

http://reviseomatic.org/help/s-push-pull/MOSFET_Push_Pull_Amp.gif

GND is your reciever’s ground, and V+ is whatever you want it to be. If V+ is greater than the reciever output voltage, then you need a simple level shifter between the reciever and the push-pull buffer, because the input signal has to swing from GND to V+ in order to properly drive the FETs.

Possible caveats is that the reciever’s H-bridge doesn’t have sufficient dead time between switching, and/or your level shifter slows the FETs down so they both remain on during crossover and start to heat up. In that case you do need another H-bridge chip, but still you don’t need the Arduino because you can just treat the reciever output as logic level signals relative to the reciever power ground.

1. Dax says:

And you also need to add freewheeling diodes across the FETs so the inductive kickback from the motor doesn’t stress them too much.

This sort of simple buffer is suitable for voltages up to about 24 Volts. Beyond that, you can’t drive the FET gates from a common input because the gate-source voltage difference goes beyond the FET’s specs and they may get damaged. For higher voltages, you need separate high- and low-side drivers.

Here’s a circuit simulation of the CMOS inverter, which is what the buffer basically is

Notice that when you implement a level shifter with a pull-up resistor to V+ and a NPN transistor for a pull-down to GND, that is also an inverter, and when the signal is inverted again by the CMOS inverter, it comes out the right way.

2. jaydcarlson says:

This ^^^^ is more or less the correct answer, but it can be simplified a bit. Many “dumb” H-bridge chips are actually just dual half-bridges (basically what is presented here), and that’s precisely what you want, as it has the dead-time / bootstrap circuitry built-in. Your RC driver’s built-in H-bridge will produce 0-5V output voltages (since that’s what its power supply is, you say), so those can be fed directly into the half-bridge control inputs. Again, as others have noted, it’s all about a common ground; tie your grounds together.

3. Dax says:

The dual half-bridges often don’t have the crossover protection or current limiting options because they’re dual half-bridges and not full bridges – it is assumed that they may be operated independently as separate push-pull buffers, and so the state of one shouldn’t affect the state of the other.

2. Steven Dufresne says:

That’s looking like it might be the solution. Last night I did some further testing with my oscilloscope, it looks like treating the board’s battery negative as ground (it turns out it’s labelled as such on the board) in fact cause the output’s to all be positive with respect to that ground. So it looks like connecting it to the Arduino’s ground, and adding some current limiting resistors and pull down resistors are all that’s needed, unless I’m still missing something or run into another problem.
BTW The receiver isn’t doing PWM. There’s no speed control with this TX/RX. The transmitter looks like it would have speed control but it’s really just on/off switches.
I do need the Arduino though. It also uses the motors to counter the droid’s wobble when it stops and also plays sounds in certain instances when the motors are turned on (e.g. when the droid is made to rotate on the spot, as I make it do when there are children around gawking at it).

2. PreferLinux says:

The only reason the Arduino needs 7+ V is you’re powering it via the built-in voltage regulator, which provides the 5 V it actually runs off. You can power it directly by connecting your 5 V source to the 5 V pin instead of the Vin pin. It is perfectly safe, despite warnings on the Arduino pages, as long as your source is actually 5 V and you disconnect it when you plug it into your computer via USB (if you didn’t it would connect two different voltage sources, which isn’t a good idea).

3. Charlie strauss says:

I think optoisolatirs can neatly solve two problems here. One problem is the positive negative issue and the other is the voltage level conversion.

1. Dhawal says:

^^Exactly. I was thinking of ac optocouplers like pc814. Just connect bkue & brown wites to the led with 500/2=250E resistors and the optocoupler eill work both ways without worrying abiut ground & – v volt difference.

6. Armchair Expert says:

Exactly, unless the motors are PWM’d you would on have a combination of

0001
0010
0011
etc….

0 being ground or “-” or “battery negative” which is probably where the confusion is – it’s not really negative in respect to anything but the positive side of the battery….

1 being “positive” which again, for a battery powered, “floating”, circuit like an RC car is meaningless unless compared to battery negative.

I work in HV for a living and I’ve read a few of your articles and uh…. Yeah…..

5. Mike says:

Although you say there is no common pin on the receiver, there is presumably a power supply ground for it or batter negative? You could connect this to your Arduino ground and then you only need a diode and a series + pull down resistor on each side to the motor drive to convert to logic levels (positive = high, negative = low).

Alternatively you could connect two opto-couplers in anti-parallel across each motor output in a similar manner with Relays above (with current limiting resistors of course) and simply wire the outputs to the arduino with pull-up or pull down resistors as appropriate. Much smaller and lower power than relays

1. If you are just trying to read an on/off signal and not an analog signal, my first thought was to use optoisolators too. Low current draw and keeps complete isolation between the two circuit boards.

2. This, if the H-Bridge output of the Rx is PWM’ed (most likely). But then you need to convert that back via an appropriate sized resistor and capacitor if you are going into an analog input, or if you have a capture/compare peripheral available on the microcontroller you can sample the rising / falling edges and measure the number of ticks between them to get the value. using capture/compare is probably the lowest parts count, power usage, and cpu load.

3. Steven Dufresne says:

From testing last light with my oscilloscope, it looks like treating the board’s battery negative as ground (it turns out it’s labelled as such on the board) in fact cause the output’s to all be positive with respect to that ground. So it looks like connecting it to the Arduino’s ground, as many of you guys are suggesting, and adding some current limiting resistors and pull down resistors are all that’s needed.
BTW There’s no PWM from this receiver. The transmitter’s paddles look like they’d do speed control but they’re really just on/off switches inside.

6. You can shift voltage levels with op-amps; but really, the problem here isn’t that you want the negatives to be positive, its that there’s no common on the outputs. (that and you really want a tri-state input; HIGH, LOW, NULL)

I would give up on reading it with 1 pin per channel. I think near the end you groked that and thus the 3rd relay. I highly recommend the MIT OpenCourse on op-amps: https://ocw.mit.edu/courses/media-arts-and-sciences/mas-836-sensor-technologies-for-interactive-environments-spring-2011/readings/MITMAS_836S11_read02_bias.pdf What you probably want is to bias the op-amp and reduce the gain of the signal. The idea being that the op amp is biased to a neutral but halfway voltage like 2.5v. When the input is negative, it outputs 0v and when the input is positive, it outputs 5v. Really, you’ll probably end up reversing that because the circuits require one less passive to output 5v at a high input and 0v at a low input.

If you do try to bias the signal, I would recommend creating a voltage divider between the two lines (with very small resistor values) – that should be good enough for your case.

7. Stupotmcdoodle says:

As N1JPL said, it sounds like the signals you’re trying to convert are from H-bridges already. Granted they might not be juicy enough to drive drill motors. Depending on the construction of the receiver, you may be able to find the PWM signals between the actual radio receiver and the H-bridges on the receiver unit and tap those straight into the Arduino. Or even straight into your larger H-bridge. Got any close-up pics of the receiver circuit?

1. Steven Dufresne says:

I just opened it up for the first time and uploaded a hi-res pic here http://hackaday.com/wp-content/uploads/2016/11/rc_receiver_board1.jpg. There’s also an edit at the bottom of the article with the link. It’s a little too big to embed.
I’ll admit I can’t figure much out from it. From searching, it looks like the chip is the actual receiver. It looks like Y2 might be a FET and D2 could be a diode or an NPN transisor (BCW32), both from https://www.sos.sk/pdf/SMD_Catalog.pdf, but there is nothing in there for HY1D.

1. You can still find where its gate (if FET) or base (If bipolar transistor) is even without knowing what exact part it is. It’s the only pin not connected to either the motor or power/ground.

2. The HY1D looks like an NPN Transistor MMBT8050 1.5A rated.
The Y2 looks like a PNP transistor SS8550 also 1.5A rated.
They are on the L/R H bridge, I’d have expected the F/R bridge to have a slightly higher spec, so it’s odd to see more Y2s.

3. imqqmi says:

I’d abandon trying to get a good mcu power supply out of motor steering pwm signals, this is bound to be instable and error prone. Just use a 7805 or similar linear voltage regulator connected to the battery, or a buck/boost converter for the 5V supply directly off the battery. You don’t need to make positive into a negative supply :)

If you look at the board, all the components have a label, the DP+, Y2 and L7 components are transistors, having a label of ‘Q’. The number is just a counter counting up, each component has a unique number per component type. R for resistor, D for diode, Q for transistor, C for capacitor, L for inductor, Y or X for crystals/oscillators etc.

You can see 4 transistors or mosfets per output, so full H bridges. Those bridges are in turn controlled with the smaller transistors L7 because the R288-2 chip can’t output a strong enough signal to overcome the MOSFET gate capacitance (in case of MOSFET) or current (in case of bipolar transistor). If you want to replicate this yourself (with higher current capability of course), make sure you research how to properly control a MOSFET from an arduino. Especially with PWM signals of above 1khz the capacitance is going to matter.
Don’t be fooled by the small size components, when properly designed, they can control huge currents without getting hot!

My guess is that these transistors gates or bases are connected directly to the Bright R288-2 chip. You can use a multimeter continuity check mode to see which pins that is. If not, there’s likely to be a resistor in between. Resistors R12..R15 seem to be such resistors connected to the R288-2 chip, the other end of the resistors are going to the L7 transistors. Those are the signals you’re looking for.

If you have a scope you can easily identify the signals and voltage levels, hook the scope ground to the battery ground (labeled GND). Put the probe onto the smaller transistor pins and see what it reads, then probe the pins of the IC1 (R288-2) and see if you can find the same signals.

The signal isn’t likely to be a higher voltage than the battery, so take care if you need to level shift it for the arduino. Connect the GND of the arduino to the battery GND, solder leads from the L7 transistors and use a voltage divider to lower the voltage if necessary, use an online calculator to get good values. If it’s between 0V-0.6V (logic low) to 3-5.5V (logic high) the arduino should be able to handle them.

Having said that, you are making it hard for yourself to use the toys electronics, there are ready made modules for RC stuff that you can just drop in, wire etc to arduino, motors etc. I’m no expert in RC though so I can’t suggest any modules but I’m sure there are plenty people here who can chime in.

1. Steven Dufresne says:

Thanks for that help reading the board, guys, and detailed tips for tracing it, imqqmi. Funny, I was looking so hard for component part numbers that I didn’t even look at the writing on the board itself, except for the capacitors. Somehow I did look at that writing.
Re using a toy RC instead of an off-the-shelf one, I didn’t realize the price would be comparable at the time. But for the motors etc, there was still a cost issue, at least when you add it all up. The way I went, one drill motor cost me \$10 and the other \$0. My dual H-bridge cost me the price of the MOSFETs since I had everything else. I also learned much more than I would have had I gone off-the-shelf. This was my first time working with MOSFETs and it was worth that alone. Plus there was the experience of designing this board, even if it was overkill, and debugging the whole thing.

1. imqqmi says:

I understand your reasoning, and that’s how I learn too :) I commend you for out of the box thinking and learning ways to do things.
I too set myself the challenge to only use what I have and try to keep cost low, but sometimes if you want to get something done it’s better to invest in off the shelf modules that are known to work. You can always take them apart and learn how they work.

I’ve been trying to find out how to use a graphics display I salvaged from a Lexmark color laser printer, a 128×64 pixel dot matrix. I’ve learned about jtag to try dumping the custom lexmark controller by building a custom buspirate. I had to learn using linux to use openocd. In the end it failed to connect though. It also has an i2c port, I made a i2c address scanner to find out which addressess it uses. Unfortunately I couldn’t figure out the protocol but I can reset the display using i2c.
The last thing to try is making a logic analyzer to capture the reset signals sent via 14 data signals and try to figure out what protocol and registers the lcd has to write to the display using my own controller. Fingers crossed hoping the lcd module has survived my poking around :)

4. mickelangelo says:

The receiver SMD pinout is described briefly at http://dduino.blogspot.se/2012/02/control-rc-car-transmitter-with-arduino.html if you want to skip converting negative to positive.

If you however want to split the positive and negative part of the signals out to two positive pins, there appears to be a trivial way to do it, but it looks so damn weird that I’ll have to breadboard it up tomorrow to verify that it actually works.
I’ll be back :)

8. You can do it with two opto-couplers, and 3 resistors.

Wire the LEDs in anti-parallel. This will go to you H-bridge with a suitable current limiting resistor.
Then wire the transistors in a totem-pole, with the other two 1K resistors in parallel with each collector and emitter pair. Connect the top of the totem-pole to your micro’s power supply, and the other end to your micro’s ground.

The resistor divider sets the output voltage to the midpoint of your micro’s supply.
Then the PWM signal from the H-bridge will drive one one or the other transistor depending on direction.

Thus full forward would be you micro’s VCC, and full reverse would be GND.

1. Oh Thank GOD I found this comment. I was about to go crazy. 2 opto-couplers was my first thought about 2 seconds into reading the problem.

However after seeing all the crazy designs and complicated solutions I was starting to wonder if I was insane to think of this, glad somebody else mentioned it.

Or, Just buy a proper multi channel TX/RX pair from eBay for \$40. SO MUCH EASIER. You would get better information too.

Why is nobody else suggesting the obvious choices?

2. Brett says:

I would have used 4 opto-couplers and 2 current limiting resistors.

For each motor (Fwd/Rev (F/R) and Left/Right (L/R) ), connect two optocoupler LEDs anti-parallel as described previously. Connect the LEDs through a current limit resistor in place of one of the motors.

On the opto output side, you have a pair of outputs – reference these to the MCU’s ground, and connect both outputs to the MCU. For each motor, only one of these outputs will be active, depending on the direction the motor was being driven. From this, you can recover motor direction and PWM using code.

Software polling of the 4 optocoupler outputs would be… intense. You would do well to find a way to capture pulse edge timing using peripherals in the MCU (input capture timing). This may require mixing the opto outputs in a way that that allows all four signals to send their pulses to a single pin for edge time capture.

Alternatives: You might probe the receiver board to try to find the output of the receiver, and decode the 1 receiver output rather than 4 motor outputs.

Or you might go back to the start of the R/C chain – back at the transmitter. Use an MCU to remix the joystick signals before they are transmitted to get the desired action from an unmodified receiver. The problem with this is that the F/R output of the receiver is likely much more capable than the L/R outputs. L/R may not be able to drive the same size motor as F/R. You might replace both existing H-bridges with your own (same as you’ve been planning). You’ll have to reverse engineer the receiver motor outputs.

After a while, using regular R/C controls begin to look attractive from a development effort viewpoint…. You can trade \$\$\$ for development time/effort. Especially if you plan on adding more functions later. But where’s the fun in that?

1. BrightBlueJim says:

Polling four inputs is not at all “intense”. You set a timer, you look at the state of each pin when the timer goes off. It doesn’t get any simpler.

9. John says:

The way I did this in a different project was with two resistors, form a 2:1 voltage divider towards the positive rail of the reciever with one of the two outputs. I’m assuming that the drivers arent isolated from the reciever supply (that would increase cost for no real reason), so that *should* just solve it with two resistors, assuming the RC reciever is 5v. If it’s higher, then you’ll need to add a third resistor to ground.
So, one resistor from a wire (either brown or blue), to another equal resistor, to the positive supply for the RC reciever, and a third from the connection between those two, to ground.

10. ViciousInstitute says:

Maybe opto isolators set up so that the internal LEDs are back to back, so when the polarity changes it changes which opto is on. Then the transistor sides connect to the arduino pins. Same basic idea as with the relays, just not as power hungry.

11. nsayer says:

It seems to me like opto-isolators would do the trick. Use four of them with the LEDs of two of them on each RC receiver wired anode-to-cathode with a common series resistor. One, the other, or neither will light up at any given time. The forward conduction of one will protect the other from excessive reverse bias. The secondary side – the phototransistors – can be wired as simple open collector outputs. The arduino pins can be configured with internal pull-ups. Done deal.

12. Brenden says:

Wouldn’t using a bridge rectifier turn a negative voltage to a positive one?

1. it would. (Minus a diode drop) However, it will turn the positive voltage into a (still) positive voltage, so you can’t discriminate between a “forward” or “backward” signal any more… Just a “motor is running”.

13. It’s a bit rough, but I listen on analog in for low or high, pipe that to serial to figure out what’s going on [no scope ], then code around it

14. SAABMAN says:

If you swant to use the H bridge output the signal on each pin will still be positive relative to the RXVR power supply negative, +ve for one direction and 0V for the other on one pin and the opposite for the other pin. This will use 2 pins on the Arduino to read + – forward – + backwards ++ stop — stop.

A resistive divider may be necessary to reduce the voltage to the input level required by the Arduino but a lot simpler than relays/optocouplers/transistors

15. Armchair Expert says:

Ebay has ESC’s with reverse for brushed motors all day long. If you can make beeps and bloops with an arduino, you can control a couple of RC ESC’s easy. about 1000 to 2000 uS of PWM with 1500uS being dead center. You could not only have drive, but proportional drive. Ramp up, ramp down, less jerky moving robots…

This is why I abhor the ardunio people, always kind of wanting super complex circuits and robots and things, yet don’t want to do any real work. “Just give me a library!” they say… ugh.

I digress

This I would argue is getting back to the roots of hacking! Making it go with an OTS wally world RC car. Reminds me of when I was 10 or so… Probably more fun than OTS parts anyway.

16. Erich Eminhizer says:

Hey dude, I’m a total noob on RC, but I stumbled across this and started thinking about it. Apologies if I’m completely off the mark.

Isn’t there a PWR/GND associated with the RC receivers? Wouldn’t you tie the GND to the Arduino GND rather than one pole of the drive wires? Then you would need two input pins on the Arduino, and I would use diodes in series on each drive wires into the input pins. If the drive wires produce +5V/-5V one way and -5V/+5V the other, put 3 diodes in series to drop the voltage closer to 3V (cathode towards the Arduino). The diodes will block the negative voltage from the Arduino.

If it’s really a floating voltage, which seems weird to me, you may be able to connect a large-ish resistor from each drive wire to Arduino GND. This would reference each drive wire to 0V, and I would use the same diode approach as above.

Now I will look forward to being completely wrong and hopefully will learn something! :)

17. If the voltage is actually negative, and not just swapping ground and power, couldn’t you just put a voltage source greater than the max negative voltage in series to bring the voltage positive, and then use a couple of resistors to divide down to the level you need for the Arduino?

18. Tom Ø. says:

On a similar chip I used the output directly from the chips pins ignoring the H-bridge on the board. Found a datasheet for that chip, but You can probably just look at det circuit board traces through the H-bridges.

19. (written in “recipe style”, I don’t mean to sound “bossy”)
Tap into the signal going from the RC car’s control chip to its H-Bridge. (Q5,6,7,8, and 11,12,13,14 for a H bridge, each.). Feed those signals to your arduino, if they go above 5V use a series resistor (+ zener if you don’t want to misuse the input protection diodes), say 10k to 100k, or a voltage divider. If they are PWM-ed wire them to a analog input and use a RC filter (try series 10k+100n to ground, check with oscilloscope and increase either part in value untill you get a smooth DC voltage).

And indeed, connect GND from receiver to arduino GND.

To me, that sounds much easy-er then using a stack of relays somehow.

20. backemf says:

Why is this on hackaday? To me this seems more like a question that you would want to post in an electronics forum.
Not a hack!

1. V says:

I thought I would never become one of those “not a hack” guys but sadly I have to agree with you…
That huge article is just an ordinary question that belongs to an electronics forum. Nothing new or interesting to learn from.

21. Travis K says:

Make the rc cars “ground” = to 3volts. Then 8v for the 5v rail. And connect a high resistance between the output and ardueno 100k to 1m ohmish.

The avr has a robust diode clamping on the pin ad can take the high voltage. Heck theres even an app note about feeding in 120v ac via the same setup.

1. Travis K says:

Then
3.3v = off
5v = forward
0v = Reverse

22. Marcus says:

If you really want to use the existing receiver, use two optocoupers per output (4 total). If you have one biased forward and one biased backwards they will give you discrete digital outputs you can send to the arduino, or you can even filter them to give analog levels.

That said, I think a better option is to get a standard off the shelf RC receiver (with no h bridge) and use the PWM outputs from its servo / esc channels. The arduino can then measure pulse length – above some threshold (eg 1.5ms) is forward, below is reverse. Standard receivers and transmitters are cheap, under \$30 – eg https://hobbyking.com/en_us/hobby-king-2-4ghz-4ch-tx-rx-v2-mode-1.html

You can usually modify the gymbals add/remove springs or detents.

23. Jesse Vallaro says:

Can’t you just connect the line that will go to -5V to the input pin. Enable the Internal pullup resistor and then do a digital read detecting for LOW?

24. Martin says:

Not going through all the comments first, I think it is easy.
Because: You do NOT have negative voltages. At least if you refer them to the right potential, the negative pole of the battery. Then you can look at each half bridge voltage of your two full bridges independent.
So as a general recipe:
I would connect a voltage divider to each half bridge output, which gives me a convenient mid point voltage.
From here on it depends on your battery voltage which supplies the motor outputs . For each half bridge you have to distinguish 3 states: Low, Off (mid voltage) and High. You can do this with comparators or voltage dividers to the inputs

For quite low voltages you can also use transistors (with base resistors) or small MOSFETs:
Connect the E (or S) to one output and the base resistor (or G) to the corresponding other half bridge output. Connect a pull up resistor from the C (or D) to the microcontroller supply (5V/3V3). And connect a second one the other way round on the same motor channel, so the E is at the connection of teh base resistor of the first transistor and the base resitor of the second is at the E of the first.

The second transistor gets a similar pull up. Now you have two direction signals.

You do the same for the other motor channel.

1. Unferium says:

+1
It is essentially forward= A*!B, Backward=!A*B and nothing= Az*Bz
Where z=at high impedance.

For speed control if the RC board supports it, I’d use an opamp for the forwards backwards biased half way into one analog pin and the another half biased opamp from the steering servo controller.
Less than bias on the drive should be programmed to produce a negative int and vice versa.

The steering should bring either motor to zero when programatically biased halfway between the zero bias and the negative/positive of both wheels. that way one side could be full tilt but the other side can be commanded to slow down or go backwards depending on how hard the stick is pushed to the sides.

“Hope dat smokes some sense”

1. Unferium says:

I meant (referring to) the H-Bridge under the “+1”
Sorry.

25. BrightBlueJim says:

Look: you are not trying to turn a negative voltage into a positive. You are trying to connect the correct wires to ground. You have two H-bridges driving four wires. That means that zero, one, or two of the wires can be connected to the receiver’s positive rail, and zero, one, or two of the wires can be connected to the negative rail. Assuming the receiver uses a negative ground topology, the negative rail is the receiver’s “ground”.

Connecting all four wires through diodes (cathode to each drive wire) will establish a “virtual negative rail” that is one diode drop above the most-negative of the four driven wires, which you can connect to the Arduino ground. These diodes essentially connect the correct wires to ground.

Then all four wires will be zero or positive with respect to this virtual negative rail. The drive wires are then also connected (through voltage dividers if the receiver puts out too high a voltage) to four digital pins on your Arduino. For each motor, you will get two logic low levels when the motor is undriven, and one and only one logic high, indicating the direction, when the motor is being driven.

Oh: and to handle the case of neither motor being driven, which would make your “virtual negative rail” float, just connect weak pull-down resistors (~ 1K to 10k) on each of the four driven wires to the Arduino ground.

1. BrightBlueJim says:

Steven: After going back and actually reading some of the other suggestions and your responses, I realize it’s much simpler than this – no diodes required. I was under the impression from the article that you didn’t have access to the circuit board, just the motors. Just connect the negative side of the battery to your Arduino ground. H-bridges don’t create negative voltages; as I said above, it just connects one of the outputs to ground and the other to the + rail. So measure each of the motor wires with respect to the negative side of the battery (ground), and you should see only positive voltages.

One other thing, though: You say you are assuming the receiver is good because it came out of a working toy. But then at one point you say that you connected the blue wires for the two motors together. This was a very bad thing to do because as soon as the receiver tried to turn the motors in opposite directions, it connected one of those wires (through a MOSFET) to ground, and the other to the positive rail. So by now your receiver may be toast.

1. Steven Dufresne says:

From testing I did last night with my oscilloscope, it looks like treating the board’s battery negative as ground (it turns out it’s labelled as such on the board) in fact cause the output’s to all be positive with respect to that ground. So it looks like connecting it to the Arduino’s ground, and adding some current limiting resistors and pull down resistors are all that’s needed. That’ll take a little longer to implement.
But the receiver isn’t toast, luckily. It’s actually part of a fully functional BB-8 droid with my overkill converter board in use (soon to be replaced with something simpler thanks to all these comments).

26. John Dragt says:

My first thought was optocouplers too, but you only need two of them. There’s no need to optocouple the positive-going signals They can be wired as per your first attempt positive path).
For the negative path, Optocoupler LED inputs can switch transistor outputs for direct connection into your inputs.

A further thought: When the receiver switches a motor in one direction, what voltages do you get between the blue wire and the RC receiver battery negative? I’m guessing that in one direction, the blue wire will be positive compared to receiver battery negative, and in the other direction, the brown wire will be positive.
If so, connect the arduino GND to battery negative of the receiver, and the 2 inputs (via appropriate diodes/resistors) to the respective arduino inputs……

27. Saabman says:

I’d love to see a follow up to this to see what solution you implement.

28. Guille says:

I’m amazed nobody’s mentioned MAX232/ST3232/etc. They are natural plus/minus/logical level shifters. Or perhaps I misunderstood the problem?

29. CityZen says:

As an RC guy, I’d say your problem was starting with the toy truck RC gear instead of just getting some standard, documented RC gear to work with. Regular RC gear comes in various flavors, but the standard outputs are one of:
1) multiple PWM channels (old school)
2) combined PPM signal (middle ground)
3) serial (new age)
There are, of course, various other possibilities as well.

Supposing you want to go with what’s relatively cheap, you can get a FlySky Gt3b tx/rx kit for a little over \$30. It provides multiple PWM outputs. I understand that \$30 is a lot more than what’s free (the toy truck), but sometimes the time saved over having to futz around can be worth it. Of course, if you enjoy the futzing around, then who’s to say?

30. threepointone says:

When the grounds aren’t the way you want, optoisolators usually do the trick, while providing commonly necessary electrical isolation in this sort of application. You can do a lot of tricks on motor outputs. For example, you can use two optoisolators, with one LED reversed, to provide three different possible signals – one of the opto outputs on (high or low, depending on how you connect a pullup or pulldown) indicates that it’s reverse; the other on indicates forward; and both off indicate that the motor is completely off.

If you don’t have any optoisolators hanging around and insist on doing it in a wired fashion, you’re thinking about the problem in a bit of an unproductive manner. The RC circuitry was probably designed in a single ended manner; that is, there’s a single positive power supply, and a ground that sits at the lowest voltage. If you get access to that ground, those two wires turn into simple “digital” outputs that are always at 0 or the positive supply.

Alternatively, if you can’t pull out the ground, two diodes on each of the motor output wires (one from ground to motor wire – negative side pointing towards motor wire, and a second diode from the motor wire to an appropriate voltage digital I/O with pulldown resistor) will do the job.

But really, if you understand all of that, you may as well pull out the raw I/O line from the wireless controller IC. There’ll be two outputs for the h-bridge, one I/O output for each half of the bridge. This should more or less give you all the possible states (forward, reverse, and motor off) quite easily. Maybe there will be some level conversion, and that’s it.

31. Gabriel says:

Soooo a simple rectifier wont work? Blue and brown of either “polarity” on one side and same polarity DC Out the other…..

32. Kelly Gray says:

Here’s a circuit that should do what you want.
http://imgur.com/a/dTJIN
the RC driver outputs are fed to the input LEDs of optocouplers. Two optocouplers are connected with the input diodes in parallel, but opposite polarity. If there is any motor drive voltage, one or the other LED will be on, as will the associated output transistor.
The Arduino will see both inputs of the pair high if there’s no motor power, and one of them low if there is a motor signal. Which one is low will depend on the motor direction.
Since the optocouplers have no electrical connection between the input and the output, there is no need for a common ground reference between them.

1. Steven Dufresne says:

Thanks! Not sure which route I’ll go yet, might even try multiple for fun, but this certainly makes it easier.

1. BrightBlueJim says:

No. That simple circuit is called a bridge rectifier. It is used to convert AC to DC. Yes, you could feed it DC, but unless the grounds on the input and output were isolated from each other, it wouldn’t work. Try simulating that, and you’ll quickly discover that you’ve connected the input power to ground through a diode.

This site uses Akismet to reduce spam. Learn how your comment data is processed.