Jump to content

Torbjørn

Members
  • Posts

    4
  • Joined

  • Last visited

Torbjørn's Achievements

Newbie

Newbie (1/4)

1

Reputation

  1. Thanks again @attila! Adding dwf.FDwfDigitalOutReset(hdwf) made all the difference. After some more debugging I can now toggle one of the relays back and forth, next step is now to add measurements with the scope channels. Here is the working relay-toggler if you or anyone else are interested: dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf)) def send5mspulse(hdwf, ch): dwf.FDwfDigitalOutRunSet(hdwf, c_double(0.005)) # 5ms run dwf.FDwfDigitalOutEnableSet(hdwf, c_int(ch), c_int(1)) dwf.FDwfDigitalOutIdleSet(hdwf, c_int(ch), c_int(1)) # 1=DwfDigitalOutIdleLow, low when not running dwf.FDwfDigitalOutCounterInitSet(hdwf, c_int(ch), c_int(1), c_int(0)) # initialize with high when running dwf.FDwfDigitalOutCounterSet(hdwf, c_int(ch), c_int(0), c_int(0)) dwf.FDwfDigitalOutRepeatSet(hdwf, c_int(1)) # once def enable5V(hdwf): dwf.FDwfAnalogIOChannelNodeSet(hdwf, c_int(0), c_int(0), c_double(True)) # enable positive supply dwf.FDwfAnalogIOChannelNodeSet(hdwf, c_int(0), c_int(1), c_double(5.0)) # set voltage to 5 V dwf.FDwfAnalogIOEnableSet(hdwf, c_int(True)) # master enable time.sleep(0.1) enable5V(hdwf) send5mspulse(hdwf, 6) send5mspulse(hdwf, 7) #"run/trigger" dwf.FDwfDigitalOutConfigure(hdwf, c_int(1)) #do clever measurements with relays in first position here time.sleep(1) dwf.FDwfDigitalOutReset(hdwf) # to clear previous instrument configuration, channels are by default in high impendance enable5V(hdwf) send5mspulse(hdwf, 14) send5mspulse(hdwf, 15) dwf.FDwfDigitalOutConfigure(hdwf, c_int(1)) #do clever measurements with relays in second position here time.sleep(1) dwf.FDwfDigitalOutReset(hdwf) dwf.FDwfDeviceCloseAll()
  2. Thanks @attila The question is really how do I trigger the digital out from software, more than once. The board I made just happen to have the same relays and pin-out as the impedance analyzer board.
  3. I forgot to mention that I made my own board, using the same components and pin-out from the AD2. But the relays now control different things.
  4. I want to control the relays of the impedance meter board using python. I can toggle the relay back and forth by running my code more than once, but can't figure out how to toggle it back and forth without starting from the top. I tried using triggerPC but that won't work either. The interesting bits: dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf)) if hdwf.value == hdwfNone.value: print ("failed to open device") quit() def send5mspulse(hdwf, ch): dwf.FDwfDigitalOutRunSet(hdwf, c_double(0.005)) # 5ms run dwf.FDwfDigitalOutEnableSet(hdwf, c_int(ch), c_int(1)) dwf.FDwfDigitalOutIdleSet(hdwf, c_int(ch), c_int(1)) # 1=DwfDigitalOutIdleLow, low when not running dwf.FDwfDigitalOutCounterInitSet(hdwf, c_int(ch), c_int(1), c_int(0)) # initialize with high when running dwf.FDwfDigitalOutCounterSet(hdwf, c_int(ch), c_int(0), c_int(0)) dwf.FDwfAnalogIOChannelNodeSet(hdwf, c_int(0), c_int(0), c_double(True)) # enable positive supply dwf.FDwfAnalogIOChannelNodeSet(hdwf, c_int(0), c_int(1), c_double(5.0)) # set voltage to 5 V dwf.FDwfAnalogIOEnableSet(hdwf, c_int(True)) # master enable #dwf.FDwfDigitalOutTriggerSourceSet(hdwf, trigsrcPC) dwf.FDwfDigitalOutRepeatSet(hdwf, c_int(0)) # infinite repeat dwf.FDwfDigitalOutRepeatTriggerSet(hdwf, c_int(1)) # wait for trigger in each cycle # <-- This toggles the relay. If I change to pins 14 and 15 and re-run the code it toggles back --> send5mspulse(hdwf, 6) send5mspulse(hdwf, 7) dwf.FDwfDigitalOutConfigure(hdwf, c_int(1)) #dwf.FDwfDeviceTriggerPC(hdwf) time.sleep(1) # <--- This will not toggle back! --> send5mspulse(hdwf, 14) send5mspulse(hdwf, 15) #dwf.FDwfDeviceTriggerPC(hdwf) time.sleep(1) dwf.FDwfDeviceCloseAll()
×
×
  • Create New...