Author Topic: Arduino, data and supply voltages on same pin?  (Read 3851 times)

0 Members and 1 Guest are viewing this topic.

Offline gmcTopic starter

  • Regular Contributor
  • *
  • Posts: 116
  • Country: gb
Arduino, data and supply voltages on same pin?
« on: April 19, 2019, 05:06:59 am »
I'm busy with a project where I am using an Arduino to either switch 5V, 12V to data to a IC under test. Depending on which IC is under test it will either need 5V, 12V or data send to it.

I've come up with 2 ideas, not sure which one is better or if they are both terrible.

On the first schematic I would like to use something like a 4066 to switch supplies (I know the 4066 has a high resistance so would not be able to use this specific chip. Is there something that will suit my needs to switch a max of 40mA at 5V and 12V.

So if D10 is high (D11, D12 low) then 12V is powering the test chip.
D11 is high (D10, D12 low) then 5V is powering the test chip.
D12 is high (D10, D11 low) then data is send to the test chip from Arduino via D13

Downside of this is if I messup the programming or when powering up Arduino D10,D11, D12 are all high then I risk damaging Arduino

On the second diagram I'm using transistors to switch the supply voltages. A better option? Again a risk if D10 and D12 both on then I risk damaging Arduino.

Any feedback on this would be appreciated. Is there a better/safer  way to do this? I have to share output pins going to the test IC as depending what the IC  is under test, it requires different voltages or data pin.
 

Offline Nusa

  • Super Contributor
  • ***
  • Posts: 2416
  • Country: us
Re: Arduino, data and supply voltages on same pin?
« Reply #1 on: April 19, 2019, 09:27:59 am »
Start by simplifying. I'd suggest using the 5V switch for data as well. When you want 5V, just hold the line high. When you want data, let the data flow. And as a bonus, you've eliminated your unprotected data line.

Otherwise, either of your methods is fine. Or use optoisolators (e.g. PC817) if you want complete isolation.

Also consider what happens if you turn on 5V and 12V at the same time. Adding a diode or two might be smart.
« Last Edit: April 19, 2019, 09:41:21 am by Nusa »
 

Offline gmcTopic starter

  • Regular Contributor
  • *
  • Posts: 116
  • Country: gb
Re: Arduino, data and supply voltages on same pin?
« Reply #2 on: April 19, 2019, 09:37:12 am »
Thanks, I thought about using the Arduino to supply the 5V but the test chip draws 40mA which could exceed the current from the Arduino IO pins.
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 1995
  • Country: us
Re: Arduino, data and supply voltages on same pin?
« Reply #3 on: April 19, 2019, 01:42:45 pm »
I don't know what chip you would use for your first circuit.  The CD4066 will go to 15V, but the HC4066, which could supply the current, only goes to 7V absolute maximum.  Actually, you might look at the CPC1017.  It's described as a solid state relay, and is a little 4-pin SOP device, about $1 each.  You would need three of them.  Typical ON resistance is about 7 ohms.  And being optocoupled, it would absolutely protect your Arduino.  It looks like the CPC1006 would also work.

In the second circuit, it looks like your PNP transistors are upside down.

Either way, as Nusa says, diodes would be needed to prevent, say, the 12V supply from flowing into the output of the 5V transistor or switch gate when it's turned off.  Bad things tend to happen when you do that.  But maybe not needed with the CPC1017.

« Last Edit: April 19, 2019, 01:55:56 pm by Peabody »
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3342
  • Country: nl
Re: Arduino, data and supply voltages on same pin?
« Reply #4 on: April 19, 2019, 06:00:21 pm »
I would build the circuit like in the attachment.
(You drew the PNP transistors backward).

It works as follows:
Q1 and R3 form an Emitter follower, and because the Microcontroller output is either 0V or 5V, the current through R3 will be either 0 or 1mA.
If the Microcontroller output is low, then R4 wil keep the Base of Q2 high to prevent leakage paths.
If the Microcontroller output is high, then there will be almost 1mA through the resistor and the Emitters of both Q1 and Q2 and Q2 can deliver a few hundred mA to the "test IC".

R6 is just a combination of both your pull down resistors. No need to put 2 resistors parallel.

For the feedback:
For 0V to 5V, the voltage over R5 will be small as long as the microcontroller pins is an input (high impedance).
If Q2  is open and there is 12V on the right side of R5 then some current will be shunted through the skottky diode to Vcc.
Instead of a skottky diode do Vcc you can also use a zener diode to GND, or even 2 LED's in series (About 4V, depending on color).
« Last Edit: April 19, 2019, 06:43:19 pm by Doctorandus_P »
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12855
Re: Arduino, data and supply voltages on same pin?
« Reply #5 on: April 19, 2019, 06:24:23 pm »
...
Actually, you might look at the CPC1017.  It's described as a solid state relay, and is a little 4-pin SOP device, about $1 each.  You would need three of them.  Typical ON resistance is about 7 ohms.  And being optocoupled, it would absolutely protect your Arduino.  It looks like the CPC1006 would also work.
That will do it.  Just add some interlock logic between the Arduino outputs and the three CPC1017 opto LEDs + their series resistors, for protection during development.  Assuming you use active high outputs to drive them, the interlock logic could be as simple as three gates of a 74HC01 open drain NAND, gate inputs wired to the Arduino outputs in pairs (all three possible combinations) to detect if more than one output is high, with all the NAND output wired to the Arduno reset pin, so if your code attempts to turn on more than one opto, it immediately gets reset, tristating all I/Os and turning off all the optos. 
 

Offline gmcTopic starter

  • Regular Contributor
  • *
  • Posts: 116
  • Country: gb
Re: Arduino, data and supply voltages on same pin?
« Reply #6 on: April 19, 2019, 06:52:21 pm »
Thanks, I'll have a look at those CPC1017's, they look perfect for the job and are pretty cheap too.

Didn't release that transistor was backwards. thanks.

Also going to be using a voltage divider and reading the voltage on the analog input. My code will check that the voltage is correct (12 or 5) before switching other inputs.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12855
Re: Arduino, data and supply voltages on same pin?
« Reply #7 on: April 19, 2019, 08:09:14 pm »
You'll probably also want a current sensor in series with the ground to the IC under test - a low-ohm resistor with the current sense voltage across it feeding a comparator - if the IC under test is drawing more than say 70mA, its bad/damaged so you need to shut-off the optos PDQ, to cut power to it, hopefully fast enough to avoid damaging them.

You can also amplify the sense voltage with an OPAMP to feed an analog input, but MCU ADCs (+ the code to read them) are usually too slow for 'electronic fuse' over-current protection.
« Last Edit: April 19, 2019, 08:41:28 pm by Ian.M »
 

Offline gmcTopic starter

  • Regular Contributor
  • *
  • Posts: 116
  • Country: gb
Re: Arduino, data and supply voltages on same pin?
« Reply #8 on: April 19, 2019, 08:19:54 pm »
Great idea. Will add that it as well.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf