Rifle Training Device - Microcontroller Sensing a Higher Voltage Motor Circuit

Thread Starter

gronkle

Joined Jun 2, 2012
18
(I think my previous post was consumed by the moderation queue - I have waited until today to repost)

I am making a simulation training device out of an Airsoft Rifle. I have a microcontroller and switches attached to the rifle that senses when things happen and tells this to a computer over USB. A switch is on the M203 Grenade Launcher breach, the M203 leaf sight, and the M203 trigger. In the previous version of the device that worked as intended, the rifle trigger switch was made by hijacking the trigger switch circuit. The 9.6 volt 1600mAh was removed from the high-torque motor that generates the air pressure for the pellet launch, and replaced with the 5 volts coming from the Arduino Mini Microcontroller. When the trigger was pressed, the 5v and 40mA was returned to a microcontroller pin.

So now we want to add the satisfying report to the rifle back by replacing the 9.6v battery and motor, and then sensing when this switch circuit has been activated. (The M203 circuit components will not be affected) So here is the problem - I cannot get access to the trigger switch to make a double pole, double throw circuit to isolate both circuits. This means I need to a) sense when the trigger has been depressed and the 9.6v/1600mAh is flowing to the motor, b) provide a constant 5v/40mA back to the pin on the microcontroller when this happens, and c) do this while providing voltage spike protection normally associated with a motor circuit. What is the best circuit diagram to do this with the two separate voltages, one being a battery?

Please note that I am not an electronics experts, please break it down Big Purple Crayon Style.

 

Attachments

wayneh

Joined Sep 9, 2010
17,496
b) provide a constant 5v/40mA back to the pin on the microcontroller when this happens
Does it really need 40mA? Do you know if the 40mA current draw is consistent?

Your solution could be as simple as a resistive voltage divider to bring down the 9.6V down to 5. This would only work if the 40mA load is reasonably constant.

If it's not, you could add a 5v zener across the inputs of the micro-controller so that the voltage at its inputs never exceeds 5v. Probably a good idea no matter what.

Or, you could forget the resistors and just put 8 small diodes in series. Each would drop about 0.6V, dropping at least 4.8 total, bringing your 9.6 down to under 5.

Lots of ways to skin this cat.
 

Thread Starter

gronkle

Joined Jun 2, 2012
18
Does it really need 40mA? Do you know if the 40mA current draw is consistent?

Looks like 40mA was a maximum value. Here is what the Arduino Pro Mini website stated : "Each of the 14 digital pins on the Pro Mini can be used as an input or output, using pinMode(), digitalWrite(), and digitalRead() functions. They operate at 3.3 or 5 volts (depending on the model). Each pin can provide or receive a maximum of 40 mA and has an internal pull-up resistor (disconnected by default) of 20-50 kOhms." What I know is that the input voltage has to be fairly constant, or you get "bouncing pins" (i.e. up, down, up, down, etc) that sends weird data to the computer.

Your solution could be as simple as a resistive voltage divider to bring down the 9.6V down to 5. This would only work if the 40mA load is reasonably constant.

Very roughly, something like this? (remember my light background in electronics, please verbally correct this circuit if needed...I am sure there is something wrong with it somewhere):



I don't think the voltage is constant as the motor has to go from a rest state to a full load state...also what would I do with the two grounds, one on the battery, the other on the microcontroller? (the 330ohm resistor is supposedly there to pull the pin to ground to prevent it from bouncing)

If it's not, you could add a 5v zener across the inputs of the micro-controller so that the voltage at its inputs never exceeds 5v

Where exactly would the 5 volt zener diode have to go in the resistive voltage divider circuit?

Or, you could forget the resistors and just put 8 small diodes in series. Each would drop about 0.6V, dropping at least 4.8 total, bringing your 9.6 down to under 5?

I will try this too, what size/type diode would you recommend?


also, what about a DC to DC converter, like this?:
 

Attachments

Thread Starter

gronkle

Joined Jun 2, 2012
18
Currently the solution was to use an optoisolator that isolated the 9.6 volt circuit from the 5 volt circuit.

Seems to work adequately. One issue is that when the optoisolator is activated after a trigger depress, the switch will stay closed for a longer period of time. In other words, the switch is not a finite event. Not sure if this is due to the energy stored in the coils being returned to the circuit after the trigger has been released. While this issue can be addressed in the Arduino code (or I think by altering the resistor situation to have the internal LED fire only at the peak of the voltage) - this may be an problem for others dealing with a similar situation.

Also, since milliseconds count in this case (rifle event must be choreographed with a simulation event) - this may not be the best solution even though it works adequately.
 
Top