analogWrite with frequency on NodeMCU / ESP8266 #5874
Replies: 1 comment
-
Posted at 2016-08-23 by @gfwilliams Yeah, the problem is that on ESP8266 there is no hardware PWM as far as I know. There is a hardware timer, but to make a pin change state you still need to do it using software. It means that realistically, reliable 38kHz soft PWM isn't an option right now. Someone could write some IR transmitter code in C, and then call it from JS like is done with the Neopixels, but it's a bit of a faff. Even with that, you can't transmit for too long or you'll interfere with WiFi/trigger the watchdog timer. The more sensible option is to use a microcontroller with hardware PWM on it, like the Espruino boards. I'll be releasing one with WiFi on soon now - I have hardware, there are just some software issues to sort out before I do a release. Posted at 2016-08-23 by davdev Thanks for the quick reply, although that's a bit of a letdown, your announcement sounds promising ;) Posted at 2017-02-26 by navas Hey @gfwilliams, is there any update yet? AnalogWrite for 38Khz is feasible in ESP8266? Thanks Posted at 2017-02-27 by @gfwilliams It looked like there was a way to call code from IRQ but nobody has put any work into it as far as I know. Also - on ESP8266, digitalPulse is a bit of a hack - it's synchronous, whereas the 'proper' one is async. Actually getting that working properly for ESP8266 could end up being a nightmare - as I guess you want to use this for IR. You may:
Posted at 2017-04-18 by stephaneAG Hi Posted at 2017-09-28 by opichals I have tried the IR receive stuff with the d1 mini (esp8266) and if my math is correct I am getting codes sometimes as long as 50ms. So if I wanted to simply retransmit using the tight loop digitalPulse() esp8266 port sw implementation it would take too long and the watchdog would reset the board before finishing. So your option 2 from above @gfwilliams doesn't seem feasible. Am I missing something there? On the other hand @gfwilliams's espruino/Espruino#1175 (comment) comment gives hope in avoiding to go with some sort of ne555-based 38kHz oscillator or something. I wouldn't really think of it if it were just for the IR emission but it sounds like using the timer handling present in custom pwm code would make the esp8266 port way more usable compared to the current state. I personally would be very interested but I guess lack knowledge and instrumentation. Perhaps somebody could give it a shot? @gfwilliams? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2016-08-23 by davdev
Hey folks,
I have just received two NodeMCU boards and thanks to all the tutorials and great resources getting started with Espruino was a piece of cake - thank all of you for your efforts!
I've managed to read IR codes sent out by various remotes using the IRReceiver module and I would like to replay them using the board and an IR LED.
Unfortunately, however, (as it seems to me) I haven't been able to do so using
analogWrite
with a 38kHz frequency anddigitalPulse
. If I understand correctly, this is due to the lack of PWM support in Espruino for ESP8266, am I right? Although I've been using platforms like the Raspberry Pi etc. for several years, I'm quite new to the "low level stuff" and I'd just like to know, whether I got my head around this correctly.I guess due to Javascript's event loop nature and the required accuracy a pure JS implementation is not feasible, right?
Possibly related (?): PWM? Anyone ever get it working? Even via peek/poke directly at control registers?
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions