Control multiple device using Timer
Control multiple device using Timer
Hello ,
I have connected the IO expander (PI4IOE5V96248) with the ESP32 s3 by using the I2C protocol, and I have generated a pwm signal on the IO expander, but I cannot control the multiple devices at the same time. If I am on any bulb, and at the same time, if I am on another device, let’s say another bulb, then the first device is turned off and the new device is turned on.
So, how can I do that by using ESP32 Timer and one more thing I have 10 devices for the application.
Thank you
I have connected the IO expander (PI4IOE5V96248) with the ESP32 s3 by using the I2C protocol, and I have generated a pwm signal on the IO expander, but I cannot control the multiple devices at the same time. If I am on any bulb, and at the same time, if I am on another device, let’s say another bulb, then the first device is turned off and the new device is turned on.
So, how can I do that by using ESP32 Timer and one more thing I have 10 devices for the application.
Thank you
-
- Posts: 9739
- Joined: Thu Nov 26, 2015 4:08 am
Re: Control multiple device using Timer
Your code probably has a bug. Suggest you post that, at the very least; we don't have a crystal ball and as such can't divine what's wrong with your setup without it.
Re: Control multiple device using Timer
This is my files for project...
Thank you
Thank you
- Attachments
-
- esp32idfDimmer.c
- (10.22 KiB) Downloaded 201 times
-
- main.c
- (8.42 KiB) Downloaded 211 times
-
- PI4IOE5V96248.c
- (4.74 KiB) Downloaded 186 times
-
- Posts: 9739
- Joined: Thu Nov 26, 2015 4:08 am
Re: Control multiple device using Timer
Question for you: How is the code supposed to remember the PWM value for channels other than the latest? Does it store that anywhere?
Re: Control multiple device using Timer
Yes this is stored in Power_buffer ,which is shown in main file I have attached
see this file please
thank you
see this file please
thank you
- Attachments
-
- main.c
- (9.66 KiB) Downloaded 480 times
-
- Posts: 9739
- Joined: Thu Nov 26, 2015 4:08 am
Re: Control multiple device using Timer
Okay. That is an entirely different version of the code than you attached previously. Sorry, but I'm not gonna help you debug a moving target.
I'm not gonna lie: your code is a bit of a mess and it's a bit hard to figure out what you *intend* it to do, rather than what it actually does. What I'd suggest you should do is to write out the architecture, as in how you envision it should work, somewhere. What are the interactions, what happens after what, which variables are involved etc. Then check if the code actually does that. For instance, I imagine that something is supposed to take ProcessSignal_on while another thing is supposed to give that semaphore. What actually does do the taking and what actually does do the giving in your code?
I'm not gonna lie: your code is a bit of a mess and it's a bit hard to figure out what you *intend* it to do, rather than what it actually does. What I'd suggest you should do is to write out the architecture, as in how you envision it should work, somewhere. What are the interactions, what happens after what, which variables are involved etc. Then check if the code actually does that. For instance, I imagine that something is supposed to take ProcessSignal_on while another thing is supposed to give that semaphore. What actually does do the taking and what actually does do the giving in your code?
Re: Control multiple device using Timer
I will tell you all those things Firstly, I received channel and power from the UART (task) .After receive the channel and power I will change in the channel_buffer array which is initially -1 and call the Power function, in this I set the power with the respective channel by using the SetPower function. another thing I attached the ZCD with my controller so every Zero crossing It it generate the Interrupt and at that time I am doing Semaphore as a pdTrue (this thing is in esp32idfDimmer.c file) . Well in the main file when the Semaphore is taken by ProccessSignal_on and ProccessSignal_off Function I just doing HIGH and LOW by using writepin function which is basically set and Reset the IO expander Pin . but what happened is that When I turn on the 1st device with power let say 2 and at the same time If I turn on 2nd Device with another power then It is not happening (Like transfer the present Power to the all the Device).ESP_Sprite wrote: ↑Tue Sep 05, 2023 4:07 amOkay. That is an entirely different version of the code than you attached previously. Sorry, but I'm not gonna help you debug a moving target.
I'm not gonna lie: your code is a bit of a mess and it's a bit hard to figure out what you *intend* it to do, rather than what it actually does. What I'd suggest you should do is to write out the architecture, as in how you envision it should work, somewhere. What are the interactions, what happens after what, which variables are involved etc. Then check if the code actually does that. For instance, I imagine that something is supposed to take ProcessSignal_on while another thing is supposed to give that semaphore. What actually does do the taking and what actually does do the giving in your code?
So can I do this thing By using the Timer (esp_timer_start_periodic();) this API ? should I create 10 timer for each Channel ?and It is possible or not ?
thank you
-
- Posts: 9739
- Joined: Thu Nov 26, 2015 4:08 am
Re: Control multiple device using Timer
Okay, gotcha. So you're not trying to generate a PWM signal per se (which would be free-running), you're tyring to do phase control dimming (which is synced to the zero-crossing).
Yes, you could use ten ESP_Timers to do this. Note that your software can only process one timer at a time, though, so if multiple timers fire at or around the same time, they will still processed after eachother, meaning some will 'lag' a bit. If this lag is acceptable depends on your application, obviously.
Yes, you could use ten ESP_Timers to do this. Note that your software can only process one timer at a time, though, so if multiple timers fire at or around the same time, they will still processed after eachother, meaning some will 'lag' a bit. If this lag is acceptable depends on your application, obviously.
Re: Control multiple device using Timer
Okay thank you !
One more thing how can I handle this I mean when Zero crossing Detector detect the Zero at that time I call the semaphore and Semaphore is taken by my task so can you please tell me that where I can Start my Timer of specific channel and Where I can Stop my timer ?
Thank you
One more thing how can I handle this I mean when Zero crossing Detector detect the Zero at that time I call the semaphore and Semaphore is taken by my task so can you please tell me that where I can Start my Timer of specific channel and Where I can Stop my timer ?
Thank you
Re: Control multiple device using Timer
I can not call esp_timer_start_periodic(); function in my Task So where It will be called?ESP_Sprite wrote: ↑Tue Sep 05, 2023 6:24 amOkay, gotcha. So you're not trying to generate a PWM signal per se (which would be free-running), you're tyring to do phase control dimming (which is synced to the zero-crossing).
Yes, you could use ten ESP_Timers to do this. Note that your software can only process one timer at a time, though, so if multiple timers fire at or around the same time, they will still processed after eachother, meaning some will 'lag' a bit. If this lag is acceptable depends on your application, obviously.
Who is online
Users browsing this forum: No registered users and 122 guests