hello,
i have built a safety light curtain and i want to build a counter to store the times that the laser pointer was triggered.
how can I realize this function ?
any advice ?
Jian
how to build a counter for the laser pointer when the laser pointer was triggered ?
Re: how to build a counter for the laser pointer when the laser pointer was triggered ?
The simplest is to use a non-threaded child script for that. In the sensing section, read your proximity sensor with
Cheers
sim.readProximitySensor
. Compare the detection value with the value read in previous simulation step. If the value goes from no detection to detection, then increment your counter.Cheers
Re: how to build a counter for the laser pointer when the laser pointer was triggered ?
hello,
how can I know the detection status of no detection and detection?
and can i read the value of the previous simulation step?
thank you in advance.
Jian
how can I know the detection status of no detection and detection?
and can i read the value of the previous simulation step?
thank you in advance.
Jian
Re: how to build a counter for the laser pointer when the laser pointer was triggered ?
sim.readProximitySensor
Before storing the result in a variable, that variable will contain the result of the previous simulation step.
E.g.:
Code: Select all
function sysCall_sensing()
result,d,p,h,n=sim.readProximitySensor(sensorHandle)
if oldresult==0 and result==1 then
-- do something
end
oldresult=result
end
Re: how to build a counter for the laser pointer when the laser pointer was triggered ?
I understand, thank you so much.