How to create a blinking light with a push button in PLC? - button

I have create a ladder diagram to control the light with a push button. I want make a blinking light with my push button. I have create a ladder diagram to control them. When I press the button, the light will start to blink. However, when I release my hand from the button, the light will turn off. I want to make it keep blinking when I press the button.
In the image, it is the ladder diagram that I created. M0 is the button.

As you did not specify exactly the model of the PLC and the program (IDE), I created this example for a Delta DVP programmed in the ISPSoft software (v3.14), it is similar to yours, except for the memory for the times, here I left the time fixed at 1 second for each timer.
Y0 will flash when pressing (OFF > ON) the M0 button.
Here I use a rising edge detection for M0, this is optional for your case.
I put M1 to stop the program (instead of M2) and put M2 as a memory to hold the state.

Related

DataQ stuck in CDC mode

I have dataQ plugged into a bunch of circuits in the lab that I use to measure Voltage V. Suddenly, I tried to connect to the dataQ in my laptop for the usual testing, but the device did not show up in the "Windaq dashboard" software. The device shows up in the device manager as "COM3". I did some research and I found out that means that the device is in CDC mode and I need it to be in LibUSB mode for it to be detected. to do that the manual says to hold on to the control button after 5s from connecting to the computer until the LED light turns red.
My problem:
I pressed and was holding the button for 1 minute but it never went red. am I misunderstanding the problem ? Any help from experienced people is appreciated.
(Note: I am using DI-4108)
I got the answer from the company itself:
keep pressing the control button as fast as possible and after that press and hold it until the LED is red

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.

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.

Arduino button interrupt triggered on high power switch on

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

Find time difference between two pulses using PIC16F628

I want to find time difference between two pulses using PIC16F628.
I am using a 4MHz external oscillator, MikroC compiler.
As a simple example let's assume there is a push button. When we press it, it sends a high signal to a pin. We press this button twice with some delay in between, I want to find the time difference between these two button presses.
Thank you.
As mentioned in the comments, the simplest way to do this is to use a timer/counter combo. I found this quick tutorial on how to do this specifically for PIC: http://www.mikroe.com/chapters/view/17/chapter-4-examples/#c4v5.
Have a look at 4.5 and 4.6, they give you exactly the information you'll need to get the count of timer intervals between pulses. The basic technique is to start a timer, associate an interrupt handler (Read: function) with the timer, and then increment a counter everytime the interrupt handler is called. Next time you see the pulse, read what the counter value is.
After that, all you need to know is the timebase you've set the counter to (which will be some integer subdivision of your oscillator rate, and is selectable in code usually) and you can convert # of timer intervals to time in seconds/millis/nanos.

Resources