Interrupt- On digital input egde example | Arduino Compatible Compiler for LabVIEW Discussions | Forum

Avatar
Please consider registering
guest
sp_LogInOut Log In sp_Registration Register
Register | Lost password?
Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Feed Topic RSS sp_TopicIcon
Interrupt- On digital input egde example
October 20, 2015
1:50 am
Avatar
koforever
Member
Members
Forum Posts: 4
Member Since:
September 21, 2015
sp_UserOfflineSmall Offline

About Interrupt- On digital input egde example , 13 pin(digital output pin) turn on when pressed the button 5 times.

But it turn on randomly for me. I don't changed the example code and coplile is successufully completed.

Schmatic is attached below~

My arduino is UNO and Arduino compatible compiler for LabVIEW version is 1.0.0.19.(LabVIEW version is 2015)

Thank you~

(yellow cable -switch& pin 2)//(black cable-GND&switch)

pull-up-1.jpgImage Enlarger

sp_PlupAttachments Attachments
October 20, 2015
1:21 pm
Avatar
LubomirJagos
Member
Members
Forum Posts: 21
Member Since:
August 4, 2015
sp_UserOfflineSmall Offline

Hmmm, you could try to set up defined state for interrupt pin, when button is not pressed, ie. try connect resistor (100kOhm or other big value) between pin and Vcc. Also I haven't look for that example, but when you are using buttons, you have to solve glitches (you think that you pressed button once, but MCU see much more, for it is like you pressed it 5 times because mechanic contacts) so there is hopefully some delay after interrupt or there is electronic solution by connecting capacitor and resistor between pin and GND.

Here is what I think using resistor to set up default level on pin when button is not pressed: https://cdn.sparkfun.com/asset.....000000.jpg

October 20, 2015
2:27 pm
Avatar
Steffan
Admin
Forum Posts: 408
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

It is likely you are getting button bounce.  When a mechanical button is pressed it may bounce and you may get a few interrupts for a single press.  You can do some of the things LubomirJagos suggested.  You can also change the example to output the actual count to the serial terminal, for example, and you should see the count increase a couple of times when the button is pressed.  This would confirm what is going on.

October 23, 2015
8:18 am
Avatar
koforever
Member
Members
Forum Posts: 4
Member Since:
September 21, 2015
sp_UserOfflineSmall Offline

Steffan said
It is likely you are getting button bounce.  When a mechanical button is pressed it may bounce and you may get a few interrupts for a single press.  You can do some of the things LubomirJagos suggested.  You can also change the example to output the actual count to the serial terminal, for example, and you should see the count increase a couple of times when the button is pressed.  This would confirm what is going on.

Thank you!~ LubomirJagos and Steffan.

I confirmed that there are several falling edges when button pressed by using serial monitor.

So I'd like to add some delay to attcehd callback.vi.

But I saw contents that Delays not working inside of attaced callback.vi at the manual.

Is there are any other delay fuction working inside the attached vi?

At the arduino sketch, there is delay_ms() fuction to postpone.

December 1, 2015
7:36 pm
Avatar
tronron
Member
Members
Forum Posts: 21
Member Since:
August 5, 2015
sp_UserOfflineSmall Offline

I have a similar issue. I am trying to use zero crossing detection of an AC waveform to trigger a adjustable delay prior to firing a triac to control the brightness of an AC lamp. (very common technique) However, if I cannot create a delay in the interrupt service routine, I cannot accomplish this. Has anybody any ideas how to address this?

December 1, 2015
7:43 pm
Avatar
Steffan
Admin
Forum Posts: 408
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

No, you cannot use delays directly in ISRs because the delay requires an interrupt itself.  Thats a common thing with embedded systems.  Refer to here.

Alternatives:

You could not use an interrupt altogether and do your detection, processing and delay in the main loop.

You could set a flag in the interrupt and exit.  Then in the main loop check the flag and then perform your delay after detecting the flag is set.  This is a common thing to do with ISRs.

 

In general you want your ISRs to execute as fast as possible and do a very small amount of work.  Usually set a flag and exit and your main loop does the heavy lifting.

December 1, 2015
7:48 pm
Avatar
tronron
Member
Members
Forum Posts: 21
Member Since:
August 5, 2015
sp_UserOfflineSmall Offline

Thanks, Stefan. I'll try that!!!

Forum Timezone: UTC 0
Most Users Ever Online: 100
Currently Online:
16
Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
miche91: 33
scottj: 28
scadao: 23
Member Stats:
Guest Posters: 5
Members: 202
Moderators: 0
Admins: 3
Forum Stats:
Groups: 1
Forums: 2
Topics: 266
Posts: 1222
Newest Members:
pujacontrol
Administrators: geadmin: 22, filipealtoe: 96, Steffan: 356