jbentham / streaming

ADC data streaming for the Raspberry Pi
35 stars 4 forks source link

converting for ADS7884 #3

Open BryceDrechselSmith opened 3 years ago

BryceDrechselSmith commented 3 years ago

First I want to say thank you for your tutorials, they are very clear and well written. I am trying to adapt this code to work with the ADS7884 following your streaming guide and the guide you wrote on fast data capture, but I am having trouble getting it right. I need to get ~2.5Msamples/sec some assumptions im making:

Is there anything else that needs to be done to stream dma from the ads7884? Any insights you may have are greatly appreciated.

jbentham commented 3 years ago

The streaming code should almost work as-is; so long as the SPI clock is being clocked, and the chip select is being selected, something should emerge from the data line; I suggest you look at the binary data, which really should contain something meaningful.

My earlier code used SPI Tx for the chip select because I didn't fully understand how to use the auto-CS capability.

However, be aware that this isn't the easiest ADC to work with; the datasheet describes the need for power decoupling capacitors, the low-ish input impedance, and the dynamic (capacitative) sampling technique, which presumably means the clock rate must be above a minimum value - I can't remember what that is, but don't expect to get sensible answers if the rate is too low.

On 26/05/2021 01:12, BryceDrechselSmith wrote:

First I want to say thank you for your tutorials, they are very clear and well written. I am trying to adapt this code to work with the ADS7884 following your streaming guide and the guide you wrote on fast data capture, but I am having trouble getting it right. I need to get ~2.5Msamples/sec some assumptions im making:

  • In the streaming code it appears that you are using the PWM to control the chip select, so i need to change this to SPI
  • i need to change the adc_dma_init() func to match adc_dma_samples_ads7884()

Is there anything else that needs to be done to stream dma from the ads7884? Any insights you may have are greatly appreciated.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jbentham/streaming/issues/3, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACNUSEV5IOWBBXPPRCZGTR3TPQ4HPANCNFSM45QPBEWA.

BryceDrechselSmith commented 3 years ago

so in the rpi_adc_stream I've changed the max sample rate to 2.5Msamples/sec, pwm_freq = 2.5M, max_spi_freq=4M, and SPI_frew = 2.5M. In this configuration running: sudo ./rpi_adc_stream -n 10 -r 200000 -s /tmp/adc.fifo and then monitoring the output in another window with: cat /tmp/adc.fifo shows that ~50% of the readings are good, and the others show 0V. I know that the RPi Zero has a 400Mhz clock, so theoretically i could push those numbers higher, but experimentation shows that doing so gives bad results. Is it possible that this is a result of the way the information is taken from the ADS7884 vs the MCP3008? In your paper you mentioned that the number of bits is different and that you were using 3 dummy bits as padding for the ADS7884. I appreciate you taking the time to respond, and any insights into what sections of the code might need changing to make the code run at ~2.6Msamples/sec like in your fast capture article would be very helpful

jbentham commented 3 years ago

I don't understand how you'll get 2.5 M sample/s with an SPI clock of 2.5 MHz - at the very least, it takes 16 cycles for a conversion, and probably more to include the chip select pulse. If you want to run the SPI clock at 40+ MHz, you do need to keep the wiring short, with a decent ground line, and supply decoupling capacitors - do take a look at the datasheet.

Aside from that, I can't really speculate on the cause of this issue; I'd just connect a scope or logic analyser to the SPI signals, and then it'd be clear whether this was a ADC or DMA problem.

On 27/05/2021 00:59, BryceDrechselSmith wrote:

so in the rpi_adc_stream I've changed the max sample rate to 2.5Msamples/sec, pwm_freq = 2.5M, max_spi_freq=4M, and SPI_frew = 2.5M. In this configuration running: sudo ./rpi_adc_stream -n 10 -r 200000 -s /tmp/adc.fifo and then monitoring the output in another window with: cat /tmp/adc.fifo shows that ~50% of the readings are good, and the others show 0V. I know that the RPi Zero has a 400Mhz clock, so theoretically i could push those numbers higher, but experimentation shows that doing so gives bad results. Is it possible that this is a result of the way the information is taken from the ADS7884 vs the MCP3008? In your paper you mentioned that the number of bits is different and that you were using 3 dummy bits as padding for the ADS7884. I appreciate you taking the time to respond, and any insights into what sections of the code might need changing to make the code run at ~2.6Msamples/sec like in your fast capture article would be very helpful

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jbentham/streaming/issues/3#issuecomment-849197083, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACNUSEWQSQNJYDQ7XHXS56TTPWDNNANCNFSM45QPBEWA.