I combined a few python scripts from the SDK (AnalogIn_Acquisition, AnalogOut_Play and AnalogOut_Sine) to write a script which is intended to run during the night and save the scope's data into a WAV file.
All looks somewhat okay, but there are a few things that don't look perfect.
For this test, I connected CH1 and W1 and started both the Scope and Signal generator in the script. I'm intending to generate a 80 Hz sine wave and record it with the scope running at 8 kHz.
I attach the whole script, and here are the important parts:
# set up signal generation
channel = c_int(0)# use W1
dwf.FDwfAnalogOutNodeEnableSet(hdwf, channel,AnalogOutNodeCarrier, c_bool(True))
dwf.FDwfAnalogOutNodeFunctionSet(hdwf, channel,AnalogOutNodeCarrier, funcSine)# ! this looks like a square wave
dwf.FDwfAnalogOutNodeFrequencySet(hdwf, channel,AnalogOutNodeCarrier, c_double(signalgenhz))
dwf.FDwfAnalogOutNodeAmplitudeSet(hdwf, channel,AnalogOutNodeCarrier, c_double(1.41))# ! this doesn't really do anything
dwf.FDwfAnalogOutNodeOffsetSet(hdwf, channel,AnalogOutNodeCarrier, c_double(1.41))
I played around with the parameters and after some investigation with Audacity it seems like the funcSine parameter generates a square wave and the amplitude is always 1.0 no matter what I set.
The other problem I have is with the FDwfAnalogInStatusData function, it looks like it doesn't just get the raw data from the scope, is contains something else. So in order to get the scope's CH1 data, I need to have a 2-channel WAV file, and discard its first channel. The second is the data I'm looking for.
waveWrite = wave.open(startfilename,"wb");
waveWrite.setnchannels(2);# 2 channels for the testing (1 channel would be enough if FDwfAnalogInStatusData returned only 1 channel's data
waveWrite.setsampwidth(4);# 32 bit / sample
waveWrite.setframerate(samplerate);
waveWrite.setcomptype("NONE","No compression");
dwf.FDwfAnalogInStatusData(hdwf,0, rgdSamples, buffersize)# get channel 1 data CH1 - ! it looks like 2 channels get read here and only the second is the data of CH1
waveWrite.writeframes(rgdSamples);
I would expect that if I only need the CH1 of the Scope, I could save it into a mono WAV file.
Question
Andras
Hi,
I combined a few python scripts from the SDK (AnalogIn_Acquisition, AnalogOut_Play and AnalogOut_Sine) to write a script which is intended to run during the night and save the scope's data into a WAV file.
All looks somewhat okay, but there are a few things that don't look perfect.
For this test, I connected CH1 and W1 and started both the Scope and Signal generator in the script. I'm intending to generate a 80 Hz sine wave and record it with the scope running at 8 kHz.
I attach the whole script, and here are the important parts:
I played around with the parameters and after some investigation with Audacity it seems like the funcSine parameter generates a square wave and the amplitude is always 1.0 no matter what I set.
The other problem I have is with the FDwfAnalogInStatusData function, it looks like it doesn't just get the raw data from the scope, is contains something else. So in order to get the scope's CH1 data, I need to have a 2-channel WAV file, and discard its first channel. The second is the data I'm looking for.
I would expect that if I only need the CH1 of the Scope, I could save it into a mono WAV file.
AnalogIn_AcquisitionSaveToWAV.py
Link to comment
Share on other sites
6 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.