We have upgraded the community system as part of the upgrade a password reset is required for all users before login in.

SPI Register readout fails (ADS 1256)



  • Good afternoon,

    I've been working for my thesis on a project to do measurements on PV systems. However I am pretty inexperienced in SPI communication and programming in general (it's really not our department). I've been struggeling alot to get a simple readout of for example the status register of the ADC (to verify if the SPI communication and PCB are working properly).

    I'm trying to do the readout trough the supported python library and trough the spi-gpio-driver-master.

    "
    import onionSpi
    import time

    spi = onionSpi.OnionSpi(1, 32766)
    spi.sck = 7
    spi.mosi = 8
    spi.miso = 9
    spi.cs = 6
    spi.speed = 100000
    spi.mode = 0b01
    spi.lsbfirst = False
    spi.checkDevice()
    spi.registerDevice()
    spi.setupDevice()
    spi.setVerbosity(1)

    ret = spi.write([0b00010000,0b00000001]) #read command to readout register 0x00
    data = spi.readBytes(0x00, 1)
    print (data)
    "

    As I expect the omega transfers the command bytes to the ADC trough the MOSI line.
    Afterwards I would expect to receive the status register from the ADC altough this does not seem to happen.

    What am I missing out?

    Attached files:

    Datasheets ADS1256: http://www.ti.com/lit/gpn/ads1256

    Greetings,

    Olivier



  • Found a mistake by reading the datasheet: The "read register command" is of the form [page 34]

    [0001 <reg. number> ]  [0000 nnnn]
           first byte      second byte            
    

    Where as n is the number of registers you want to read minus one. So if you want to read one register, n = 0.

    Also have a look at the read/write register functions from an Arduino ADS1256: https://github.com/adienakhmad/ADS1256/blob/master/ADS1256.cpp#L36

    According to that, maybe do

    import time
    
    RREG = 0x10 #constant
    ret = spi.write([RREG | 0x00 , 0x00]) #read command to readout register 0x00
    time.sleep(0.001) #sleep for 50*tCLKIN, since I don't know the master clock freq for your ADS board; 1ms should be enough..
    #now read register
    data = spi.readBytes(0x00, 1)
    # arduino codes sleeps after reading registers, too.
    print("STATUS REG: " + hex(data[0]))
    

    If that doesn't help you can attach a logic analyzer to see what the ADC receives/sends and can you compare that with e.g. what signals an arduino with a ads1256 lib produces from the link above.



  • @Maximilian-Gerhardt
    Thanks alot for the fast response. Will try this out asap. I'll keep it posted! Cheers


Log in to reply
 

Looks like your connection to Community was lost, please wait while we try to reconnect.