LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble reading multiple analog inputs with LIFA

I am having trouble reading multiple analog inputs through an Arduino.  It seems like the signals are leaking into eachother.  I get very similar readings across each each of the pins and readouts.  At the moment I'm just using a 10k pot as a voltage divider for my sensor and only have it connected to one port at a time.  That may be the issue, I'm not too sure.

  I want to have multiple analog sensor which if they reach a threshold will produce a warning and stop the program.  This code is modified to not stop when the threshold is met, but I'm sure you see where I'm headed if I wire the output of the or array to the stop.   Any advice would be greatly appreciated. Thanks

MultipleAnalogIssue.JPG

0 Kudos
Message 1 of 12
(20,700 Views)

jdskier1,

This is a common issue with the arduino and any other device that uses a multiplexer with an analog to digital converter.

When you want to read an analog voltage the voltage needs to be digitized.  This is accomplished with an analog to digital converter.  While the arduino uno has six analog input pins it only has a single analog to digital converter (ADC).  A multiplexer is used to allow the ADC to "scan" through all of the ports so as far as the user is concerned you have six independed analog inputs.

When you attach a signal to one of the analog input pins but leave the others floating you may get something called ghosting.  Ghosting is where the signal attached to one channel is visible on the other channels using the same multiplexer (for the arduino all six use the same multiplexer).

You can fix using several different methods, the easiest of which is to tie all lines to something (ground, +5v, another signal...).  When you have all four signals attached you should not see this ghosting. 

Below are some links that contain more information about ghosting and other noise sources to consider when sampling analog voltages.  Its a lot of information but explains a not about sampling noise and how to clean up your samples.

Field Wiring and Noise Considerations for Analog Signals

http://zone.ni.com/devzone/cda/tut/p/id/3344

How Do I Eliminate Ghosting From My Measurements?

http://digital.ni.com/public.nsf/allkb/73CB0FB296814E2286256FFD00028DDF

Let us know if this helps.

-Sam

LIFA Developer

0 Kudos
Message 2 of 12
(6,324 Views)

Hi Sam,

I´m trying to read 2 digital ports from the Arduino via LabView. Could it be possible, that i get the same issue as described above? Because when reading one digital port i get the correct result. But when 2 digital ports are being evaluated I get strange results. Might that be due to the ghosting you described above?

What can I do to read multiple digital ports on the Arduino via Labview in a nearly realtime environment? I use timed loops with a 10ms sampling rate.

THX for any help.

Best regards,

Jan

0 Kudos
Message 3 of 12
(6,324 Views)

Jan,

What you are seeing is not the same issue as the analog inputs.  The ghosting you see on analog inputs does not effect digital inputs in the same way.

What you are seeing is likely due to your use of timed loops (assuming you are actually using the 'Timed Loop' and not a loop with timing in it).  The proper timed loop in LabVIEW is only meant for use on a real time operating system (for example on a compact RIO).  You should never use this on windows because windows is a non-deterministic operating system, so even if your timed loop completes in time once you never know if it will always return in time.  The communication loop rate of LIFA is around 150Hz when connected via USB so I would not expect you to ever maintain a timed loop rate of 10ms in LV.

Try reading two digital inputs in a non timed loop and just let it run as fast as possible.  Let us know if you see the same problems.  If you are curious about the loop rate there are loop timing VIs included in the Arduino Utility palettes.

-Sam

LIFA Developer

0 Kudos
Message 4 of 12
(6,324 Views)

I am new at Labview and I would like to read multiple analog inputs as it appears you have done above. To read multiple inputs did you need to change the LIFA arduino code or did you just do it through labview?

0 Kudos
Message 5 of 12
(6,324 Views)

hello jdskier1, i think that i kwon what is your problem you are conecting in serie your analog read, the solution that i use, was conecting the the analog read in arduino in pararel  and each one I connected to his corresponding arduino out... like in the vi multiples analogos.png

0 Kudos
Message 6 of 12
(6,324 Views)

Hello Sammy_K

I'm having the same problem with digital inputs. There are some strange results. I've tried with several "digital read pin.vi" and "digital read port.vi" and got the same problem.

When I change the state of the input, other ports changes their values. How should I proceed?

Thanks in advance.

Philipe

Sem título.jpg

0 Kudos
Message 7 of 12
(6,324 Views)

Hi Sammy

Question for you: If I want to perform a continuous multichannel AI, how should we configure the Arduino? What is fastest rate in case of above example. I see sampling rate issues when I go above 5 Hz on Arduino Mega when using 2 channels AI read.

On the same line, Can I simultaneously control SPI channel and perform AI, DI and DO. Could you give an example?

Thanks

RY
0 Kudos
Message 8 of 12
(6,324 Views)

Hey, i tryed to put them in paralel like you, and is the same problem, nothing changed. What else can I do ?

0 Kudos
Message 9 of 12
(6,324 Views)

I don't have any other suggestions for modifying LIFA to get it to read multiple analog channels.

hrh1818

0 Kudos
Message 10 of 12
(6,324 Views)