Page 1 of 1
how to build a counter for the laser pointer when the laser pointer was triggered ?
Posted: 21 Nov 2019, 14:34
by jianye
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
Re: how to build a counter for the laser pointer when the laser pointer was triggered ?
Posted: 27 Nov 2019, 14:06
by coppelia
The simplest is to use a
non-threaded child script for that. In the sensing section, read your proximity sensor with
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 ?
Posted: 28 Nov 2019, 21:42
by jianye
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
Re: how to build a counter for the laser pointer when the laser pointer was triggered ?
Posted: 29 Nov 2019, 08:59
by fferri
jianye wrote: ↑28 Nov 2019, 21:42
hello,
how can I know the detection status of
no detection and
detection?
sim.readProximitySensor
jianye wrote: ↑28 Nov 2019, 21:42
and can i read the value of the previous simulation step?
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 ?
Posted: 29 Nov 2019, 16:34
by jianye
I understand, thank you so much.