1 year ago

#323320

test-img

Mihai

Python and Rasbperry MCP3008 sampling

I am trying to use MCP3008 for sampling. I want obtain 8000 samples/second, but i really can't obtain much than 1000 samples/second. This is my code:

    spi = busio.SPI(clock = board.SCK, MISO=board.MISO, MOSI=board.MOSI)
    cs = digitalio.DigitalInOut(board.D5)
    mcp = MCP.MCP3008(spi,cs)
    
    def myadc():
        channel = AnalogIn(mcp, MCP.P0)
        es.append(channel.value)
    ok = 1
    k = 0
    try:
        while ok:
            myadc()
            time.sleep(0.000125) # this is the time for 8kHz sampling frequency

May be a problem with the SPI clock of Raspberry Pi? I have tried a lot, but nothing...

python

adc

iio

0 Answers

Your Answer

Accepted video resources