my external wavegenerator is set to sine wave 2kHz with High 700mV and low 0mV. im trying to record the frequency through the ad2 osciloscope (analog in). but my output displays '0'
from ctypes import *
from dwfconstants import *
import time
import sys
#print(DWF version
version = create_string_buffer(16)
dwf.FDwfGetVersion(version)
print("DWF Version: "+str(version.value))
#open device
"Opening first device..."
dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf))
if hdwf.value == hdwfNone.value:
szerr = create_string_buffer(512)
dwf.FDwfGetLastErrorMsg(szerr)
print(szerr.value)
print("failed to open device")
quit()
Question
abia
my external wavegenerator is set to sine wave 2kHz with High 700mV and low 0mV. im trying to record the frequency through the ad2 osciloscope (analog in). but my output displays '0'
from ctypes import *
from dwfconstants import *
import time
import sys
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")
#declare ctype variables
hdwf = c_int()
voltage1 = c_double()
voltage2 = c_double()
#print(DWF version
version = create_string_buffer(16)
dwf.FDwfGetVersion(version)
print("DWF Version: "+str(version.value))
#open device
"Opening first device..."
dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf))
if hdwf.value == hdwfNone.value:
szerr = create_string_buffer(512)
dwf.FDwfGetLastErrorMsg(szerr)
print(szerr.value)
print("failed to open device")
quit()
print("Preparing to read sample...")
dwf.FDwfAnalogInChannelEnableSet(hdwf, c_int(0), c_bool(True))
dwf.FDwfAnalogInChannelOffsetSet(hdwf, c_int(0), c_double(0))
dwf.FDwfAnalogInChannelRangeSet(hdwf, c_int(0), c_double(5))
dwf.FDwfAnalogInConfigure(hdwf, c_bool(False), c_bool(False))
time.sleep(2)
z = 0
for i in range(4):
time.sleep(1.66)
dwf.FDwfAnalogInStatus(hdwf, False, None)
dwf.FDwfAnalogInStatusSample(hdwf, c_int(0), byref(voltage1))
dwf.FDwfAnalogInStatusSample(hdwf, c_int(1), byref(voltage2))
print("Channel 1: " + str(voltage1.value)+" V")
print("Channel 2: " + str(voltage2.value)+" V")
dwf.FDwfAnalogInFrequencyGet(hdwf, z)
print("Freq: " + str(z) )
print('---------------------------')
dwf.FDwfDeviceCloseAll()
#####
DWF Version: b'3.18.1'
Preparing to read sample...
Channel 1: 0.25451508173897247 V
Channel 2: -0.0023014079845233293 V
Freq: 0
---------------------------
Channel 1: 0.44609468785736645 V
Channel 2: 0.012614214611239793 V
Freq: 0
---------------------------
Channel 1: 0.6771269877313809 V
Channel 2: 0.012614214611239793 V
Freq: 0
---------------------------
Channel 1: 0.05825464754787773 V
Channel 2: 0.027529837207002916 V
Freq: 0
---------------------------
Process finished with exit code 0
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now