Page 1 of 1

PWM and ESP32

Posted: Mon Sep 20, 2021 9:07 am
by jollybv
Hi Guys
I am trying to get the PWM to work on the NODEMCU ESP-32 board. I'm using the GPIO32 port B0 pin 7 but nothing is happening, I'm not sure if I have not set something up correctly but everything seems to be write. I am calling the GetTemp macro using the read max6675 branch then going to the ProcessPID where I do the processing then output to the PWM which is not working. I have also put the PWM enable at the beginning of the program otherwise I get this error [0;31mE (5714) MCPWM: mcpwm_set_duty(203): MCPWM DRIVER NOT INITIALIZED[0m so not sure what is the problem

Example_PID_max6675.fcfx
(43.25 KiB) Downloaded 132 times

Re: PWM and ESP32

Posted: Mon Sep 20, 2021 5:01 pm
by BenR
Hello,

You might want to check that the pwm period property is set correctly, there was a bug where is was being reset to 181 which has recently been solved.

I think you also need to call the SetDutyCycle10Bit function instead of the SetDutyCycle function on the ESP32 device.

Re: PWM and ESP32

Posted: Wed Sep 22, 2021 7:28 am
by jollybv
Hi Ben

Thanks that worked, what would you suggest that the frequency and period be set to, to control an element? also I would like to control the system from my phone using the blink app how do I send the temperature value over the WiFi is there any tutorials or examples on how to do this.

Re: PWM and ESP32

Posted: Wed Sep 22, 2021 12:49 pm
by BenR
Hello,

I think it depends largely on the inductace of the element you're driving. I've read that driving DC motors with frequencies over 10KHz just ends up heating up the motor/driver and drops efficiency levels. This puts it in the audio range so you might need to make sure that the frequency you choose isn't going to cause any annoying vibrations/sounds to be generated. Maybe go up to 15 or 20KHz if this becomes a problem. The driver you use may also set the frequency range that is available to you. Some of our high ampage motor drivers have a max frequency input of 10KHz and so we drive them around 7KHz as the maths works out nicely around there.

Choose a duty that gives you a nice degree of control, we went with full 16-bit to allow for good sine wave representations but again this is dictated by your application and how finely you need to be able to adjust the output. On a control system using PID you probably want a fair amount of control but temperature is often slow to respond and so this may allow you to get away with much coarser control values. Ovens for example just use On/Off control.

As for sending over Wifi, I don't have any experience with the Blink app but I am guessing it's a fairly closed and encrypted system and so tapping into that might be tricky to impossible without a good knowledge of hacking or their protocol. What would be much easier is to use a system like Modbus TCP or MQTT or simple HTTP. There should be some nice examples out there for each of these but shout if your struggling to find what you need or need a more tailored example. Another option might be if Blink works with ITTT as that could be a means of navigating their protocol and converting it into something you can use.

Re: PWM and ESP32

Posted: Thu Sep 23, 2021 9:22 am
by jollybv
Hi Ben

Thanks, looks like I did not spell the "Blynk" platform correctly seems to work off Arduino IDE.
https://blynk.io/en/getting-started
Not sure if it is comparable with Flowcode but there pricing is quite high if you want to do anything meaningful. I know App Developer runs on desktop will it run on a mobile phone?

Re: PWM and ESP32

Posted: Thu Sep 23, 2021 9:29 am
by BenR
Aha ok thanks I'll look again at Blynk and see what we can do there :P It looks a bit like app developer aimed specifically at IoT so there is promise there.

We are currently looking into things like Azure which would allow the Flowcode app to be run in the cloud and then accessed via a mobile phone.

Re: PWM and ESP32

Posted: Thu Sep 23, 2021 10:44 am
by jollybv
Great let me get app developer and get the project working on the PC so long then wait and see what happens with the cloud.

Re: PWM and ESP32

Posted: Mon Feb 06, 2023 11:32 am
by jollybv
Hi Guys

Has there been any progress in getting Blynk to run with flowcode yet