analogWrite on ESP32 #7123
Replies: 1 comment
-
Posted at 2018-11-24 by Robin Sat 2018.11.24 Hello Ronald, What is it you are attempting to do? Please post link to tutorial/example etc so we may follow along.
Are you asking why an LED dims when controlling with an analog/PWM voltage? What does the circuit look like? Link or schematic image please Did you set Posted at 2018-11-24 by Rovale I just try to control the brightness of an LED, similar to this: https://www.arduino.cc/en/Tutorial/Fading, just basic stuff. I did not set the Oh... with LED dims I mean it turns black. And, even more surprising, after that it does not light up anymore with Posted at 2018-11-24 by Robin Ronald,
There is a current limiter of at least 220 ohm? Test the LED out of circuit with the limiter in series. As this is a non-authentic Espruino board, have you verified the pin you are on supports PWM or DAC ? Posted at 2018-11-25 by Rovale No worries, no LED are being killed here. :-) I just trying to dim an LED in the console of the the Espruino Web IDE. For what I understand GPIO26 supports DAC. https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/dac.html, correct? I just did the same on GPIO4 (a PWM output) of an ESP8266 which works as expected. Posted at 2018-11-25 by Robin
Thank goodness, wouldn't want to 'tee off' ASPCA - PITA
Does cross check with: As you have a 'Widora air' board, what does that manufacturer data sheet say? You may need their schematic to see if their GPIO DAC/PWM pin goes to which header pin. Also, Posted at 2018-11-25 by Rovale This is the board: http://wiki.widora.cn/_media/air-spec.pdf It exposes all the ESP32 pins, and also GPIO26. Did you see Posted at 2018-11-25 by Robin
No, I have no practical experience with Suggests keeping above 50Hz to avoid flicker to 'fool our senses' though. Third argument was just a thought as: doesn't specifically indicate 'Widora air' unless one has verified the 'Xtensa' chip for the ESP32 category
Posted at 2018-11-25 by Rovale Thanks for helping me think this trough and for pointing me to some remarks in the documentation. I will dive into this. In the mean time can who knows how to get DAC or PWM working on an ESP32 please elaborate a bit? Posted at 2018-11-25 by Robin Sun 2018.11.25
Google is your friend. Type your question and add the 'site:' qualifier like this:
There are more than ten supporting articles with and many others without the 'site:' qualifier Posted at 2018-11-25 by Rovale Yeah... I know how google works. Posted at 2018-11-25 by hungryforcodes Hi Rovale, analogWrite, should work on the ESP32, depending on what version you are using. I've used it a fair amount. I know in recent versions of Espruino (for various reasons -- changes in the Espressif SDK specifically), there have been a few features that are currently regressed (such as WS2812 support), on the ESP32. But I did not notice anything about the analogWrite specifically. That said, unless I am mistaken, the analogWrite is a software feature -- not a hardware one -- so its timing is not super precise (as opposed to say, if it were interrupt driven). So its possible that setting the value after the PIN parameter causes the LED to dim, due to timing issues, though I have not specifically tried to drive an LED using this feature on the ESP32. I did try using analogWrite on the ESP8266 about a year or so ago, and it usually led to LEDs having a slight dimming. Specifically I was trying to control an RGB LED (not a WS2812, but one LED with three differently colored diodes, fed by three output pins), and there were issues with color consistency and dimness which I attributed to the software implementation. My suggestion would be to use digitalWrite for off and fully on, and then analogWrite for dimming or brightening the LED in between. Unless you need a luminosity profile that is extremely precise, it should be good enough for most projects I would imagine. More info here: Posted at 2018-11-25 by Rovale Hello Patreon, Thanks for your response. The Maybe it will work in a next version, I am OK with this outcome. Posted at 2018-11-26 by @gfwilliams It looks like ESP32 has actual DAC hardware on gpio 25/26: https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/dac.html By default It's possible there is some problem with Espruino's DAC implementation - maybe the pin output mode isn't being set correctly? Posted at 2018-11-29 by Rovale Thanks for your reply. I just added an issue for this: espruino/Espruino#1574 Posted at 2018-11-30 by Robin Thr 2018.11.29 Seeking clarification from someone with ESP32 experience please. I have minimal knowledge of the ESP32 and have no practical experience using it. As a total noob, just trying to understand the event unfolding process of this thread here. Correct me if I mis-understand the following please, as I'm adding to my knowledge base: There are several individuals, whose input is used to create a port of Espruino for the ESP32 and a *few* of the *many* board possibilities are supported. Their efforts are to be commended for the resultant work that Espruino on ESP32 is what it is today. Thank you. Rovale was able to use analogWrite() successfully on a separate Xtensa board,
which doesn't appear to be a known working (tested on) board, unless one forms the opinion that any Xtensa board has to work as it is listed as an ESP32 Wikipedia also indicates 'Compact ESP32 development board' This implies to me a limited instruction set or limited hardware feature list.
As that code snippet worked on another type of ESP32 using Espruino 2v0, isn't the above statement from the filed issue, pointing the finger at the wrong culprit, e.g. isn't this a hardware issue on a non-tested, non-supported board instead? Shouldn't it state something along the line of that the issue is with a specific board manufacturer, rather than an issue with the Espruino source? Posted at 2018-11-30 by @gfwilliams ESP8266 and ESP32 are totally different chips and ports of Espruino despite using the same Architecture. Much like nRF52 and STM32. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2018-11-24 by Rovale
Hello,
I just tried to perform
analogWrite
on a Widora air and it looks like it's not supported. Or is it something I am doing wrong?Regards,
Ronald
Beta Was this translation helpful? Give feedback.
All reactions