One of the classes that I’m in this term is an introduction to Python, so I figured that I’d give MicroPython a shot. I have a LoLin branded NodeMCU v3 kicking around, and have done a little bit of messing around with it. Tonight, I figured that I’d try out the PWM on the NodeMCU and check its performance on the shiny new o-scope.
This is the 50% duty cycle. The NodeMCU has an ESP8266 MCU, and it’s PWM is based on a 1KHz frequency divided into 1024 segments that define the duty cycle with 512 being 50%. You can tell that the floor is noisier than the ceiling, and you can also see the voltage jiggle at the top and bottom of the pulse.
This is zoomed in on the rising edge. It looks like about a 6 or 7 ns rise with a 37 ns jiggle afterwards.
The falling edge looks to be about the same, but the exact timing of the fall varies by quite a bit.
I tried to look at duty(1) and duty(1023), but those just showed up on the scope as LO and HIGH, respectively. I don’t think it is a problem with the scope not being able to resolve pulses that slew from 0V to 3V3 that quickly, but I’ll have to test with a couple of other MCUs to be sure. At the moment, I’m operating on the hypothesis that the chip can’t handle it.
Those little blips are duty(2), so it should be roughly 0.2% duty cycle. The scope reports it as about 0.4%, but again, I think that it could be something with the chip. As soon as I get more data, I’ll post it.
This is zoomed in quite a bit on the duty(2) pulse. There seems to be a lot of jitter on the falling edge, which seems to be normal with this chip. I think that is what is causing the varied reading for the duty cycle on the low end.
This is the opposite, duty(1022), which should be 99.8%. The reading of 99.5% is close enough, I suppose.
This is zoomed in on the dip in duty(1022), and again the falling edge is really ragged. I definitely need to find out if this is normal, or particular to the ESP8266. I’d also like to find out if this is something based in the firmware for the chip or is hardware based. I’ll post a follow up once I find out.