Get PWM value in any way
Moderators: grovkillen, Stuntteam, TD-er
-
- New user
- Posts: 6
- Joined: 27 Aug 2019, 19:24
Get PWM value in any way
Hi,
is it possible to get the current PWM status in the version 20190817? I need it for fhem. In some early versions it was in the state variable but now there is only 0,1,-1 and sometimes -2.
Where can I change the source code to get the value? I changed the code on my own and tried to modify the globalMapPortStatus directly or with the function savePortStatus. I prepared a struct which has the PWM value in the state and the output variable, but it doesnt work. I also changed the type of state to uint16_t like in the older versions.
Thanks
is it possible to get the current PWM status in the version 20190817? I need it for fhem. In some early versions it was in the state variable but now there is only 0,1,-1 and sometimes -2.
Where can I change the source code to get the value? I changed the code on my own and tried to modify the globalMapPortStatus directly or with the function savePortStatus. I prepared a struct which has the PWM value in the state and the output variable, but it doesnt work. I also changed the type of state to uint16_t like in the older versions.
Thanks
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Get PWM value in any way
I use a custom event and send the wanted value, which I store as in internal variable as well as setting the pwm.
So conclusion, you cannot get the value any other way currently.
So conclusion, you cannot get the value any other way currently.
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
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
-
- New user
- Posts: 6
- Joined: 27 Aug 2019, 19:24
Re: Get PWM value in any way
Good evening,
thank you for the fast answering. Can you explain the custom event and how to use it?
thank you for the fast answering. Can you explain the custom event and how to use it?
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Get PWM value in any way
Using rules you create an event using the event command.
https://espeasy.readthedocs.io/en/lates ... Rules.html
https://espeasy.readthedocs.io/en/lates ... Rules.html
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
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
-
- New user
- Posts: 6
- Joined: 27 Aug 2019, 19:24
Re: Get PWM value in any way
Ah ok, I thought you talked about something in the code, because of the internal variable. I will try it. Thank you!
Re: Get PWM value in any way
How to store adn read PWM to/from Dummy values?
I read this but can`t understand syntax. What exactly used here and what not
I read this but can`t understand syntax. What exactly used here and what not
Also where i can find plugin and pluginid?For any plugin that registers the used pin(s), the last set pin state can be retrieved, either regular pin state or PWM state, by using this syntax: [Plugin#<pluginId>#Pinstate#N]
Re: Get PWM value in any way
See the documentation on referring to the pinstate of a specific pin:
https://espeasy.readthedocs.io/en/lates ... task-names
And some example here: https://espeasy.readthedocs.io/en/lates ... tem-events
You need to scroll to the "Matching events" section as the example is at the end of the section above it.
https://espeasy.readthedocs.io/en/lates ... task-names
And some example here: https://espeasy.readthedocs.io/en/lates ... tem-events
You need to scroll to the "Matching events" section as the example is at the end of the section above it.
Re: Get PWM value in any way
To put a value in a dummy device use taskvalueset:
https://espeasy.readthedocs.io/en/lates ... skvalueset
The pwm value you would get with:
Code: Select all
[Plugin#GPIO#Pinstate#12]
As also discussed here: viewtopic.php?t=9801
So to write to a dummy device simply use:
Code: Select all
TaskValueSet,<name_of_dummy_device,<value_name>,[Plugin#GPIO#Pinstate#12]
Code: Select all
[<name_of_dummy_device>#<value_name>]
Code: Select all
LogEntry,'[MyDummy#MyValue]'
Re: Get PWM value in any way
This is what i can`t understand) I though should use "status,g,5" in command line or something! Thanks a lot. I have PWM fan and wanted to store and restore the last duty.
Re: Get PWM value in any way
Stil can`t get success.
I wrote 3 rules
1st for restore the last PWM value:
2nd for triggering pwm:
3rd when the PWM changing duty this should store in memory last value:
When i push the button with this code
fan start spining at max speed and should store this value in Dummy device, but it`s empty.
I wrote 3 rules
1st for restore the last PWM value:
Code: Select all
on System#Boot do
PWM,5,[TestMemory#Dummy]
endon
Code: Select all
on pwm do
PWM,5,%eventvalue1%
//Publish %sysname%/GPIO/GPIO5,[Plugin#GPIO#Pinstate#5]
endon
Code: Select all
on pwm#state do
TaskValueSet,TestMemory,Dummy,[Plugin#GPIO#Pinstate#5]
endon
Code: Select all
http://192.168.0.123/control?cmd=event,PWM=1023
Re: Get PWM value in any way
I guess this is not working because the PWM#State is still 0 and did`t change value when u call it via http. This is why taskvalueset wont work. I could see changes in logs but i dunno.
Re: Get PWM value in any way
Maybe, because evantname and command are the same !?
Re: Get PWM value in any way
When in doubt whether events are handled and if so with which eventvalues, you can always use "logEntry" to create logs.
And please note that rules parsing ends when a matching event is found.
So if "on pwm do" is before "on pwm#state do", the latter one may not be processed. (not 100% sure this is the correct example, but you get the idea)
Code: Select all
on pwm do
PWM,5,%eventvalue1%
//Publish %sysname%/GPIO/GPIO5,[Plugin#GPIO#Pinstate#5]
logentry,"On pwm Do: EventValue: %eventvalue1% PinState: [Plugin#GPIO#Pinstate#5]"
endon
So if "on pwm do" is before "on pwm#state do", the latter one may not be processed. (not 100% sure this is the correct example, but you get the idea)
Re: Get PWM value in any way
Why not combining these two?
Like:
Code: Select all
On pwm Do
PWM,5,%eventvalue1%
TaskValueSet,TestMemory,Dummy,%eventvalue1%
//Publish %sysname%/GPIO/GPIO5,%eventvalue1%
Endon
Last edited by chromo23 on 07 Sep 2023, 09:35, edited 1 time in total.
Re: Get PWM value in any way
it`s working. YAASS))chromo23 wrote: ↑07 Sep 2023, 09:12Why not combining these two?
Like:Code: Select all
On pwm Do PWM,5,%eventvalue1% TaskValueSet,TestMemory,Dummy,%eventvalue1% //Publish %sysname%/GPIO/GPIO5,%eventvalue1% Endon
Td-er was right, i guess there problem was in sequence.
Thank You all for help!
- Attachments
-
- Image.jpg (16.73 KiB) Viewed 2564 times
Who is online
Users browsing this forum: No registered users and 89 guests