Main > Main Forum

12 volt coin counter with I-Pac/4

Pages: << < (2/7) > >>

MonMotha:

No problem.  The purpose of the resistor is to limit the currect coming from the device. You might want to bump that up to about 420-470 ohms, actually.  That'll keep the current down to about 10mA.  You can probably go as high as 1-3.3k (you just need enough base current to switch the coil in the counter - this current will be 50-250 times the base current at maximum, the transistor will saturate and whatever current is needed will flow through the counter).  At 100 ohms, you'll actually get about 40mA out of the chip, which is a little more than I like to source without looking at spec sheets.  If your relay is only going to draw 20mA, then yes, you could probably just drive it directly, but again watch out for inductive switching transients.

The purpose of returning ground directly to the PSU is so that you aren't pushing excessive current down the USB cable's ground wire.  It's only designed for 500mA (figure it's overspec'd quite a bit, but bear with me), and if you've got it available, it's best to avoid it if possible when you're switching larger loads.  And yes, you can just use the 12V from the PC supply (heck, my entire arcade-on-a-bench is powered by an ATX PC power supply).

Your circuit diagram looks fine.  See note above about increasing resistor size.  In theory, you can also remove the diodes from the switches (the transistor acts like one), but leaving them there won't do any harm (other than lowering the current due to the voltage drop across them), and provides some extra protection against nasties.

The inductive switching transients I speak of are where, due to the inductance of the relay coil, rather large votages can appear across it when you switch it on and off.  These can be large enough, especially when of the opposite polarity than you're normally considering to damage semiconductors, especially ICs.  The transistor will isolate the IC from these transients (and can probably withstand them just fine).  If you were to drive a relay directly, placing a diode backwards across the terminals of the relay (so it is normally reverse biased - make sure the reverse bias breakdown voltage is significantly greater than what you plan on using, most will be much larger than 5V) will clip these transients to about 0.7V, which isn't big enough to cause damage.  If you drive the load with a discrete transistor, you don't really need to worry about this (and if it broke, it wouldn't matter too much anyway).



clhug:

Wow, you're fast!  I just thought of something to add and see you replied again already.  But I do want to add this comment to see if this changes anything.

I just realized this.  Under normal use of the I-Pac (or any keyboard encoder as I understand it), none of this circuitry is involved.  Usually a normally-open switch is connected with each input on the I-Pac then to the common ground.  So when a switch is closed, it's a dead short from the I-Pac to its own ground.  So why should I be concerned about placing any kind of a load on it?  If it can handle a dead short under normal circumstances, I can't possibly have "too high" of a current draw by either a relay coil or the transistor can I?  That will certainly be less current than the dead short no matter what won't it?  At the very least, would that mean that using the transistor method instead of the relay, I shouldn't need that resistor at all before the transistor?

I don't know how it handles it but it must be built in to the I-Pac device itself that we aren't really "drawing" current in the traditional sense from the USB port this way.

On a side note, the purpose of the diodes is to keep all 4 inputs on the I-Pac from firing at once.  These are coin inputs.  In a 4 player game, each coin for each player must register individually.  Without the diodes, any time one coin switch was activated, all 4 coin inputs would activate.  That's the theory, although I have to say now that I look at TheNasty's diagram again, I don't quite follow that logic with this particular diagram.  Again, normal operation of the I-Pac would still have all the grounds tied together, just not going through the counter and no diodes.  What difference does it make to have the counter on the ground side or not?  The switches themselves (being normally open) block the other inputs from firing.  The only thing I can think of where the diodes might be needed is if we tried to wire the counter between the I-Pac and the normally-open switches instead of after the normally open switches, but that would seem to make it more complicated than it needs to be.  So the more I think about it, I'm not sure the diodes are really needed in this case.

On the transients again, I get the gist of what you're saying they are and certainly how they can cause damage.  I still need a bit more on specifically what kind of a diode to hook up here though, and how to hook it up.  Would a 1N4004 type work?  That's just what was recommended to use for the diodes before the switches.  And just to clarify on how to wire it in, you mean put it backwards directly across the terminals of the coil of the relay?  Something like this?

                                 
+5 from I-Pac -----------|Relay Coil|-----------Ground
                                    |               |
                                    |----|<-----|
                                        Diode



MonMotha:

Oh, ok.  I didn't see that.  Yes, that's what those diodes are for, and you'd still need them.  I didn't realize those were INPUTs you were hooking up to (I wondered what the switches were for on the outputs...now I know).  That's a bit different.  You don't have to worry about sourcing too much current from an input as you're actually sourcing current from the pull-up resistor on the input, not the chip itself (well, at least that's where most of the current comes from).

*EDIT*: I'm still not entirely sure why the diodes in front of the switches are needed to prevent them all from triggering - only the ones that are active should still trigger.  But they won't hurt anything (see below still).

That's actually a kinda nifty design.  And yes, you can just get rid of the resistor on the base of the transistor in that case.  The pull-up will do everything for you.

That does mean that any transients could cause even more problems since they'd be appearing on an input.  CMOS inputs especially don't like to be driven beyond their rails.  Of course, using a transistor that doesn't matter.

What will happen in this case is that the pull up resistor (which is probably internal to the microcontroller on your IPAC) will normally float the input gate high since there will be no current flowing through it (so the drop across the resistor is 0, and the resultant node voltage is 5V).  When you push the switch, current will flow through the resistor, through the diode, and through the transistor.  This will pull the input to the IPAC low (caveat: see blow), and the resultant current from doing so will turn on the transistor as it goes to ground, which will activate your coin cointer.

There may be a problem here that the input "low" voltage which was before at ~0.7V (one diode drop) will now be 1.4V due to the base-emitter voltage of the transistor in addition to the diodes.  This may be too high for reliable detection of a low.  If that's the case, you can use the old design, and wire the switches additionally to a NAND gate (such as a 7420 - F, S, LS, or HCT will do, standard C or HC may not be reliable) and use the output of that to drive your transistor.  Only bother with that if you aren't getting reliable detection of coin insertion.  If you only want one coin switch, you can omit the diode in front of the switch and just have the transistor there - then there should be no problems.  It's OK to wire-or (i.e. connect together with simple wires) coin switches if you have multiple identical switches that don't need separate software counts or credit/coin settings.

There's also a way to use 4 transistors and no diodes instead (basically, replace each diode with the transistor base-emitter, and wire the collectors together) if you'd like.

Your diode drawing is correct.  You want to have the diode seemingly "pointing" the wrong way.  This will clip nasties to a safe level should they occur.  A 1N4001/2/3/4 or 1N4148 should be fine for that.

clhug:

Awesome, thanks!!  Yes, these are inputs.  The I-Pac simulates a keyboard.  When a given input is grounded it sends a particular keystroke to the computer.

Yes, on the software side I do need to keep the coin inputs separate for some games.  However, I agree with your edit.  I don't understand what function the diodes are serving here since they're already on the separated side of the normally-open switches.  The switches themselves would block any back triggering so the diodes should be completely unnecessary with this diagram.

Now, I just tried a simple version of the transistor setup using only one of the coin inputs and no diodes (since only a single input).  Thought I'd make sure it worked using just a single input before trying to tie them together.  No problems with the I-Pac still detecting the input and creating the keystroke, but the counter won't fire.  I verified that the counter fires fine when I just directly touch it to the 12 volts.  It just won't when it's going through the transistor.  What should I look at.  Oh, based on your very first reply I'm using a 2N3904 transistor since I could get one of those for 69 cents.  The 2N2222 came in a package of 15 of them for $2.59.  Since I just need one I opted for the 2N3904 in a single package for lower price.  What should I look at?

MonMotha:

With the switch depressed (closed), check:

V_BE (voltage from base to emitter) of the transistor: should be about 0.6-0.75V.
V_CE (collector to emitter) should be about 0.2-0.5V.

If you can measure the currents directly (using a multimeter), what is the current going into the base?

I don't remeber how you have it wired up as there are multiple "correct" ways.  If you have the emitter tied to one end of the counter, collector at 12V, and the other end of the counter grounded, V_E (emitter voltage) should be about 11.5-11.8V (V_12 - V_CE).  If this is how you have it, try the below method.

If you have the emitter grounded, counter hooked up to collector and other end of counter at 12V, V_C (collector voltage) should be about 0.2-0.5V (=V_CE).

If you are using the first method, all that base current has to flow through the resistance of the counter, which may cause it to not be big enough to turn the transistor "on".  In the latter case, with the emitter grounded, the base current can flow more freely and should easily turn the transistor on if the pull-up resistors are small enough valued: if they're 4.7k, I = 915uA which is usually big enough to switch most loads on a 2N3904 if the current gain is large enough.  You can try a darlington pair type transistor (which is basically two transistors set up such that the current gain essentially multiplies).  The first method also means that with 12V, you'll actually reverse bias the base-emitter junction and turn it off.  That method really only works when the supply is the same voltage as the supply voltage to the load.

Do you know the coil resistance of specified current of your counter?


Pages: << < (2/7) > >>

Go to full version