LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to use Labview control Arduino to output analog signals

Hi,

I have a problem when doing my project now. I have to use Labview to control Arduino Uno to output analog signals such as sine waves in low frequencies, but I know Arduino can only output PWM waves. Do you have any ideas about how to convert PWM output to analog output by using Labview. Do I also need to build a circuit like low pass filter to achieve this?

Thank you!

0 Kudos
Message 1 of 11
(4,592 Views)

Nevermind, I thought the Uno had an Analog Out pin

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 11
(4,563 Views)

Yes, but they can only output PWM... 

0 Kudos
Message 3 of 11
(4,554 Views)

Well one of the common things we do to get a variable DC level from PWM is put a capacitor followed by an op-amp buffer on the PWM output.

 

By changing the PWM it charges the cap to differing levels giving you a nice variable DC output.

 

Now I guess it might be possible to use a similar circuit  (you will have to experiment with cap values) and with some clever programming change the PWM up and down at a rate that it may produce a sinusoidal output.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 11
(4,550 Views)

Thank you for your advice! I'll try this and see if it works.

0 Kudos
Message 5 of 11
(4,546 Views)

This page gives a pretty good explanation of the circuit I was describing  

 

ARDUINO-LM358-PWM-to-ADC-Functional-Description

========================
=== Engineer Ambiguously ===
========================
Message 6 of 11
(4,542 Views)

Thank you very much! I tried just now and it worked well!

0 Kudos
Message 7 of 11
(4,531 Views)

Hi, you can use also another way. Create in LabVIEW a Case Structure inserting as control a U8 knob. Then create 255 cases and in each case create with 8 numeric constants (Value 0 or 1)  to represent 8bit binary code of the decimal input. Each constant value send via wire in labview at the digital write input to arduino  block (8 blocks, 1 for each digit) which will represent Digital out pin in arduino. Choose 8 pins in arduino (2-9) not DO and D1 (tx,rx) to not interfere with labview serial communication. Then built a 8- bit DAC R2R network with 10kohm and 20kohm resistors at the arduino side. Then run your code in LabVIEW. At the DAC output you will have an analog output with steps of 5V/255= 20mV when you increment by 1 the U8 knob. If you want less resolution you can create 4, 5, 6, 7 bit DAC un the same way. It is up to you. Hope can help!

0 Kudos
Message 8 of 11
(4,142 Views)

@1001 wrote:

Hi, you can use also another way. Create in LabVIEW a Case structure insterting as control a U8 knob. Then create 255 cases and in each case create with 8 numeric constants (Value 0 or 1)  to represent 8bit binary code of the decimal input. Each constant value send via wire in labview at digital write input to arduino  block wich will represent Digital out pin in arduino. Choose 8 pins in arduino (2-9) not DO and D1 (tx,rx) to not interfere with labview serial communication. Then built a 8- bit DAC R2R network with 10kohm and 20kohm resistors ate the arduino side. Then run your code in LabVIEW. At the DAC output you will have an analog output with steps of 5V/255= 20mV when you increment by 1 the U8 knob.


Even if you wanted to do this, you absolutely should not use 255 nearly identical cases to carry out the LabVIEW side.

Use something like Number to Boolean Array, and a For loop over the booleans and the Digital Pins of the Arduino. Since the LIFA (is that the right package) toolkit uses numbers (not booleans) for the digital outputs, you may also need the Boolean to 0,1 node.

No cases required.


GCentral
0 Kudos
Message 9 of 11
(4,135 Views)

Thanks for your reply 😀! I used this solution I showed from some years but never gave me problems. I'm an electrical engineer and not a programmer😃

0 Kudos
Message 10 of 11
(4,130 Views)