PYNQ: PYTHON PRODUCTIVITY

Use 4 channel ADC with PmodAD2

I need to use all 4 ADC ports in a Pmod AD2 in python but it seems that the out-of-the-box pmod_adc files are configured to leave the 4th ADC port as a reference. I have tried editing the pmod_adc.c file (basically adding lines for the remaining port, copying what’s written for the other ports). Below are some of the edits I have made:


EDIT: Forgot to mention that before edits, useChan3=0 and useVref=1. I tried useVref=0 and it didn’t work either.

After that, I try reading the 4 channels on jupyter as follows, but I am still not getting the expected results:

ch1, ch2, ch3, ch4 = 0, 0, 0, 1
cmd = (ch4 << 7) | (ch3 << 6) | (ch2 << 5) | (ch1 << 4) | READ_VOLTAGE
microblaze.write_blocking_command(cmd)
readings = microblaze.read_mailbox(0, 4)

results = []
for e in readings:
    results.append(reg2float(e))

Even though now I am able to read 4 readings out of the mailbox they do not correspond to the voltage I am supplying the PmodAD2. Is there an easier way this is supposed to be done? Or am I on the right track? Thank you