node-red-nodes
node-red-nodes copied to clipboard
Add field to set different trigger pulse time
The JSN-SR04T uses a different trigger pulse time (20uS) than the als HC-SR04 (I guess 10uS ?!). Could you please let the user adjust the trigger pulse time in the node-red PI-SRF node?
Which node are you reporting an issue on?
node-red-node-pisrf
What are the steps to reproduce?
What happens?
Measurement seems to be unstable. The documentation of the JSN-SR04T says that the trigger time set to 20uS could stabilize that: https://protosupplies.com/product/jsn-sr04t-v3-0-waterproof-ultrasonic-range-finder/
What do you expect to happen?
Better, stable measures
Please tell us about your environment:
- [ ] Node-RED version: 3.0.1
- [ ] node.js version: 14.17.3
- [ ] npm version: 6.14.13
- [ ] Platform/OS: Rpi
- [ ] Browser: Firefox/Chrome
can you try editing line 32 of file nrsrf.py
time.sleep(0.00001)
to see if indeed it does stabilise things for you ?
Just tried it out: with 10uS: 139.7, 140.5, 139.3, 140.7, 227.2, 136.8, 138.8, 137.7, 137.8, 138.5, 139.1, 139.9 Std deviation: 25.492791613364 Mean, x̄: | 146.33333333333 Variance, s2: | 649.88242424242
with 20uS: 137.7, 138.0, 137.5, 139.4, 136.8, 136.6, 138.3, 138.9, 137.4, 138.7, 140.7, 139.2, 234.2 Std deviation: 26.631110109063 Mean, x̄: | 145.64615384615 Variance, s2: | 709.21602564103
Tried it also with 25uS but the measurement were far worse somehow. Unsure if this also is a problem of an unstable 5V connection on my side. Still I think it would be good to have it configurable as the docs say:
- When using in the default Ping mode of operation, the JSN-SR04T is completely software compatible with the HC-SR04 EXCEPT that the trigger must be held high for 20uS rather than the standard 10uS or else there will be numerous erroneous readings.
So both the std deviation and variance are worse with 20 uS ? Not sure that is a good argument for a change to be honest. I can't see "numerous erroneous readings" so I'm not sure what real benefit we would be giving the user.
I totally understand what you mean. Still I think that my measurements and my use case are not the ideal values to compare these different trigger timings. The code does not break if you keep the default value at 10uS. But could you still make it an adjustable value?