How to output analog voltage (+/-10V ) using usb port ?

12 views (last 30 days)
Hi,
I have a matlab program that communicates with an instrument to measure the strain of a material under test. It is a real time measurement. The strain values are stored in a vector, in Matlab workspace (R2015b). Of course, the vector grows in size as function of time. Until here, no problem.
I need to send the strain values to another instrument, in real time also. This instrument has an +/- 10V analog input. I would like Matlab to use a USB port for the data transfer. The connection would be something like:
MATLAB ----> USB ----> Digital/Analog Converter ----> +/- 10V signal
What I don't know is:
1) Is there an easier solution to create a +/- 10V signal with Matlab?
2) How to send data (a vector or matrice) to a USB port? What are the basics functions for that?
3) Is there USB Digital/Analog Converters that can communicates with Matlab?
4) How the Digital/Analog Converters and MATLAB can understand each other?
Many thanks!
  9 Comments
Walter Roberson
Walter Roberson on 16 Feb 2019
Edited: Walter Roberson on 16 Feb 2019
The age of your MATLAB leads to complications. In R2015b, the Data Acquisition Toolbox for 64 bit MATLAB supported only some National Instruments devices, and the Digilent Analog Discovery device.
The Digilent device is interesting, but would require a voltage doubler (it is +/- 5V). However it is no longer sold by Digilent, replaced by the Analog Discover 2, which requires R2018b or later.
The National Instruments boards are rarely the fastest or least expensive boards on the market, but support for them is pretty well developed. In R2015b, the 64 bit MATLAB "session based" interface did support the USB-6001 device I mentioned before, which directly supports +/- 10V.
For the data rates that you need, Arduino or Raspberry Pi would do fine for rate. However neither of them is as "plug and play" for analog output. For both of them, the built-in analog outputs are fixed voltage with PWM, and the voltage range is not very high (0-5V) . There is discussion at https://www.instructables.com/id/Arduino-RC-Circuit-PWM-to-analog-DC/ showing how to smooth out a PWM to a flatter continuous response using an RC circuit, but that in itself will not get you negative voltage. https://www.amazon.ca/Digital-Analog-Signal-Tranformer-Konverter/dp/B00UIZKYAS has an inexpensive device to convert PWM to 0-10V, but again no negative voltage.
Direct negative voltage on Arduino or Raspberry Pi would probably involve installing a small I2C based chip -- though finding one that handles negative voltage is not easy. https://store.ncd.io/product/1-channel-0-10v-dac-digital-analog-converter-i%c2%b2c/ has a 0-10V I2C chip.
Ti has a circuit suggestion for converting a 0-2.5V DAQ into +/- 10V; see http://www.ti.com/tool/TIPD125
... As a quick summary then, if you follow the examples about communicating with I2C or SPI devices for Arduino or Raspberry Pi, then for the rates you need, the software should not be difficult. Finding an appropriate hardware device to handle the range you need might be more of a problem. Still, if you have not worked with Arduino or Raspberry Pi before, you would have to allocate some time to working through the kinks. If you had needed significantly higher rates then Arduino and Raspberry could involve higher learning curve.
The NI USB-6001 will do +/-10V for sure, if you have the Data Acquisition Toolbox. If you do not have that, then getting it now would be expensive, as you would have to update your MATLAB to the current release in order to be eligible to purchase the Data Acquisition Toolbox. Update to the current release for purchasing purposes, that is: if you had reasons to stick with R2015b then buying a current license would permit you to continue to use any older release.
Valentin Segouin
Valentin Segouin on 20 Feb 2019
Edited: Valentin Segouin on 21 Feb 2019
Firstly, thank you very much for your very documented reply. I think I understood every solution you mentionned. As discussed, see below what MATLAB answer to the "ver" command:
----------------------------------------------------------------------------------------------------
MATLAB Version: 8.6.0.267246 (R2015b)
MATLAB License Number: xxxxxx
Operating System: Microsoft Windows 7 Professional Version 6.1 (Build 7601: Service Pack 1)
Java Version: Java 1.7.0_60-b19 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
----------------------------------------------------------------------------------------------------
MATLAB Version 8.6 (R2015b)
...
Data Acquisition Toolbox Version 3.8 (R2015b)
...
So I guess the Data Acquisition Toolbox is installed. I will use something like the NI USB-6001. I think the Arduino or the Raspberry will take me a lot of time to set up. Also, I will ask to our informatic department if it is possible to buy a licence for the R2018b version so that it will extend the possibilites (for instance, the Analog Discover 2 you mentionned).
Thank you again for your help.

Sign in to comment.

Answers (0)

Categories

Find more on Digital Input and Output in Help Center and File Exchange

Products


Release

R2015b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!