Jump to content
  • 0

How can I code to output just N sine waves for desired frequency?


AlexMark6

Question

I am writing a code for Analog Discovery 2 in Python.
I want to output just N times (for example one or two or fifteen etc.) sine waves from 0 degree to 360 degree.
And I want to change frequency arbitually.
I tried the API "dwf.FDwfAnalogOutRunSet()" but doesn't work(start is 0 degree, but finish is not 360 degree). See attached image.
Does anyone teach me how to code?

 

one_sine_wave-2.jpg

one_sine_wave-3.jpg

one_sine_wave-1.jpg

Edited by AlexMark6
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Dear attila

Thank you very much for answering my question every time.

Actually I hided this question after I posted, but you seemed to have found my question.

Anyway. I checked the sample code "AnalogOut_Custom.py". I changed wave form from triangle to sine wave.

Then I changed the frequency. In case the fast frequency, output wave form is from 0 degree to 360 degree.

But for slower frequency, output wave form did not end at 360 degree.

I checked the sample code, and finally I found the reason was the time length of "time.sleep(second)" function.

When time length was short, wave form was quit by "dwf.FDwfAnalogOutReset(hdwf, channel)" function.

After I changed the time length to long enough value, output wave became to finish at 360 degree. 

I appreciate your advice every time.

Please help me next time too.

Best regards.

Link to comment
Share on other sites

  • 0

Hi @AlexMark6

You could make use of the following:
...
dwf.FDwfParamSet(DwfParamOnClose, c_int(0)) # 0 = continue running, 1 = stop, 2 = shutdown
dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf))
dwf.FDwfDeviceAutoConfigureSet(hdwf, c_int(0))# 0 = the device will be configured only when calling FDwf###Configure
...
dwf.FDwfAnalogOut...Set(...
dwf.FDwfAnalogOutConfigure(...
dwf.FDwfDeviceCloseAll()

PS: I thought your post was automatically hidden by spam detection.

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...