Go Down

### Topic: Converting 6v AC to arduino input (Read 1 time)previous topic - next topic

#### trickpony

##### Dec 02, 2008, 04:08 am
Hi.
I have a project where I need to convert 10 6V AC switches into signals to the arduino. I only need to know if the switch is open or closed.  I want to do this for under say \$5.

What would I use?

Thanks
Ben

#### kg4wsv

#1
##### Dec 02, 2008, 04:47 am
I'm working on a project where I need to sense when a 240VAC source is on.  I found this AC input optoisolator useful.

-j

#### trickpony

#2
##### Dec 02, 2008, 10:44 pm
Somebody was supposed to say 6 Vac, how do you have 6V ac?? Then of course I would have looked at the schematic and seen the transformer that is putting out 6V DC...heh.

Sorry,
Ben

#### retrolefty

#3
##### Dec 03, 2008, 12:26 amLast Edit: Dec 03, 2008, 12:28 am by retrolefty Reason: 1
You can use a diode to rectify the AC voltage to pulsating DC and then a capacitor to smooth out the pulsation and then possibly a resistor divider to scale the voltage to 5vdc. The result will be 5vdc when the AC is present and 0vdc when it is not, easily read from the A/D input or even a digital input. Should cost under a dollar per channel.

Lefty

#### kg4wsv

#4
##### Dec 03, 2008, 12:46 am
Well, if it's 6VDC, I'd probably use a voltage divider network (i.e. two resistors). 1k or 2.2k and 4.7k seem likely candidates.  A transistor or optoisolator would probably work, too, if you have them handy.

-j

#### trickpony

#5
##### Dec 03, 2008, 04:30 am
Ok, sorry I made an optimistic mistake, it IS 6v AC.
So the diode, cap smoothing seems the way to go.
Then I am thinking to use a 16 way multiplexer which will allow me to
use 4 digital pins from the arduino to select which switch to poll, then another pin for the actual read...so 5 pins total for 10 inputs (actually I have an idea to use a few more switches so that is perfect)

So what size cap would I use? 10v 1000uF
And the diodes could be 1N4004s?

Thanks all,
Ben

#### retrolefty

#6
##### Dec 03, 2008, 06:54 am
"So what size cap would I use? 10v 1000uF
And the diodes could be 1N4004s?"

Any 1N400x diode would be fine. Cap is kind of too big in that it will be slow to charge and discharge. I would try something small say 1mfd to start and experimate with the time lag to detect high to low and low to high. There will be a time constant (RC) developed by the cap and the input resistance of the I/O pin plus any pull down resistance. A lot depends on how 'fast' you want to be able to detect a change of state on a switch. If for a pin ball machine you want fast, if for people turning switches on and off, speed is not so important.

Good luck

#### trickpony

#7
##### Dec 03, 2008, 07:07 am
Thx retrolefty. It is indeed for a pinball machine.

I'll post the results.

Ben

#### retrolefty

#8
##### Dec 03, 2008, 08:06 am
"It is indeed for a pinball machine"

i guess I'm on a roll today   Make sure you wire the diode such that the cathode band goes to the Aurduino logic and the other end to the switched 6vac.

#### Grumpy_Mike

#9
##### Dec 03, 2008, 12:52 pm
Just a point, you say it's 6V ac but is that 6V rms or 6V peak. Most likely it is 6v rms as that's what a meter measures..

That means if you do a half wave rectification on it you will get 1.414 * 6 = 8.48 V as a signal. Be sure to factor that into your potential divider.

#### trickpony

#10
##### Dec 05, 2008, 12:48 am
Thanks grumpy, actually that should work out well because the voltage regular wants at least 7v to knock it reliably down to 5..

OK I found that mouser has DIP 16 channel analog multiplexers in stock at \$1.25 so I am thinking that these could make my life much easier.

Warning: I am going to show my ignorance below:

So I have this 6v AC being brought in to all these physical switches, the switches make contact any bring 6v to lamps (6v bulbs) then off to a common ground.
My plan is to remove the bulbs tap into the 6v coming in from the switches to the multiplexer, then use the arduino to check the values.

Question 1:
By Analog Multiplexer, does that mean I could connect the AC 6v from the switches directly to the multiplexer, or will I have to diode, cap, regulate each switch?
(The multiplexer is rated to run at 3-15V)

Question 2: If the above is possible then how should I power the multiplexer..can I do it from the 5v of the arduino

Question 3: Powering arduino. Will diode,cap(1uF), and regulator off the 6v ac(rms) power I have available be stable enough to power the arduino, or should I use a wall wart?

Question 4: Should I hook arduino ground to multiplexer ground to pinball ground.

Thanks,
Ben

Go Up