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

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

what current do you need on output ? Which operating system ? Is your r2015b matlab 32 bit or 64 bit?
The instrument has an input impedance of 1 MOhm (high impedance). Considering a voltage of 10 V, the consumed current should not exceed 10 µA.
I'm working with Windows 7 64 bits.
R2015b was the last release that supported 32 bit MATLAB (which could be executed on 32 bit or 64 bit Windows.) The difference between 32 bit and 64 bit MATLAB is important for this purpose as 32 bit MATLAB was able to use the legacy Data Acquisition Toolbox, but 64 bit MATLAB needed the newer session-based Data Acquisition Toolbox. The legacy toolbox supported a number of different vendors, but back in R2015b, the newer session based interface supported only some National Instruments (NI) devices.
I suppose I should also ask whether you even have the Data Acquisition Toolbox, since it is probably tool late to purchase it now against R2015b.
If you do not have Data Acquisition Toolbox, then do you have Instrument Control Toolbox?
What is acceptable latency, and what sampling rate do you need for taking the measurements for your situation? If you do not use the Data Acquisition Toolbox then some of the most natural approaches involve adding in an Arduino or Raspberry Pi, which are inexpensive but not especially fast, and communications with either one of those is rate restricted. (If you are not using Data Acquisition Toolbox then communication to anything USB based is rate restricted to at most 1000 packets per second.)
What device are you communicating with at the moment, with what toolbox?
What sample rate do you need?
The NI USB-6001 is 2 channels of output, +/- 10V, but only 5 mA. None of their USB-6xxx series appears to handle more than 5 mA.
See the discussion at https://www.maximintegrated.com/en/app-notes/index.mvp/id/2398 about circuits for +/-10V at 10 mA, built with components and a 0-3.3V DAQ.
For the MATLAB version (32 or 64 bits) and for the Data Acquisition Toolbox, I'll tell you on monday (I don't have the computer with me).
I'm communicating with a camera using the Image Acquisition Toolbox. The camera is imaging the material. The maximum acquisition frequency of the camera is 20 Hz. MATLAB processes each image to extract the material strain. There is two strain values per image since the measurement is 2D. This processing is quite long (~1 s per image) so:
1) The strain measurement cannot actually exceed 1 Hz (instead of 20 Hz).
2) The measurement is not synchronised with the material excitation.
Consequently, it is not necessary to have a high speed communication. I just need to send two values (double format) at 1 Hz. Note that the camera is triggered by the second instrument (the one with the +/- 10V inputs) so it is possible to resynchronise everything at the end (as long as the strain processing/transmission time do not exceed the trigger period). Ideally, the transmission time should be low compared to the processing time so that the frequency limit is still around 1 Hz. Let say we want a transmission delay < 100 ms and let consider 2 values of 64 bits (double floating point), I need a transmission speed > 1280 bits/s (which is largely affordable).
The currend needed is not 10 mA but 10 µA. I guess the NI USB-6001 you mentionned is sufficient then. Regarding the Arduino option is it "plug and play" like the USB-6001? I mean, is MATLAB able to control the Arduino without pre-programming the Arduino µcontroller?
Thanks
Ah, I misread the micro-amp . 10 micro-amp should be easy to do with the voltage being more of a problem.
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.
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

Products

Release

R2015b

Asked:

on 15 Feb 2019

Edited:

on 21 Feb 2019

Community Treasure Hunt

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

Start Hunting!