Hi there,
I' m trying to make a "failsafe" unit. Let' s make an example with one channel only: there is an input (where the pwm is produced) and an output (where I have to send my signals). I would like to 'stop' the source signal though a microprocessor' s trigger and, at the same time, send my mcu-produced pwm signal (from aduino). I thought to use a pnp transistor but it doesn' work properly (there is something wrong...). That' s my schematic:
I remember once it worked but I can' t find anymore the code. Basicly I set the 'base' to low to turn on the transistor and simultaneously I use pinMode INPUT to pin 10 to push the high impedence state and avoid the current flow into arduino. On the other hand I set the base to high to turn off the transistor and I push my pwm custom signal. I used this document but I can' t understand what' s wrong (PNP Transistor Switching)
They share the arduino' s ground. Maybe few problems with the code? Is it correct to call the input state? I tried many times but it won' t to work at all. I' ve also tried to stop the pwm signal from the source to the output, sharing the ground with arduino' s gnd, and triggering the base of pnp it doesn' t let the signal to pass. But if I do the same thing with the 3.3v it works. The transistor is an epitaxial, the A1266 one.
I would set pin 10 to input mode or at least HIGH output before switching the base. Maybe you killed a pin? I guess I'd test D4 with a new sketch and a couple of LEDs to make sure it can BOTH source and sink current ok.
Another thing. I assume the input to the PWM device is high impedance meaning no real current flows thru the emitter to the collector. I'm not real big on transistor theory myself, but maybe some kind of pulldown resistor on the collector to force some current to flow; otherwise I'm thinking the transistor will stay in cutoff mode.
Thank you for your suggestions:) but it still doesn' t want to work. I' ve seen that a 2x1 multiplexer is composed by at least AND gates, so I' m going to be sceptical about this kind of switch. But I still can' t understand why it doesn' t work with the pwm, in fact the 3v3 passes without problems. At this point, how a pnp transistor works? What happens when the base is polarized? How can I polarize the base without sinking all the current from the emitter/collector? Thank you
If you wanted to do this entirely in hardware, you would be best off implementing a simple multiplexer using 3 MOSFETs and 4 resistors (unless you wanted to use a single multiplexer chip).
Two P-channel MOSFETS act as switches to enable/disable the two PWM signals, and an N-channel acts as an inverter so that only one P-channel is on at once:
Using this method you don't run the risk of blowing an Arduino pin by messing up the order of your INPUT/OUTPUT switching.
Is the pwm signal an RC signal ? if so, why not do it all in software using a pass through mode which simply outputs whatever it receives and a failsafe mode which you can switch to to output whatever you require for failsafe. You can also have the system self recover when the failsafe condition passes.
DuaneB:
Is the pwm signal an RC signal ? if so, why not do it all in software using a pass through mode which simply outputs whatever it receives and a failsafe mode which you can switch to to output whatever you require for failsafe. You can also have the system self recover when the failsafe condition passes.
Yes, they' re rx signals (standard pwm, 25ms period). Because it would require many resourses from the mcu and the output signal wouldn' t be clean. And also because if arduino fails or just stuck I wouldn' t be able to keep the signal going...
Hey majenko,
thank you for your scheme! It' s really clear and simple, I would like to make this switching using just arduino and pnp transistor, otherwise I would have used a simple 2x1 multiplexer. It' s better to attach this other scheme:
Default
Read the PWM input (inizialize pin D7 to INPUT so its high-impedence state will not sink current)
At the same time pass the in to out (I suppose I should set the D10 to INPUT too so it will leave the current to flow among out)
How should I polarize the base?
Bypass
Read the PWM input (D7 to INPUT so it will not sink current)
Avoid the signal to pass though the pnp to out, so generate a custom signal from pin D10 and inject to out
I would like to say that the pwm source is a 6ch hobby radio receiver and the output is a servo. This configuration today doesn' t work. I don' t understand what' s the matter.