Jump to content
  • 0

Problem with analog output on USB-231 DAQ



⚙️ Hardware details

I am using the USB-231 USB data acquisition (DAQ).

💻 Software details

  • OS: Windows 10 Home, Version 21H2
  • 64-bit operating system, x64-based processor
  • Python version: 3.9.10
  • Python library concerned : mcculw
  • Python library method concerned: ul.a_out_scan

🤔 What am I trying to do ?

The USB 231 has two analog output channels.
I am storing voltages to be outputted in python lists. For example :

array1 = [1,2,3]
array2 = [4,5,6]

array1 in intended for channel number 0 and array2 is intended for channel number 1. I wish to send each voltage as a square wave of 200 Hz (the square wave oscillates between +voltage and -voltage). Going ahead with the above example, I wish to send :

1V to channel 0 at 200 Hz,
4V to channel 1 at 200 Hz,
2V to channel 0 at 200 Hz,
5V to channel 1 at 200 Hz

so on and so forth.

😔 What exactly is the problem ?

Voltages appear in each channel, but the voltage sign is not consistent. So, if my array contains 1V, I can see only +1V and I can't see -1V at all. I have done the interleaving of voltages to output each array for the corresponding channel. So, the final interleaved array has +1V and -1V repeated 200 times. But the -1V is not outputted by the DAQ at all. Sometimes one channel outputs only positive voltages and other only negative voltages.

👨‍💻 What have I done till now ?

Created a script based on the a_out_scan.py example script to achieve the goal. Since I didn't get the expected output, I have tried the following:

  • Changing ul.win_buf_alloc to ul.scaled_win_buf_alloc
  • Changing the ctype array from u_short to other types.

But I had no success with these.

🔎 Script/code ?

Here is a link to my script.

📝 Any specific note ?

I prefer to use the ul.a_out_scan method instead of ul.a_out method, since I can specify the rate as a parameter in ul.a_out_scan method. Using ul.a_out_scan is a better way to generate precise signals than using the ul.a_out along with something like Python's time.sleep() method.

🔬 Any other observations ?

I have observed that the sign of output voltage varies when I change the rate parameter of ul.a_out_scan. I don't think this is an expected behavior.

Edited by Sid_1
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0


The a_out_scan buffer channels must be interleaved. Attached is my python script that generates a 1000 Hz square wave on both channels. The channels output a +/-10 volt square wave. In D/A counts, the values are 0 for -10 volts and 65535 for +10 volts. 32767 is zero volts. Each volt is roughly equal 3276 counts. 

best regards,



Link to comment
Share on other sites

  • 0

Hi JRys. Thanks for the solution. I really appreciate that.

The rate parameter seems to be not working in your program.

For example, this is what I had in my previous program:

Let's say rate = 200, points_per_channel = 2000. Then the scan used to get over in 10 seconds.

But in your program, the scan doesn't seem to end. I have to end it manually using Ctrl+C.

Edited by Sid_1
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...