This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Sending short pulses on LM outputs
#1
Hello,
I have a door lock with input which is supposed to be connected to a door unlocking push-button. It expects short pulses generated by pushing and releasing of the button.

I would like to instead connect this input to one of the LM outputs and control the door lock from there. I can probably figure out the circuitry needed for this, however I am not sure how to best simulate the short pulses on the LM side.

I found a Java Script here on the forum which automatically reverts value of an object after certain period of time, however it relies on a resident script and I am not sure if it is feasible for the very short times I have in mind (50-100ms). I just checked and the minimal sleep interval for resident scripts is 1s which is too much.

Any suggestions how to best achieve this?
Reply
#2
Create a virtual object and map an event script to it which will write to the real output.
Code:
grp.write('1/1/1', true, dt.bool)
sleep(0.1)
grp.write('1/1/1', false, dt.bool)
Reply
#3
Thanks, however I understand sleep() is blocking, right? So all (event?) script execution is paused while the sleep is running. I was reluctant to use sleep for this reason.
Reply
#4
It only blocks the script itself, the whole device continues normal operation.
Reply
#5
Alright, I am confused. Smile

User manual, page 89:
Quote:Note! All event-based scripts are executed in a single queue-like manner. Make sure event scripts do not contain infinite loops, sleep calls or other blocking parts.
Reply
#6
Such small delays are ok
Reply
#7
OK, thinking about it a bit more I kind of came to the same conclusion. I'll use the event script with sleep() and try to keep in mind other event scripts could be delayed a bit. Thanks.
Reply
#8
Other scripts are not affected, because each script runs as a separate OS process
Reply
#9
(10.10.2018, 13:45)Fadmin Wrote: Such small delays are ok

Could you explain this mechanism? I thinked that it mean that I shouldn’t use sleep function with a big duration because every further instance of this script will be blocked or 2 same instances could work paralel.
Done is better than perfect
Reply
#10
Yes, having large delays can cause undefined behavior due to several scripts running in parallel. In worse case LM can reboot due to out of memory condition when there are hundreds of scripts running at once.
Reply
#11
(10.10.2018, 13:59)admin Wrote: Other scripts are not affected, because each script runs as a separate OS process

Is that true? I am asking because it directly contradicts what is written in the user manual, see my quote above. Perhaps the user manual needs to be updated?
Reply
#12
True, documentation is wrong on this point
Reply


Forum Jump: