Posts | Comments

Planet Arduino

Archive for the ‘Ask Hackaday’ Category

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

RC toy truck and circuit with no common
RC toy truck and circuit with no common

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.

BB-8 hamster type cutaway showing wheels, motors and casters and how it moves BB-8 hamster type cutaway showing how it turn by rotating the wheels in opposite directions

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 big picture - RC to drill motors
The big picture – RC to drill motors

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.

Using a transistor
Using a transistor

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.

Using A Relay Instead

Using a relay
Using a relay

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.

No Common In The Receiver

Schematic with common blue RC wires
Schematic with common blue RC wires

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.

Finished RC-to-Arduino converter schematic
Finished RC-to-Arduino converter schematic

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.

The Ask

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.


Filed under: Arduino Hacks, Ask Hackaday

Speak with those who consider themselves hardcore engineers and you might hear “Arduinos are for noobs” or some other similar nonsense. These naysayers see the platform as a simplified, overpriced, and over-hyped tool that lets you blink a few LEDs or maybe even read a sensor or two. They might say that Arduino is great for high school projects and EE wannabes tinkering in their garage, but REAL engineering is done with ARM, x86 or PICs. Guess what? There are Arduino compatible boards built around all three of those architectures. Below you can see but three examples in the DUE, Galileo, and Fubarino SD boards.

Arduino DUE uses Atmel ARM Arduino Galileo uses Intel x86 Fubarino SD uses PIC32

This attitude towards Arduino exists mainly out of ignorance. So let’s break down a few myths and preconceived biases that might still be lurking amongst some EEs and then talk about Arduino’s ability to move past the makers.

Arduino is NOT the Uno

When some hear “Arduino”, they think of that little blue board that you can plug a 9v battery into and start making stuff. While this is technically true, there’s a lot more to it than that.

  1. An Arduino Uno is justanAVR development board.AVRs are similar to PICs. When someones says “I used a PIC as the main processor”, does that mean they stuck the entire PIC development board into their project? Of course not. It’s the same with Arduino (in most cases), and design is done the same way as with any other microcontroller –
    • Use the development board to make, create and debug.
    • When ready, move the processor to your dedicated board.
  2. What makes an Arduino an “Arduino” and not justan AVR but the bootloader. Thus:
    • An Atmega328P is an AVR processor.
    • An Atmega328P with the Arduino bootloader is an Arduino.
  3. The bootloader allows you to program the AVR with the Arduino IDE. If you remove the bootloader from the AVR, you now have an AVR development board that can be programmed with AVR Studio using your preferred language.

There Is No Special Arduino Language

Arduino "blink" sketch should run on any Arduino compatible board.
Arduino “blink” sketch should run on any Arduino compatible board.

Yes, I know they call them sketches, which is silly. But the fact is it’s just c++. The same c++ you’d use to program your PIC. The bootloader allows the IDE to call functions, making it easy to code and giving Arduino its reputation of being easy to work with. But don’t let the “easy” fool you. They’re real c/c++ functions that get passed to a real c/c++ compiler. In fact, any c/c++ construct will work in the Arduino IDE. With that said – if there is any negative attribute to Arduino, it is the IDE. It’s simple and there is no debugger.

The strength comes in the standardization of the platform. You can adapt the Arduino standard to a board you have made and that adaptation should allow the myriad of libraries for Arduino to work with your new piece of hardware. This is a powerful benefit of the ecosystem. At the same time, this easy of getting things up and running has resulted in a lot of the negative associations discussed previously.

So there you have it. Arduino is no different from any other microcontroller, and is fully capable of being used in consumer products along side PICs, ARMs etc. To say otherwise is foolish.

What is the Virtue of Arduino in Consumer Products?

This is Ask Hackaday so you know there’s a question in the works. What is the virtue of Arduino in consumer products? Most electronics these days have a Device Firmware Upgrade (DFU) mode that allows the end user to upgrade the code, so Arduino doesn’t have a leg up there. One might argue that using Arduino means the code is Open Source and therefore ripe for community improvements but closed-source binaries can still be distributed for the platform. Yet there are many products out there that have managed to unlock the “community multiplier” that comes from releasing the code and inviting improvements.

What do you think the benefits of building consumer goods around Arduino are, what will the future look like, and how will we get there? Leave your thoughts below!


Filed under: Arduino Hacks, Ask Hackaday, Hackaday Columns, rants
Mar
09

Ask Hackaday: Wiping Your Bum With An Arduino?

arduino hacks, Ask Hackaday, toilet paper, toilet paper alarm Comments Off on Ask Hackaday: Wiping Your Bum With An Arduino? 

TP

Over or under? Standing or sitting? Truly, toilet paper has been the focus of the most irreconcilable arguments ever. The folks on the Arduino Stack Exchange have a far more important question: how do you trigger an alarm when your TP supply is low?

[user706837] asked the Internet this question in response to his kids never replacing an empty roll. This eliminates the most obvious means of notifying someone of an empty roll – looking at it before you sit down – and brings up a few interesting engineering challenges.

Most of the initial ideas deal with weight or some sort of light sensor that can differentiate between the white TP and the brown roll. A much, much more interesting solution puts a radioactive source in the TP holder’s spring-loaded rod and uses a sensor to detect how much TP is left. A quick back-of-the-wolfram calculation suggests this might be possible, and amazingly, not too dangerous.

We’re turning this one over to you, Hackaday readers. How would you design an empty toilet paper alarm? Bonus points awarded for ingenuity and cat resistance.

Image source, and also one of the longest and most absurd Wikipedia articles ever.


Filed under: Arduino Hacks, Ask Hackaday


  • Newsletter

    Sign up for the PlanetArduino Newsletter, which delivers the most popular articles via e-mail to your inbox every week. Just fill in the information below and submit.

  • Like Us on Facebook