Digilent / WaveForms-SDK-Getting-Started-PY

Demo package for the WaveForms SDK Getting Started guide and multiple test scripts for different instruments.
https://digilent.com/reference/test-and-measurement/guides/waveforms-sdk-getting-started
MIT License
40 stars 13 forks source link

Power supplies not configurable using WaveForms SDK on Raspberry Pi 4 #2

Open alexeysatsunkevich opened 1 year ago

alexeysatsunkevich commented 1 year ago

I have an Analog Discovery 2 device connected through Rasberry Pi 4. I installed the latest version of Adept Runtime(2.26.1) and WaveForms(3.18.1) on the RPi device according to the instructions here: https://digilent.com/blog/analog-discovery-2-is-now-compatible-with-raspberry-pi-4/. WaveForms app works fine via GUI interface. But I have one issue with configure power supplies when I try to use WaveForms SDK in python scripts. I configured the "positive" power supply to 3.3V and I tried to read state from static DIOs. I got a "LOW" state on all DIO inputs, although there should be a "HIGH" state on the DIO inputs according to my scheme.

I tried to run my script on Windows 10 and I got the expected result.

My examples can be found here:

from WF_SDK import device, static, supplies, error  # import instruments
from time import sleep  # needed for delays

try:
    # connect to the device
    device_data = device.open()
    print("Device name: " + device_data.name)

    # start the positive supply
    supplies_data = supplies.data()
    supplies_data.master_state = True
    supplies_data.positive_state = True
    supplies_data.state = True

    supplies_data.voltage = 3.3
    supplies_data.positive_voltage = 3.3
    supplies.switch(device_data, supplies_data)

    # set 9,10,11 pins as input
    static.set_mode(device_data, 9, False)
    static.set_mode(device_data, 10, False)
    static.set_mode(device_data, 11, False)

    try:
        while True:
            reading_dio9 = static.get_state(device_data, 9)
            print("DIO9: ", reading_dio9, end=' ')
            sleep(0.1)

            reading_dio10 = static.get_state(device_data, 10)
            print(" DIO10: ", reading_dio10, end=' ')
            sleep(0.1)

            reading_dio11 = static.get_state(device_data, 11)
            print(" DIO11: ", reading_dio11)
            sleep(1)

    except KeyboardInterrupt:
        # stop if Ctrl+C is pressed
        pass

    finally:
        # stop the static I/O
        static.close(device_data)

        # stop and reset the power supplies
        supplies_data.master_state = False
        supplies_data.positive_state = False
        supplies_data.negative_state = False
        supplies.switch(device_data, supplies_data)
        supplies.close(device_data)

        # close the connection
        device.close(device_data)

except error as e:
    print(e)
    # close the connection
    device.close(device.data)

Do you have any idea how to solve issue with Raspberry PI ?