Page 1 of 1
Long pulse accurrancy
Posted: 22 Jun 2017, 08:07
by ewaldharmsen
I am on 147 RC8.
I use a sonoff 4CH device to control my sunscreen.
I use longpulse for it.
However it seems to be not very accurate.
When I send /control?cmd=LongPulse,15,1,1 it runs for 2.3 seconds
When i send a longpulse of 5, it runs for 5.5 seconds.
Is there a way to make a long pulse of 1 second really 1 second?
Re: Long pulse accurrancy
Posted: 22 Jun 2017, 08:24
by grovkillen
I don't know the behind the scenes code that is handling this but you could try to use rules instead.
Code: Select all
On 1secondPulse do
gpio,12,1
timerSet,1,1 //timer 1 set for 1 second
endon
On 5secondPulse do
gpio,12,1
timerSet,1,5 //timer 1 set to 5 seconds
endon
On Rules#Timer=1 do
gpio,12,0
endOn
Trigger through:
http://<espeasyip>/control?cmd=event,1secondPulse
http://<espeasyip>/control?cmd=event,5secondPulse
Re: Long pulse accurrancy
Posted: 22 Jun 2017, 18:53
by Martinus
ewaldharmsen wrote: ↑22 Jun 2017, 08:07
I am on 147 RC8.
I use a sonoff 4CH device to control my sunscreen.
I use longpulse for it.
However it seems to be not very accurate.
When I send /control?cmd=LongPulse,15,1,1 it runs for 2.3 seconds
When i send a longpulse of 5, it runs for 5.5 seconds.
Is there a way to make a long pulse of 1 second really 1 second?
1 second should be considered short here. So better use the normal pulse command if you need this level of accuracy.
(Longpulses are timed in background and with single threaded processing this can be inaccurate, unless it's build with hardware timers and interrupts)
Re: Long pulse accurrancy
Posted: 23 Jun 2017, 13:19
by ewaldharmsen
Thanks all!
I am using normal pulse now, that seems to work better. Problem solved
Re: Long pulse accurrancy
Posted: 27 Jun 2017, 14:11
by toffel969
ewaldharmsen wrote: ↑23 Jun 2017, 13:19
Thanks all!
I am using normal pulse now, that seems to work better. Problem solved
Yes normal pulse is much better for accurate timing. The reason for that accuracy is also the biggest downside of normal pulse: it blocks the ESP --> rules and webinterface do not respond in that time. AFAIK even the Timers in Rules get delayed. So its your choice: accurate but blocking, or less accurate and non-blocking
Re: Long pulse accurrancy
Posted: 13 Sep 2017, 14:11
by ewaldharmsen
clear explanation, thanks!