m-labs / pdq

Pretty darn quick interpolating arbitrary waveform generator
GNU General Public License v3.0
6 stars 3 forks source link

problems with SPI frame select #9

Closed erickson-nist closed 7 years ago

erickson-nist commented 7 years ago

@jordens, as requested in your email I am moving this conversation github for easier tracking. To recap what we have done:

Flashed our qc2 Artiq crate with the latest version as of 2017-06-27 Flashed a PDQ board with 1 channel "pdq3" gateware Attempted to program 32 different frames to the pdq via USB (attached as program_test_wfs.py) Attempted to use SPI in Artiq to select each of these waveforms then trigger with TTL (attached as SPI_wf_test.py) Tried the above with multiple different PDQ boards

On the scope we see clear pulses on the CLK and MOSI channels while CS_N is always high (not sure whether it should be). When trying to read the frame number or crc, we see nothing on the scope and Artiq interprets it as reading 0. We also don't see anything on the DAC output of the PDQ board.

Neither the python compiler when programming the waveforms or Artiq raise any errors when running the code that would point to an obvious fix. We are unsure what we are doing wrong and wondering if you have any advice on what to try next.

PDQ_SPI_testing.zip

jordens commented 7 years ago

Please verify that readback of the frame, config, and checksum registers via SPI works after setting them via USB and SPI.

sbourdeauducq commented 7 years ago

It seems that it doesn't? Reads back 0 and CS is not asserted (during the write at least).

jordens commented 7 years ago

If CS_N is never low there is something wrong with your setup. Please add more information (device_db,pyon) and a complete description how you wired everything. Also, PdqSPI will only work on the coredevice (over the coredevice's SPI connection) and the regular Pdq will work over the USB connection.

erickson-nist commented 7 years ago

Thanks for your feedback, I was able to isolate the source of our problem. In device_db we had "chip_select" set to 0. Changing it to 1 allows us to select frames via SPI. The PDQ output is mostly as expected, except that I am only able to run 8 distinct waveforms.

I have attached basic code that I am using to test:

program_spi_test_waveforms.py constructs a PDQSPI object with num_frames = 32. It then generates 32 simple trapazoidal pulses where the pulse height corresponds to the frame number and programs them to the board.

PDQSPItest.py is an artiq script that steps through and sets via SPI then triggers each of the 32 frames. With read_frame we read back 0-31 as expected. However, when we look on the oscilloscope we see 4 sequences of frames 0-7 instead of frames 0-31. We see similar behavior if we program only 5 waveforms; the first 5 trigger as expected, then we see 3 gaps, then this sequence repeats another 3 times.

device_db.py is the usual thing.

read_frame suggests that the PDQ is is correctly receiving the write_frame command, but when it comes to outputting waveforms it seems to use the frame number mod 8.

PDQ_SPI_only_8_frames.zip

jordens commented 7 years ago

OK. Nice. SPI works, read-back also works, programming also works. The fix for the frame numer should be coming up.

A note: pdq = PdqSPI(Pdq(port), num_boards=1, num_dacs=1, num_frames=frames) should be pdq = Pdq(port, num_boards=1, num_dacs=1, num_frames=frames)