Skip to content

Some assistance needed with u3 and SPI #125

@michK

Description

@michK

Hi,

I am trying to read temperature with the MAX6675 with a U3 LJ and SPI.

I followed this example and seem to have the PSI communication set up correctly because I can see the expected chip select, clock, and return signal on an oscilloscope, however, I am not sure how to set up the d.spi() command to read back only the required bits.

Here is my script:

import os
import time
import u3

d = u3.U3() #Open first found U3 over USB
d.configIO(FIOAnalog = 0x0F) #For this example FIO4-7 need to be digital IO

# Press ctrl-C to exit the program
try:
    while(True):
        results = d.spi([0x4<<2, 0])
        print(results)
        time.sleep(0.1)
except KeyboardInterrupt:         #this allows the program to quit when you press "ctrl C"
    print("ctrl C received, shutting down program")
    d.close()                      #close the device   

Here is a screenshot of the scope output: https://u.pcloud.link/publink/show?code=XZEsxIVZhKq97lWxxtBJFH1mVRERBLQWpWIV

Manually digitizing bits D14–D3 gives the binary sequence 000001101000, which in decimal is 104, and interpolating this as a 12 bit number between temperatures of 0°C and 1023.75°C as per the datasheet gives a reasonable 26°C result for the conditions I took the data.

Is there a way to set up the d.spi() command to return the binary sequence as mentioned above?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions