Jitter / Latency in DIO Outputs
Posted: 27 Oct 2021, 15:38
Hello everyone,
I am using a RevPi Core 3+ with a MIO module and I am trying a simple test application with 7 segment LED (like this https://raspi.tv/wp-content/uploads/201 ... up_700.jpg)
Basically I want to display multiplexed 7 segment LED but switching them alternatively every 5ms. The problem is that I have a lot of jitter (up to 15ms!).
So I did a very simple program in Go and the same with Python (pseudo-code):
while True:
output(1, True)
sleep(0.005) # 5ms
output(1, False)
I have so much jitter that I think something is wrong somewhere. The same code with standard rpi GPIO works steadily.
The experiment were done by writing at the offset in /dev with Go (there is no buffer for the write but maybe there is one in your driver?) and used RevPiModIO in python.
I then tried to slow down everything (about 100ms sleep) and what I see is that writing Digital Output and Analog Output have different latency so the AnalogOutput is set sometime after the DIO is set.
for {
u.Write(AnalogOutputLogicLevel_OFFSET, outBytesDigit_1)
u.Write(DigitalOutput_OFFSET, outBytesDO_1_ON_ONLY)
time.Sleep(5 * time.Milliseconds)
u.Write(AnalogOutputLogicLevel_OFFSET, outBytesDigit_2)
u.Write(DigitalOutput_OFFSET, outBytesDO_2_ON_ONLY)
time.Sleep( 5 * time.Milliseconds)
}
I do not expect nano or microseconds but 5ms sounds pretty high (https://codeandlife.com/2012/07/03/benc ... pio-speed/)
Understanding this is not a pico but still I am confused why 2 successive write are done with up to 25ms delay in between?
Is there any buffer that can be deactivated to get something similar to standard GPIO? I though the RT kernel would help but it's worse than the standard RaspberryPi OS with GPIO.
Any help or idea would be helpful!
Torpi
I am using a RevPi Core 3+ with a MIO module and I am trying a simple test application with 7 segment LED (like this https://raspi.tv/wp-content/uploads/201 ... up_700.jpg)
Basically I want to display multiplexed 7 segment LED but switching them alternatively every 5ms. The problem is that I have a lot of jitter (up to 15ms!).
So I did a very simple program in Go and the same with Python (pseudo-code):
while True:
output(1, True)
sleep(0.005) # 5ms
output(1, False)
I have so much jitter that I think something is wrong somewhere. The same code with standard rpi GPIO works steadily.
The experiment were done by writing at the offset in /dev with Go (there is no buffer for the write but maybe there is one in your driver?) and used RevPiModIO in python.
I then tried to slow down everything (about 100ms sleep) and what I see is that writing Digital Output and Analog Output have different latency so the AnalogOutput is set sometime after the DIO is set.
for {
u.Write(AnalogOutputLogicLevel_OFFSET, outBytesDigit_1)
u.Write(DigitalOutput_OFFSET, outBytesDO_1_ON_ONLY)
time.Sleep(5 * time.Milliseconds)
u.Write(AnalogOutputLogicLevel_OFFSET, outBytesDigit_2)
u.Write(DigitalOutput_OFFSET, outBytesDO_2_ON_ONLY)
time.Sleep( 5 * time.Milliseconds)
}
I do not expect nano or microseconds but 5ms sounds pretty high (https://codeandlife.com/2012/07/03/benc ... pio-speed/)
Understanding this is not a pico but still I am confused why 2 successive write are done with up to 25ms delay in between?
Is there any buffer that can be deactivated to get something similar to standard GPIO? I though the RT kernel would help but it's worse than the standard RaspberryPi OS with GPIO.
Any help or idea would be helpful!
Torpi