Jump to content
  • 0

USB1808x - How to simultaneously output 2 different analog signals


Question

Posted

Hi, I am trying to figure out how to output 2 analog signals simultaneously. (the 2 signals are different, one sinusoidal, and another a triangular wave. The example python code, a_out_scan.py seems to be only able to take one data buffer) I tried to call the a_out_scan function twice but it doesn't seem to work. 

Is it even possible to output 2 different analog signals simultaneously using the USB-1808x?

4 answers to this question

Recommended Posts

  • 0
Posted

Hello @Charlie2134.

Yes, the USB-1808X can output two different analog signals simultaneously.  Are you creating your Python program with UL for Windows or UL for Linux?  

When scanning multiple output channels, the data must be interleaved into a 1-D array.

https://www.mccdaq.com/pdfs/manuals/Mcculw_WebHelp/ULStart.htm

https://www.mccdaq.com/PDFs/Manuals/UL-Linux/python/index.html

https://www.mccdaq.com/pdfs/manuals/USB-1808X.pdf

 

Regards,

Fausto

  • 0
Posted
23 hours ago, Fausto said:

Hello @Charlie2134.

Yes, the USB-1808X can output two different analog signals simultaneously.  Are you creating your Python program with UL for Windows or UL for Linux?  

When scanning multiple output channels, the data must be interleaved into a 1-D array.

https://www.mccdaq.com/pdfs/manuals/Mcculw_WebHelp/ULStart.htm

https://www.mccdaq.com/PDFs/Manuals/UL-Linux/python/index.html

https://www.mccdaq.com/pdfs/manuals/USB-1808X.pdf

 

Regards,

Fausto

Hello,

Thank you for answering! I am using Python UL for Linux. I try to call the function a_out_scan() twice with 2 different data buffers but it would raise an UL exception. (UL_Error_ALREADY_ACTIVE);

I don't quite understand the idea of interleaving the data for 2 channels into one 1-D array. We are trying to output 2 different analog outputs on the 2 different channels, i.e., channel Aout0 outputting a sine wave, and channel Aout1 outputting a triangular wave. Is it possible? 

Best,

Charlie

  • 0
Posted

Only one a_out_scan can be run, and likewise for a_in_scan. Consider a_in_scan. You specify a group of channels, and the data buffer it produces has interleaved channels. For example, if channels 0 - 3 are used, the data buffer will be 0, 1, 2, 3, 0, 1, 2, 3, etc. The buffer is sized using channel count times packet size. It's the same concept for output. Let's say you have a sine wave that consists of 1024 samples. Then the triangle wave would also consist of 1024 samples. For example output_buffer = create_float_buffer(2, 1024). Next,  review the create_output_data function in the a_out_scan.py example. It has a nested loop that generates a single sine wave. The interloop iterates the number of channels. Add an IF statement to determine channel 0 and channel 1. If channel 0, generate sine data; if channel 1, generate triangle data. 

Finally, only one a_out_scan and a_in_scan can be run because there is one clock circuit for each. The device would need two clocks to run two a_out_scan functions, one for each channel.  

 

  • 0
Posted (edited)
On 7/17/2023 at 9:13 AM, JRys said:

Only one a_out_scan can be run, and likewise for a_in_scan. Consider a_in_scan. You specify a group of channels, and the data buffer it produces has interleaved channels. For example, if channels 0 - 3 are used, the data buffer will be 0, 1, 2, 3, 0, 1, 2, 3, etc. The buffer is sized using channel count times packet size. It's the same concept for output. Let's say you have a sine wave that consists of 1024 samples. Then the triangle wave would also consist of 1024 samples. For example output_buffer = create_float_buffer(2, 1024). Next,  review the create_output_data function in the a_out_scan.py example. It has a nested loop that generates a single sine wave. The interloop iterates the number of channels. Add an IF statement to determine channel 0 and channel 1. If channel 0, generate sine data; if channel 1, generate triangle data. 

Finally, only one a_out_scan and a_in_scan can be run because there is one clock circuit for each. The device would need two clocks to run two a_out_scan functions, one for each channel.  

 

Thank you for your response! I have figured out how to output 2 different analog waveforms by interleaving the data buffer. Using the nested loop provided by the a_out_scan.py example, I am able to get 2 different waves with the same frequency. I am currently working on how to make the 2 signals' frequencies different. I think I need to use different samples_per_second and change up the nested loop in create_output_data() a bit.

Edit: I figured it out. There are still some offset errors that I'm still investigating. I might ask it in a separate question. Thank you!

Edited by Charlie2134

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