Jump to content
  • 0

Using Python (Waveforms SDK) to turn on/set the VIO pins for the Digital Discovery


AstroKevin

Question

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? 

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

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. 

Link to comment
Share on other sites

  • 0

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")

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...