Long pulse accurrancy

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
ewaldharmsen
Normal user
Posts: 66
Joined: 16 Feb 2017, 09:23

Long pulse accurrancy

#1 Post by ewaldharmsen » 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?

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Long pulse accurrancy

#2 Post by grovkillen » 22 Jun 2017, 08:24

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
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

Martinus

Re: Long pulse accurrancy

#3 Post by Martinus » 22 Jun 2017, 18:53

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)

ewaldharmsen
Normal user
Posts: 66
Joined: 16 Feb 2017, 09:23

Re: Long pulse accurrancy

#4 Post by ewaldharmsen » 23 Jun 2017, 13:19

Thanks all!

I am using normal pulse now, that seems to work better. Problem solved

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: Long pulse accurrancy

#5 Post by toffel969 » 27 Jun 2017, 14:11

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
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

ewaldharmsen
Normal user
Posts: 66
Joined: 16 Feb 2017, 09:23

Re: Long pulse accurrancy

#6 Post by ewaldharmsen » 13 Sep 2017, 14:11

clear explanation, thanks!

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 22 guests