Arduino button interrupt triggered on high power switch on - arduino

I have a nearly finished prototype using an arduino uno. Basically its purpose is to switch a 2000w main AC heating load using a heavy relay on and off. The input of the relay is comming from the mains but is connected to the power company using a special meter that is only switched on between 23-07 hrs at night. The power for the arduino is continous by the way, so this stays on.
The whole thing is nicely build into a box with on the front an small lcd display and a button, connected using 20cm wires to the arduino board (I am using a protoshield).
The button is pulled up with a 10k resistor which is pulled to ground when pressed. I have put a 0.47 uF cap on the input pin = pin 2 to also debounce the circuit a bit. In software I am using an interupt on the falling edge to detect button presses. The whole thing works nicely... Except...:
When the load ac input is switched on by the power company this is sometimes recognized as a button press! I am thinking that the suddon power spike induces a voltage in the 20 cm button wires which is recognized as a falling edge. How can I avoid this?
I am equiped with multimeter, oscilloscope, soldering... so I can try out any suggestions in detail.

I am having a similar problem building a fuel injection flow bench. The button press starts a simulated engine run sequence that powers a relay. That relay then powers up to 6 injectors. What happens is as soon as I press the button the injectors closing induces a current and trips the whole system to start over again. The solution I've found that worked was using a battery to supply voltage to the injectors as opposed to the power supply itself. This isolates the arduino supply from the injector supply via my relay. The problem is of course now I need to keep the battery charged. I'm looking for a more elegant solution.

I tried to solve this issue in hardware, but unfortunately failed.
These are the options I tried, but that did NOT work
used a shielded cable for the button
implemented an XY denoise capacitor network on the AC of the load (input)
like this one : http://www.conrad.be/ce/nl/product/450571/K042201052-Ontstoringscondensator-XY-Radiaal-bedraad-01-F-250-VAC-1-stuks?ref=searchDetail
In the end I implemented the following software solution:
The first time the button is pressed, it must be pressed 1 second before the button actually becomes active. This will never happen due to the AC turning on because this is a very brief spike. I programmed this into the arduino using interrupt to detect button press and then micro delay (inside the ISR) to check that after 1 seconds the button is still pressed.
After the initial 1 second button press, the button stays lively for 1 minute

Related

ON/OFF Switch with Push button (LTSpice & electronic test)

I am trying to do an ON/OFF switch to power up my MCU when user use a push button :
Schematics
When the user clicks once, the MCU should light up. When the user clicks a second time, the MCU should turn off.
To do this I thought of the simplest solution, in analogue, which seems to be a flip flop D.
I did some simulations on LTspice, it seems to work, but I'm not really sure.
Simulation result
I have three questions:
Why do I get 1V and not 3V at the output of the simulation?
Does this setup seem OK in reality?
What to do with the SET & RESET pins: should I leave them unconnected or connect them to GND?
Regards
The digital components of ltspice has two only 0 and 1 (low and high). Download a library for LS and for CD series to behave more like the real components. And make symbols for them.

Am I a wizard? An led lights up when my fingers get close

I was writing some simple code involving a tilt ball switch, but it didn't end up working right. I messed around with the inputs and outputs and eventually I learned that when I put my fingers near the input pin, the built-in led lit up. I didn't even have to touch anything. Are the input pins just really sensitive to an electric or magnetic field in my fingers?
Here is the code that I was running: 1
When the led built-in was lighting up I only had the Arduino hooked up to a power source. The most logical thing that I can come up with (which is probably wrong) is that my fingers are magnetized which creates a magnetic flux which induces a current. So basically I'm Magneto until somebody tells me what is actually happening.
I'm not qualified to answer whether or not you are Magneto.
As for the Arduino, try adding a resistor between Pin 8 and Ground.
That should help to drain the phantom signal that your mutant powers are generating.

Node-Red + Arduino nodes - distinguish long press of push button from short one

My setup is a PC with running Node-Red and Arduino Mega (standard Firmata) plugged via USB. I also have a push button wired to the Arduino's pin. I can read the state of the button, but I would like to distinguish a long press from a short one. For example:
short press - power toggle switch #1
medium press - power toggle switch #2
long press - power off all switches.
How can I achieve this? Do I need to write some function (I'd be glad for a little help here too, as I am no programmer) or I just have not found yet dedicated nodes?
The second scenario is not to distinguish the length but the number of times a button was pushed (in 0.5 sec for example):
1 time - power toggle switch #1
2 times - power toggle switch #2
3 times - power off all switches.
Is this easier to achieve?
Best regards,
Jakub
You will certainly have to write a function on the Arduino to have it generate some form of a message that can be sent to Node-Red.
You could use the serial interface of the Arduino to send it to the pc over the USB port and have Node-Red listen to the serial port. There are plenty of examples for Arduino to start with (a lot of them in the Arduino IDE itsself).

How to differentiate active and passive buzzers in Arduino?

I have an Arduino starter set, which came with both an active and a passive buzzer. Unfortunately, I can't seem to know which is which. All I know is that one is a little longer than the other one, on which I can see the green circuit board underneath.
An active buzzer generates the sound itself. You basically just turn it on or off.
A passive buzzer needs a signal source that provides the sound signal.
To find out which is which you can measure the resistance between both leads. If it is a few Ohms its the passive one, higher values indicate an active one.
Also the active one will have it's own circuitry (the pcb you can see) and will therefor be probably bigger.
But I guess your arduino package comes with a parts list that should give you all information you need?
"Programatically" speaking:
Active Buzzer: using a simple digitalWrite(buzzerPin, HIGH) will turn the beep on, once it has a internal oscillator.
Passive Buzzer: you need to use Tone() function in order to make it beep. Once it has no internal oscillator you need to use Tone() function to create the frequency it will oscillate. Check the Tone() reference page to learn how to use it, but is quite simple, you just need to enter as parameter pin and frequency like Tone(3, 440), will generate a 440Hz on passive buzzer hooked up to pin 3.
To stop a active buzzer you need to use digitalWrite(buzzerPin, LOW), while with a passive buzzer you need to use noTone(passiveBuzzerPin).
How to distinguish passive buzzer and active buzzer?
There are several ways to distinguish passive buzzer and active buzzer.
The most simple method is to watch their different appearances.If you can see a drive board,it is passive buzzer.If the buzzer is completely covered by black adhesive,it is active buzzer.
https://www.keliking.com/Differences-Between-Passive-Buzzer-and-Active-Buzzer-id570060.html
They come in all shapes and sizes, so don't assume "long" means one thing or another. The passive buzzer has only a small piezo on the module's PCB. An active buzzer will have a couple other small components on the pcb, like an amp and resistor(s).
In the Freenove Arduino kit that i bought, the passive buzzer is the one with the green on the bottom and the active is the one without, and is slightly taller with varied hights of the pins
Physical distinction between the two.
Slight disclaimer first. . . the buzzers I have are from one of those 27 piece sensor kits. For me it was an extra buy from "30 Days Lost In Space". After my pieces all got mixed together, I've decided to lay them all out & know what each one does. Yours may be different
Here's what I observed. If you have the connections down and the buzzer away from you so you're looking at the back of the board There are solder points. The upper left solder point is filled on the active buzzer. note don't count the larger mounting hole on the very edge. In the photo, I've highlighted the filled solder hole on the active buzzer.
highlighted solder point on active buzzer -- left vs passive buzzer -- right
I had this same question, which led me here. The other answers were helpful in and of themselves, but I noticed the difference after testing, and hopefully someday this may help someone else who may be new, as I am now.
I've been at arduino just shy of 2 weeks.

FPGA - Push button constraints

Is there any benefit/reason to apply a setup & hold constraint to a push button input to an FPGA when the button is asserted asynchronously?
From what I understand a violation can still happen regardless as the button can be pressed within the setup and hold time of the flip-flop that it's connected to inside the FPGA.
Push buttons generate very slow changing signals compared to the system clock (0.001 .. 10Hz vs. several MHz). Applying setup/hold times is a waste of effort. Just apply a timeing ignore rule.
A propper synchronizer and maybe a debouncer circuit is needed anyway.
I agree with previous poster that push button input pin shouldn't be timed (use false_path). If you want to be very safe, you should probably:
Turn on Schmitt trigger for the input pin connected to the button.
Feed the input signal through 2 stage synchronizer (2 flops in serial)
Implement debouncer either using analog circuit on the board, or doing this digitally using a counter after the synchronizer.

Resources