Jump to content

AstroKevin

Members
  • Posts

    7
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

AstroKevin's Achievements

Newbie

Newbie (1/4)

0

Reputation

  1. When I save a workspace (as of v3.21.11) the DIOs/DINs pull up/down are all saved. However, when I press save while the VIO is on, the VIO automatically gets shut off. This also happens when first loading the workspace as well. Is there anyway to configure it so that the VIO turns on when the workspace is loaded? We have 3 DDs and require the VIOs to be turned on before any of our circuit works, so having to go into 3 different GUIs and turn them all on every time is a (mild) pain.
  2. I just updated mine to the latest (V3.21.11) and confirmed it does work now with the Waveforms GUI. Is there a sample/example python code that shows how to enact this using the SDK? Right now I have a method in my controller class, but I have to initialize the device, open the device, then use the method below to set up the defaults we would like. I am not sure if there a way to save the defaults through a power on/off so that the "load_default_states()" method is not having to be used every time we connect? I am assuming not. def load_default_states(self): """Load default states for the device.""" logger.info("Setting weak pull for DIN lines to middle") # configure weak pull for DIN lines, 0.0 low, 0.5 middle, 1 high dwf.FDwfAnalogIOChannelNodeSet(self.device, c_int(0), c_int(1), c_double(0.5)) logger.info("Setting the pull enable for all DIO pins") # pull enable for all DIO pins (DIO 39 to 24, bit 15 to 0) dwf.FDwfAnalogIOChannelNodeSet(self.device, c_int(0), c_int(2), c_double(0xFFFF)) logger.info("Setting the DIO pins to pull down") # pull down for all DIO pins dwf.FDwfAnalogIOChannelNodeSet(self.device, c_int(0), c_int(3), c_double(0x0000)) logger.info("Setting the drive strength for DIO lines to 8 mA") # drive strength for DIO lines: 0 (auto based on digital voltage), 2, 4, 6, 8, 12, 16 (mA) dwf.FDwfAnalogIOChannelNodeSet(self.device, c_int(0), c_int(4), c_double(8)) logger.info("Setting the slew rate for DIO lines to Fast (More EMI, but faster state transitions)") # slew rate for DIO lines: 0 quietio, 1 slow, 2 fast dwf.FDwfAnalogIOChannelNodeSet(self.device, c_int(0), c_int(5), c_double(2)) logger.info("Default states of the DD have been loaded and set")
  3. That worked perfectly. Thank you! I updated to the v3.20.25 beta so I could get the 40bit pin combinations for the DD DINs/DIOs. I am wanting to set the pins to preconfigured states that they hold when I connect the DD to the computer. Is this possible? if so, how? I noticed in WF Options it has the DIOs tab with the drive/slew/pull etc and all up/down, but even if I save it as a workplace, it won't hold those default states.
  4. I cannot find the correct function using the Python SDK to turn on the VIO power pins. The examples on the website and github use the analog discovery functions and throw errors when trying to use it on the Digital Discovery. Can you give me an example code that turns on and sets the VIO using the python SDK?
  5. Ooof, I don't know how I missed that, but it works perfectly now! Thank you.
  6. Hey, I seem to be having a very difficult time with the documentation on the WaveForms SDK using python. I can read/write all DIOs and do everything else using the GUI waveforms, but I cannot read DIN pin 8-23. I have been able to read DINs 0-7. I made a function to read a certain DIN, but then overwrote a few things because of troubleshooting, so the "pin_index" is really not used here as it prints all the pins out. Can you please help me figure out why I cannot see DIN pins 8-23? I should add that I have another Digital Discovery outputting simple high signals to pins 0, 3, 7, 8, and 20, but I only get 0,3, and 7 to show up. from ctypes import * import configparser import sys # Load the dwf library if sys.platform.startswith("win"): dwf = cdll.dwf elif sys.platform.startswith("darwin"): dwf = cdll.LoadLibrary("/Library/Frameworks/dwf.framework/dwf") else: dwf = cdll.LoadLibrary("libdwf.so") def initialize_devices(): """ Initialize the Digilent Digital Discoveries """ cDevice = c_int() devicename = create_string_buffer(64) serialnum = create_string_buffer(16) # Enumerate devices dwf.FDwfEnum(c_int(0), byref(cDevice)) devices = [] for iDevice in range(cDevice.value): dwf.FDwfEnumDeviceName(c_int(iDevice), devicename) dwf.FDwfEnumSN(c_int(iDevice), serialnum) devices.append((devicename.value.decode('utf-8'), serialnum.value.decode('utf-8'))) return devices devices = initialize_devices() print(devices) def open_device_by_serial(target_serial_number): """ Open a device by its serial number """ cDevice = c_int() serialnum = create_string_buffer(16) # Enumerate devices dwf.FDwfEnum(c_int(0), byref(cDevice)) # Find the device with the target serial number for iDevice in range(cDevice.value): dwf.FDwfEnumSN(c_int(iDevice), serialnum) if serialnum.value.decode('utf-8') == target_serial_number: hdwf = c_int() dwf.FDwfDeviceOpen(c_int(iDevice), byref(hdwf)) if hdwf.value == 0: raise RuntimeError("Failed to open device.") return hdwf raise ValueError(f"No device with serial number {target_serial_number} was found.") def read_din_pin(pin_index): hdwf = open_device_by_serial(My_Serial) # Declare ctype variables sts = c_byte() cSamples = 8192 rgwSamples = (c_uint32*cSamples)() # Adjusted for 32 bits cAvailable = c_int() cLost = c_int() cCorrupted = c_int() fLost = 0 fCorrupted = 0 # Set up acquisition dwf.FDwfDigitalInInternalClockInfo(hdwf, byref(c_double())) dwf.FDwfDigitalInDividerSet(hdwf, c_double(10)) dwf.FDwfDigitalInSampleFormatSet(hdwf, c_int(32)) # Adjusted for 32 bits dwf.FDwfDigitalInBufferSizeSet(hdwf, c_int(cSamples)) dwf.FDwfDigitalInTriggerAutoTimeoutSet(hdwf, c_double(10)) dwf.FDwfDigitalInTriggerSourceSet(hdwf, c_ubyte(0)) dwf.FDwfDigitalInTriggerSet(hdwf, c_int(0), c_int(0), c_int(0), c_int(0)) # Set sensible mask for specific pin mask = 1 << pin_index # This will create a mask that enables only the specified pin dwf.FDwfDigitalInSampleSensibleSet(hdwf, c_int(mask)) # Set trigger position dwf.FDwfDigitalInTriggerPositionSet(hdwf, c_int(8191)) # 8191 is one less than cSamples # Start signal generation dwf.FDwfDigitalInConfigure(hdwf, c_bool(False), c_bool(True)) # Wait until done while True: dwf.FDwfDigitalInStatus(hdwf, c_int(1), byref(sts)) if sts.value == 2: # DONE break time.sleep(0.1) # Get sample dwf.FDwfDigitalInStatusData(hdwf, rgwSamples, 4*cSamples) # Adjusted for 32 bits print(rgwSamples[:10]) # Close device dwf.FDwfDeviceCloseAll() # Extract pin state from sample (for easier reading) for pin_index in range(24): pin_state = (rgwSamples[0] >> pin_index) & 1 print(f"Pin {pin_index}: {pin_state}") return pin_state read_din_pin(0)
  7. Hello, first time poster, but I will probably be posting a lot through this year as my work is using the Digilent Digital Discovery a lot. I am just getting started in the testing process to see the functionality of the Digital Discovery, however, I have not been able to get the WF_SDK package to work properly (the WaveForms application GUI works fine). Using only the sample code "Using the Logic Analyzer and the Pattern Generator" provided on this page, and after installing the package, connecting the digital discovery, then running the script, I get the following error: User> python test_pattern.py Traceback (most recent call last): File "User\WaveForms-SDK-Getting-Started-PY\test_pattern.py", line 16, in <module> pattern.generate(device_data, channel=1, function=pattern.function.pulse, frequency=100e03, duty_cycle=30) File "User\WaveForms-SDK-Getting-Started-PY\WF_SDK\pattern.py", line 83, in generate check_error() File "User\WaveForms-SDK-Getting-Started-PY\WF_SDK\device.py", line 229, in check_error raise error(err_msg, err_func, err_inst) WF_SDK.device.error: Error: pattern -> generate -> Invalid channel index provided Where "test_pattern.py" is only the copied python code and the channel is kept at "channel=0". I even tried channel=24 (in case the channels started at the label on the hardware). The page gives no other information and even states "As the same line is used both as input and as output, no external connections have to be made.". Please assist me so I can get this fixed. I assumed the example and test codes would work right out of the box so I could further expand on it for our needs.
×
×
  • Create New...