voltage drop not seen by mega

Hi.

I am trying to make a pinball machine work with computer software written by someone else.

I have an arduino uno for the buttons, shutter motor and ball lift motor and a mega2650 for the ball return, ball thro gate and ball in lane.

I am only a couple of weeks into working with arduinos with no knowledge of programming or electronics, again the programming is done by another person.

The problem I have is that the ball going through the ball gate (2 metal contacts which are open and the ball goes through the gate and closes the contacts) is so fast that the voltage drop is only .5 to 2volts and therefore the mega does not seem to see it, if I hold the gate open for a second longer it completes the cycle and the next ball rises.

I have been reading about digitalreadfast and was wondering if that was the way to go.

forgot to add sketch

BALLY_25_SWITCH_MASTER.ino.ino (3.83 KB)

I am trying to make a pinball machine work with computer software written by someone else.

So.... You have the Arduino software and you want to modify it?

The problem I have is that the ball going through the ball gate (2 metal contacts which are open and the ball goes through the gate and closes the contacts) is so fast that the voltage drop is only .5 to 2volts and therefore the mega does not seem to see it...

Is it normally +5V and it's supposed to drop to about zero?

How are you measuring that? Assuming you're using a meter, your meter may not be fast enough but the voltage probably is going to zero. Meters don't respond instantly because you have to have time to read the numbers. That doesn't mean the Arduino isn't fast enough... A mechanical switch is usually slow compared to microprocessor speeds....

If I hold the gate open for a second longer it completes the cycle and the next ball rises.

We'll need to see the code. And, it wouldn't hurt if you can show us a schematic (at least a small schematic of that switch and how it connects to the Arudino).

I'd guess that the program is off doing something else when the switch closes and you're not reading/looping fast enough to "catch" the switch-change. The processor can only do one thing at a time and most of the time it's not reading the switch... It's a question of how often it reads the switch (how fast your loop runs0. Are there any delay() statements in the code? You might have to use an interrupt or make some other changes to the program.

You could also use a 555 timer chip to "stretch the pulse", but you might need some other components and I'd rather see a software solution if possible.

I have been reading about digitalreadfast and was wondering if that was the way to go.

Sorry, I'm not familiar with that function (macro?) but you'd probably have to change all of the reads & writes, etc. to make the program run faster. (An interrupt is probably a better solution.)

P.S.
Lots of delay()'s... Just quickly scanning the code, it looks like once you detect a sensor you start a delay so you can't read another sensor until that delay time is up.

You can not simply connect a switch to a controller, if that switch is already connected to other (pinball...) electronic.

In detail when you want to connect multiple switches, you have to figure out a common line, that can be connected to the Arduino Gnd, and then the voltages (AC/DC?) of each contact in open and closed state. Then we can find out how to connect the contacts to Arduino input pins.

Is this like a real (full size) Pinball machine or what? There are some serious hardware concerns to address if you're talking about a "real" pin...

Hi.

Thanks for the replies.

"Is it normally +5V and it's supposed to drop to about zero?"

Yes it is 4.6v and I am using a multimeter, the switch is 2 metal contacts which are open and as the ball goes through the gate it closes the contacts, but it happens very fast.

"You can not simply connect a switch to a controller, if that switch is already connected to other (pinball...) electronic."

I am only using the original wiring and where a wire that I need goes through another switch I have bypassed that switch with a wire direct to the Mega.

The only voltages I have are from the Uno and the mega, the two 12v stepping motors are powered by a 12v mains adapter plugged into the uno.

I have a ground bar with all the grounds connected together and a ground from the uno and mega into the ground bar.

"Is this like a real (full size) Pinball machine or what?"

Yes it is but I am only using the wiring, as I said above the only power I have is a 12v supply for the stepping motors, I am using nothing off the original pinball machine.

The game runs fine if I operate the ball gate switch manually.

The top half of the machine will be a tv monitor displaying the game I want to play, all controlled by a computer.

I have attached a photo.

I hope I have answered your questions.

Sorry but I don't know how to use the quotes.

Please measure the current flowing when you short a switch (connect Ameter between contact and ground).

To prevent shorting of an Arduino output pin and other damage, I'd suggest to use optocouplers.

The reading is 1 on the 200mamp and .12 on the 20m

I think that I confused inputs and outputs in reply #6, in a mix up with another thread :frowning:

If you are reading signals from switches, the open state voltage must never exceed Vcc. Insert a resistor (1k-10k) to prevent damage to the Arduino pin. For 12V contacts add a voltage divider (18k/10k).

When the switch contacts are shorted by the metal ball or gate, the signal can be bouncing heavily. You can add a capacitor (10nF-100nF?) over the switch contacts, to reduce bouncing. Even then you'll have to debounce the switches in software as well.

Just to make sure I am putting the capacitor in the correct place, the terminals for the ball gate switch are 1/2 an inch apart, do I connect a leg to each side of the terminals and keep the live and earth wire wires connected to the terminals.

I will get one tomorrow.

That capacitor can be placed where it fits best. The "contacts" here denote the wires connected to the contacts, not a required placement. Sorry for my poor English :frowning:

The capacitor here shall not protect the contacts, but shall form a RC low pass filter, together with the resistor to the input pin. For that purpose the capacitor comes first (other pin to ground), then the resistor, then the input pin. That's a typical protection scheme when connecting long lines to Arduino inputs.

I think your english is very good, it is my ignorance of electronics and terminology.

I have attached a photo of the capacitor in place, it is temporary at the the minute as I wanted to be sure it was in a good position.

Can you help me please with the software for the debounce.

Thanks.

I had placed the capacitor near the Arduino, but you can leave it where it is.

For debouncing see the Debounce and StateChangeDetection examples.