Replies: 4 comments
-
Maybe try with a newer MicroPython. That one is four years and more than twelve releases out of date |
Beta Was this translation helpful? Give feedback.
-
This looks like the same problem I'm having. I am also trying to create a PPM stream, and have found that sometimes the frames interfere with each other. It seems to me that, despite what the documentation claims, the write_pulses command does not wait for the previous frame to complete before starting to write the next frame. This seems to happen if rmt.loop() is active or not. If the write_pulses command happens to occur while a frame is being written, it just overwrites whatever was on the end of the previous frame. I think this may be a bug. Hmmm. That was last night. Tried again this morning and nothing worked again. Must be something to do with my setup rather than blaming the chip... |
Beta Was this translation helpful? Give feedback.
-
Well, finally found my problem. My el-cheapo Chinese knock off 8 channel logic analyser that I bought on Ebay for AUD17, failed! Well, two of the channels did, channels 0 and 1 that I use all the time. By complete accident I plugged one of the leads into channel 3 instead of channel 1, and it worked! How many hours have I wasted because of that. Don't ask. What I have discovered, and I think this might explain it, is that the RMT blocks the next write_pulses command until it has completed sending the last pulse, not the last frame, as I had assumed. In this screenshot the upper trace is a write_pulses executed after a fixed time (every 100ms) so there are big gaps between frames. The lower trace is the same, but with RMT.loop() activated. So the first pulse in the upper frame (arrowed) is started at the correct time. The corresponding pulse on the lower trace (arrowed) starts slightly later, as it seems to have waited for the last pulse of the previous frame to complete, not the last frame. In the documentation is refers to the last "sequence", which I assumed to be all the pulses in the "duration" mentioned in the write_pulses() command. But that doesn't seem to be what's happening. With further experimentation I found that the best result was using a timer to trigger the write_pulses() command, with a frequency of 45. A 22.5ms frame size (which allows 8 pulses up to 2000us each plus 300us "low" pulse in between and still have a sufficiently long sync pulse at the end) which gives a frame rate of 44.4, so anything slower than 44 is going to add extra time to each frame. Interestingly, a much faster frame rate seems to make no difference to the output. Every frame is still output, so it must be doing some serious buffering somehow, or some other trickery of which I'm totally unaware. I tried it up to a frequency of 100, and same result, all frames present and correct. Hope this helps. ;-) |
Beta Was this translation helpful? Give feedback.
-
Another small fly in the ointment I've discovered. The last low pulse, the one at the end of the frame, varies. in my program all the low pulses are 300us. I had to fudge the last one though, as it always was 325us. I solved this problem by making the final pulse length 275us instead of 300us, a horrible kludge, but it worked. (as they say in the military, if it's a stupid idea but it works, it's not a stupid idea.) But that was with the board not doing anything else. So I tried putting in some long loops that did stuff that wasn't important to see if it affected the final pulse size. Well, it did. Instead of 300us, or reasonably close to it, the last pulse is now 502us. And that's with the size set to 275 in the program. For my application (R/C transmitter encoder for model aircraft) I'm hoping it won't matter much. When the receiver detects the sync pulse, it then waits for the next pulse and assumes it's the first one in the stream. I don't know how long it's prepared to wait for the next pulse, but hopefully more than 500us, or however long it takes to do the rest of the processing the chip needs to do. That'll be the next thing I have to play with. :-\ |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi. At the moment when I update the RMT frame of a certain channel, the frame temporarily expands, affecting other channels. I’m attaching a screenshot from the oscilloscope and the code.
MicroPython v1.14-73
`
from machine import Pin
import esp32
import globals
import time
from config import *
class PPM:
def init(self, rmt):
self.channels = [1500] * 8
self.FRAME_LENGTH = 20000
self.PULSE_HIGH = 400
self.MIN_SYNC = 2000
self._last_values = self.channels.copy()
rmt = esp32.RMT(0, pin=Pin(13), clock_div=80)
self.rmt = rmt
self.rmt.loop(True)
self._update_rmt()
Beta Was this translation helpful? Give feedback.
All reactions