Logic Machine Forum
Sending short pulses on LM outputs - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Hardware (https://forum.logicmachine.net/forumdisplay.php?fid=12)
+--- Thread: Sending short pulses on LM outputs (/showthread.php?tid=1642)



Sending short pulses on LM outputs - Regis - 10.10.2018

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?


RE: Sending short pulses on LM outputs - admin - 10.10.2018

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)



RE: Sending short pulses on LM outputs - Regis - 10.10.2018

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.


RE: Sending short pulses on LM outputs - admin - 10.10.2018

It only blocks the script itself, the whole device continues normal operation.


RE: Sending short pulses on LM outputs - Regis - 10.10.2018

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.



RE: Sending short pulses on LM outputs - admin - 10.10.2018

Such small delays are ok


RE: Sending short pulses on LM outputs - Regis - 10.10.2018

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.


RE: Sending short pulses on LM outputs - admin - 10.10.2018

Other scripts are not affected, because each script runs as a separate OS process


RE: Sending short pulses on LM outputs - buuuudzik - 10.10.2018

(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.


RE: Sending short pulses on LM outputs - admin - 10.10.2018

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.


RE: Sending short pulses on LM outputs - Regis - 10.10.2018

(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?


RE: Sending short pulses on LM outputs - admin - 10.10.2018

True, documentation is wrong on this point