-
Notifications
You must be signed in to change notification settings - Fork 416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wave_send_repeat() does double the delay time of pulses #331
Comments
Could you please prepare a short Python script which demonstrates this problem? E.g. a script which is meant to generate pulses of 100 µs but actually results in pulses of 200 µs. |
try following script .. and connect RXPIN with TXPIN:
i get following output with 400 us between each pin change,
by the way: the receive timings are really accurate, i had not expected. |
above (doubled delay) result was on Raspberry Pi 3B+ with latest Raspbian.for completeness, here it's pinout chip infos:
same SD-card on Raspberry Pi 1B (of a friend) produced quite similar results, doubling the delay:only the measured delay jittered up to 5 us - think, that is quite ok.
Interestingly on a Raspberry Pi 4B with following pinout infos:
there is NO error:
|
Unfortunately it works as expected on my Pi3B+.
|
Interesting. Have you looked at the signal with oscilloscope and is it clean? I'm curious as to why you set the pulldown. |
There is a timing problem on some Pis which has never been tracked down. This may be another example of the same problem. |
@joan2937 , is the timing issue you're referring to the one associated with have a monitor/display attached? I seem to recall something of that nature. |
from
changing to PUD_OFF gives same doubled delay on my Pi 3B+. i don't have an oscilloscope here at home :-( any idea, how we could track this down? how can i assist? |
i have doubled delay on Pi 3B+ with display connected (working with screen/keyboard) previous test on Pi 4B was headless. would need to look for a display adapter .. |
@guymcswain That sounds right. It was never resolved. Nobody ever discovered a pattern as to which Pis were affected or why. |
tested on the another Pi 3B+: timing looks GOOD, delay factor is 1. it's exactly same model (
|
@hayguen Were you using the same SD card and PSU on the working and non-working Pi3B+ ? |
2nd Pi 3B+: now changed the SD-card for 2nd Pi 3B+ .. and have to connect Ethernet: removed Ethernet, configured WiFi on 2nd Pi 3B+: |
@hayguen , prior to your initial testing, did you run the pigpio's test suite - |
Okay. I have downloaded and burnt the image. My initial tests seem to be seeing the same as you, i.e. the waveforms are twice as long as expected. For my test I did the following after logging in to the image.
That should have resulted in a continuous square wave of 100µs on and 100µs off. Instead I see a square wave of 200µs on and 200µs off (using piscope). It's good that we can replicate the problem. That said I am busy at the moment and need to prioritise tasks needed for @guymcswain so can't be sure when I will be able to investigate. |
i had not executed the test suite before - even wasn't aware of it.
this happended 3 times on gpio25. |
@hayguen Could you start the pigpio daemon with the -t0 option and see if that works okay.
|
some more tests / insight:setting hdmi_safe=1 in /boot/config.txt
activating the comment in /boot/config.txt, thus removing hdmi_safe
before having played with hdmi_safeby default hdmi_safe was commented in /boot/config.txt |
that is quite quite interesting!
|
let me ask, what are the implications for using PWM or PCM clock? setting audio to 'always 3.5mm' with i'd suggest:
|
@hayguen , pigpio has a wide user base and has been in existence for several years so changing default config is out of the question. But I could see value in coming up with a test that could determine if the alternate clock peripheral should be used. Since you have invested some time on this issue would you be interested in supporting the development of such a test? I should add that there is already documentation in place. Selecting the alternate as default will create the need to document the cases that break under that scenario. This is why I suggest a test. |
Yes, I'd like to help. |
let me notice, that i had no speakers connected at any time |
Off the top of my head, using the C library one could generate pulses for timing measurement and switch between the two clock sources. If you want to help I'll accept a PR. Maybe it could be a part of x_pigpio.c |
x_pigpio requires that pin GPIO25 is unconnected or open. Suppose, this is why the tests are not automatically executed with every build / make. the (python) test program (from above) requires having connected 2 pins. however, both test programs have the problem, that they are executed only once in lifetime and usually not again. thus, end users would not realize the problem :-( i would prefer something, to run at every start of pigpiod - without any requirements. |
Just looking for something simple that users can run when the question comes up. I don't want to support anything complex nor try to protect against anything a user might do to his system. |
Perhaps something like the following. It should print 1.00 for no problem #!/usr/bin/env python
import time
import pigpio
GPIO=4
MICROS=1000
pi = pigpio.pi()
if not pi.connected:
exit()
pi.set_mode(GPIO, pigpio.OUTPUT)
pi.wave_add_generic(
[pigpio.pulse(1<<GPIO, 0, MICROS),
pigpio.pulse( 0, 1<<GPIO, MICROS)])
wid = pi.wave_create()
if wid >= 0:
start = time.time()
pi.wave_chain([255, 0, wid, 255, 1, 200, 0]) # send wave 200 times
while pi.wave_tx_busy():
time.sleep(0.001)
duration = time.time() - start
pi.wave_delete(wid)
pi.stop()
EXPECTED_SECS = 400.0 * MICROS / 1000000.0
ratio = duration / EXPECTED_SECS
print("{:.2f}".format(ratio)) |
@joan2937 , yes this is along the line I'm thinking about. However, if the result is negative, can the test verify success when the alternate clock is selected. I don't think that can be done via pigpiod client |
i had a similar idea, but did go one step further: following script works fine, to detect the erroneous timing - or not,
increasing the test duration (above, only 1 ms), the determined ratio gets more accurate. it also looks, that timing does only change on (re)boot - and happily not at runtime. i'm working on a C version testing both clocks .. and want to test on Pi 1. |
here's the standalone test program:
i've extended the test duration to 50 ms per clock.
one more info:
i'll prepare a pull request .. |
see pull request #332 |
Hello,
i'm recording a bunch of pulses and re-playing them quite similar to the example http://abyz.me.uk/rpi/pigpio/python.html#wave_add_generic
my application records the remote control's signal for a power switch (or any other 433 MHZ OOK device) .. and replays the recorded signal later, e.g. to allow sort of home automization.
see https://github.com/hayguen/rc433_rpi
and https://github.com/hayguen/rc433_rpi/blob/master/tx_csv.py
using python3 and wave_send_repeat() failed to control the power switch at first attempt.
i thought, that the timing is not accurate enough,
that i've written https://github.com/hayguen/rc433_rpi/blob/master/tx_csv_pigpio.c
this worked - even using busy loops.
now, having recorded the transmitted signal of tx_csv.py with an RTLSDR, i realized that all pulse delays were doubled on air!
thus, halving all delay values (see ~line 50 in tx_csv.py) does work and switch the power.
i've tested with Raspberry Pi 3B+ and the latest Raspbian (2020-02-14) with the pigpio package containing version 71 and latest github master with version v74.
later (next days), i could test with a Raspberry Pi 1 and a 4B.
i tried to have a look into the sources .. but i could not understand. i'm missing an explanation how gpioWaveTxSend() works with DMA stuff. Especially how is DMA utilized to produce the delays?
however, if / when there's a bugfix, how can i determine in python if i should halve the delays - or not?
kind regards,
hayati
The text was updated successfully, but these errors were encountered: