Open viric opened 1 year ago
Yeah, the trigger can be a little finicky. Do you know roughly what the signal looks like, and what its frequency is? One possible reason for the trigger not working is that it times out waiting for the trigger condition to be met. The timeout is 6.25 ms, so if your signal has a frequency less than 200 Hz or so the trigger might be timing out.
Check if the trigger works on a signal generated by the PSLab itself. Connect pin SI1 to CH1, and run this code:
import matplotlib.pyplot as plt
import pslab
psl = pslab.ScienceLab()
psl.waveform_generator.generate(1, 1000) # 1 kHz sinusoid on SI1.
for _ in range(5):
x, y = psl.oscilloscope.capture(1, 1000, 10, trigger=1) # Capture 1 kS @ 100 kS / s on CH1 w. 1 V trigger.
plt.plot(x, y)
This works for me on my V5. Do the curves overlap, or do they start all over the place? If the trigger is working, they should all start at 1 V or slightly above.
Ah sure, I tried a 50Hz signal, and the other was a serial line frame that came once in a while.
How can I get a normal trigger implementation? How does one compile a new firmware (on linux) and flash it to a v5 board? Only with a PIC programmer?
The timeout can be increased, and even disabled entirely, with the timeout
argument of configure_trigger
. It's a prescaler, so a value of 1 doubles the timeout to 12.5 ms, 2 doubles it again 25 ms, and so on.
To disable the trigger timeout, set the timeout prescaler such that:
timegap * 4 / timeout < 1
The v5 has no bootloader, so flashing new firmware requires a hardware programmer like a PICkit, yes. If you can get ahold of one you can use it to flash the bootloader , after which new firmware can be flashed over USB.
The pslab-bootloader and pslab-firmware repos have instructions for how to build and flash them. It would be great if you could try it out, and let us know if anything is unclear or doesn't work as expected.
Note that the firmware is currently undergoing a major overhaul. It's almost done and should be mostly feature complete, but there may be bugs we haven't ironed out yet. It's also not very well tested on the v5, but it should work in theory.
On second thought, disabling the timeout is only possible for high sample rates / small timegaps less than 4 us. This is because the timeout prescaler is only one nibble wide, i.e. its maximum value is 15.
Still, a timeout value of 15 leads to a timeout of just over 200 s, if my math is right. Should be enough for most use cases.
I'm trying a very simple set up, with an electrical signal in CH1, trigger in CH1 at 1V, and the enabling the "trigger" setting makes no difference. It keeps on updating the display as if it were not checked. I tested the Android and the pslab-desktop app, and also the pslab-python alone (with the oscilloscope capture() trigger parameters and also with configure_trigger()). Maybe it's a bug in the PSlab v5 board or firmware? I bought the board some years ago. I don't know if I can check or update the board firmware easily.