LongPulse_mS vs Pulse

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
hestia
Normal user
Posts: 90
Joined: 06 Mar 2021, 08:27
Location: Paris

LongPulse_mS vs Pulse

#1 Post by hestia » 03 Jul 2021, 23:23

in https://espeasy.readthedocs.io I've read that
LongPulse_mS :
A long pulse is basically the same as the plain pulse. Duration is defined in seconds, which makes it more suitable for longer duration.
Pulse:
this is a blocking call, meaning no other actions will be performed during the pulse.
Question about <<no other actions will be performed during the pulse>> - no other actions in all the ESP or only in the sequence of the pulse?
For instance, if I do

Code: Select all

Pulse, 13,0,250
Pulse, 13,1,250
Pulse, 13,0,250
Pulse, 13,1,250
Nothing else could happen during 1 second in all the ESP?
Is it a good way to bling a LED?
On the other hand I could not do it with LongPulse_mS

Code: Select all

LongPulse_mS , 13,0,250
LongPulse_mS , 13,1,250
LongPulse_mS , 13,0,250
LongPulse_mS , 13,1,250
because all events are sent at the same time.
So, how to blink fast?

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: LongPulse_mS vs Pulse

#2 Post by ThomasB » 04 Jul 2021, 00:11

So, how to blink fast?
Based on your examples, I suggest using the Notify-Chiming plugin available in mega's TESTING release.

Basic Installation as follows:
1. Install the Notify-Chiming plugin.
2. Select the Enable box.
3. Select the Actuator Inversed Logic box.
4. Enter your GPIO-13 pin in the GPIO → Driver#1 entry.
5. Set Chiming/Strike Time to 250ms.
6. Set Normal Pause Time to 250mS.

Your double blink "Pulse" code from your rule example looked like this:

Code: Select all

Pulse, 13,0,250
Pulse, 13,1,250
Pulse, 13,0,250
Pulse, 13,1,250
But now you will use non-blocking rule code like this to blink twice:

Code: Select all

chime,11
If you want to blink five times then do this:

Code: Select all

chime,11111
Other blink patterns are possible. Details are here: https://github.com/letscontrolit/ESPEas ... ng.ino#L12

- Thomas

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: LongPulse_mS vs Pulse

#3 Post by TD-er » 04 Jul 2021, 10:25

I think the PWM command may also be useful here.
The PWM command is only given once and being executed in the background without the need to process events or rules.

See: https://espeasy.readthedocs.io/en/lates ... ernal-gpio
The pwm command can accept a frequency parameter too , but sadly it also needs a duration which you don't need.
The duration is a fade from one duty cycle to another (to fade lights), but this is blocking code so don't use it continuously.
What you can do however is call it once with a frequency and a very short fade.
Then the frequency is set and you can then call the PWM to start blinking (e.g. 50% duty cycle at 10Hz) without the need to process rules at 10x a second, which is a burden on the ESP.

hestia
Normal user
Posts: 90
Joined: 06 Mar 2021, 08:27
Location: Paris

Re: LongPulse_mS vs Pulse

#4 Post by hestia » 04 Jul 2021, 15:32

thanks both of you
I'd rather not to install any plugin if possible , so I've tried the PWM
with no success :-(
I've tried several codes around

Code: Select all

on Rules#Timer=4 do
	timerSet,4,1
	//PWM,13,0,1000,10
	PWM,13,0
endon

on System#Boot do
  timerSet,4,1
  PWM,13,0,1,10 // init the frequency
endon
with no blink at the end!

hestia
Normal user
Posts: 90
Joined: 06 Mar 2021, 08:27
Location: Paris

Re: LongPulse_mS vs Pulse

#5 Post by hestia » 04 Jul 2021, 16:24

Basic Installation as follows:
1. Install the Notify-Chiming plugin.
I did find how to install a plugin :-(
Possible OTA? I have a Sonoff 4CH R3

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: LongPulse_mS vs Pulse

#6 Post by ThomasB » 04 Jul 2021, 20:02

I did find how to install a plugin :-(
Possible OTA? I have a Sonoff 4CH R3
This plugin is in the Mega [Testing] builds. To get it you need to reflash with a ESPEasy Mega TESTING release that is compatible with your device.

- Thomas

hestia
Normal user
Posts: 90
Joined: 06 Mar 2021, 08:27
Location: Paris

Re: LongPulse_mS vs Pulse

#7 Post by hestia » 04 Jul 2021, 20:10

thanks Thomas
I'm not willing to flash my Sonoff because I'll need to put it off the wall and reopen it. I think I'm at the end of the testing and I don't want to break everything.
I'll try PWM if I can get some progress

Post Reply

Who is online

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