How to output analog voltage (+/-10V ) using usb port ?
12 views (last 30 days)
Show older comments
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
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.
Someone crowdsourced a +/-10V device but was not successful; https://www.kickstarter.com/projects/660498803/extended-dac-shield-for-arduino-eight-10v-analog-o
Ti has a circuit suggestion for converting a 0-2.5V DAQ into +/- 10V; see http://www.ti.com/tool/TIPD125
Ah it looks like https://www.maximintegrated.com/en/products/analog/data-converters/digital-to-analog-converters/MAX5322.html/tb_tab0 might be an SPI based output of +/-10V . The documentaiton of https://www.mathworks.com/help/supportpkg/arduinoio/examples/communicate-with-spi-device-on-arduino-hardware.html shows communicating with an SPI device from Arduino.
... 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.
Answers (0)
See Also
Categories
Find more on Digital Input and Output in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!