Some kind of electronic switch

Hey guys,

I'm not sure if this is an unusual one or not but it's the situation i've found myself in.

I need to be able to switch a ground wire on and off on demand. After testing, I know this is the best course of action for what I'm doing and I can see on my bread board that unplugging the ground gives me one function I'm needing and plugging it back in gives me a different function I'm wanting.

What I'm really needing is some kind of switch that when I send a:
digitalWrite(switchPin, HIGH);
it'll complete the circuit leading to the ground pin and when I send a:
digitalWrite(switchPin, LOW);
it'll break the circuit.

I'd thought I could do this with a transistor but so far have had no luck, though it is entirely possible that I'm not doing it correctly, I'm afraid I'm no expert of electronics.

Can anyone help me out here? I'm sure it must be very simple really.

Andy

After testing, I know this is the best course of action for what I'm doing and I can see on my bread board that unplugging the ground gives me one function I'm needing and plugging it back in gives me a different function I'm wanting.

Danger...danger...this does not sound like the right answer. Give us more details and I'm 99% sure we'll be able to give you a better solution :wink:

But, what you want to do is fairly easy. Just use a MOSFET connected something like this:

Q1 can also be any other logic-level MOSFET (the "logic-level" part is important because it means the MOSFET can switch on with only 5V at its gate terminal).

--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, speaker, microphone, light sensor, potentiometer, pushbuttons

Thanks, that looks really useful.

I'll try my best to explain, though I have a habit of rambling so forgive me if I confuse you.

I have a model airplane with four servos for various controls. For this I'll just talk about one of them, the one that controls the ailerons (bits on the wings that wiggle to make it roll left and right).

This servo is connected to a radio control unit already which gives me my full manual control. Here's where I start to have my fun, I have an arduino with a bluetooth adaptor that speaks to an android phone that it placed inside the plane. The phone has all the sensors and internet access I need to develop some pretty cool stuff, eventually to the point that the plane will fly itself.

Right now the plane is set up so that when it tilts, the phone detects this and the arduino uses the servo library methods to compensate.

Now here's my problem, I can not in all good conscience allow Hera (the plane's name) to fly without having the fail safe of taking back manual control if the the phone dies.

What I can do is connect both circuits to the same servo with the ground to the radio control unit and the arduino being tied in together.

The arduino's signals from the servo library methods seem to be powerful enough to drown out all signals coming from the radio control unit. I'd thought that sending the:
ailerons.detatch();
command (from the servo library) would be enough to give me back control but apparently not.

The only method is to disconnect one of the wires that completes the circuit between the arduino and the servo, either the signal or the ground, this breaks the circuit with the arduino and gives back all control to the radio control unit.

Now I had thought of putting this electronic switch on the signal pin but I figured that considering I will eventually be having all four servos connected up, I may as well put it on the ground because after all, that would mean just one wire to be playing with, rather than four.

I hope I've made sense enough for you to picture what I'm doing, if you've better ideas for solving this, please tell, as I said, I'm no electronics expert :slight_smile:

If it works, it works, and I'd hate to waste your time on this when it could be spent doing cooler things on what is already a very cool project.

But here is the part that concerns me:

The arduino's signals from the servo library methods seem to be powerful enough to drown out all signals coming from the radio control unit. I'd thought that sending the:
ailerons.detatch();
command (from the servo library) would be enough to give me back control but apparently not.

This "mixing" of signals from the RCU and the Arduino is really the root cause of the problem, and I think root causes should be eliminated. They can lead to unforeseen problems down the road (or in the sky). If you have some kind of schematic that shows how you are doing this mixing perhaps we can help with that instead.

--
The Rugged Motor Driver: two H-bridges, more power than an L298, fully protected

RuggedCircuits:
But, what you want to do is fairly easy. Just use a MOSFET connected something like this:

Hi RuggedCircuits

As a newbee, can I ask you to please tell me why the 47k resistor in your circuit ?
I assume that it is a pull-down, but if the output pin was set LOW during the setup(), wouldn't that be doing the same thing ?

The pulldown is not strictly necessary but it prevents the MOSFET from being damaged should charge accumulate at its gate (easy to do due to electrostatic buildup). MOSFET gates can be damaged by as little as 20V while your accumulation of 1000V on your body of electrostatic charge is barely perceptible when you get "zapped". So it doesn't take much "stray charge" to destroy a MOSFET. The 47k resistor provides a path for that charge to leave the gate. When the Arduino is off or is in reset, the pin driving the gate is floating thus does not pull the gate neither high nor low, which is when bad things can happen (as they can while you are building the circuit, so put the resistor on first :slight_smile: )

--
Beat707: MIDI drum machine / sequencer / groove-box for Arduino

Thank You for an excellent explanation.

I'm off to add some resistors to my circuit.

Was the 47k value arrived at by calculating the current required from the pin (after the 1k) to drive the MOSFET ?

No, it was more calculated as a Goldilocks-type thing: not too big, not too small, just right. Too small and the voltage divider formed by it and the 1k resistor doesn't allow the gate voltage to be high enough. Too big and it isn't a good path for charge to drain. The value isn't particularly critical. I think for a 1k series resistor anything between 10k and 100k should work fine.

--
The Aussie Shield: breakout all 28 pins to quick-connect terminals

The underlying assumption that because there are 4 signal lines and 1 ground line it would be easier to switch/disconnect the ground line is flawed.

The 'signal' really consists of the difference between signal and ground voltage for each of the 4 servos. Those 4 signals happen to share a common ground but they are 4 signals. If you disconnect the ground from the signal source but leave all the servo grounds connected together then you still have differences between signal and signal at the receiving end. You could disconnect each ground separately, but this is still switching 4 wires...

RuggedCircuits:
.........I think for a 1k series resistor anything between 10k and 100k should work fine.

--
The Aussie Shield: breakout all 28 pins to quick-connect terminals

I disagree. If the 1k resistor is changed to 100k and the other one is 47k, then the current from the output is 34 uA causing only 1.6 V to gate. With 1k, the current is 0.1 mA and gate voltage 4,9 V. Much better.