LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview showing zero analog voltage values from arduino

Solved!
Go to solution

Im trying to read values of two EMG sensors from my arduino UNO, on the serial monitor I get correct values of the readings but when i view them on waveform chart in labview, i continuously get zero values.

I also get this error when I press stop: 

 

Error -1073807360 occurred at VISA Clear in test2.vi

Possible reason(s):

VISA: (Hex 0xBFFF0000) Unknown system error (miscellaneous error).

 

i read the website support details but im still confused, since the VISA resource name ive specified is the arduino COM port. im new to labview so any help will be appreciated

Download All
0 Kudos
Message 1 of 12
(2,000 Views)

Hi,

 

you know you cannot have two programs watch the same COM port at the same time?

Use either LabVIEW or that SerialMonitor, but not both at the same time!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 12
(1,980 Views)

Yes I didn't open both serial monitor and labview at same time but checked the readings on serial monitor first to check if there was an issue in my hardware, and after closing the serial monitor i ran labview. But it still gave me the error

0 Kudos
Message 3 of 12
(1,968 Views)

Do you have any explanation why you would wire the iteration terminal to the read count input of VISA read?

0 Kudos
Message 4 of 12
(1,946 Views)

I was following this tutorial for the block diagram:

https://m.youtube.com/watch?v=bLUbCD1EcHQ

To be honest, I'm not sure why they did that in the video either

0 Kudos
Message 5 of 12
(1,915 Views)

Can you share the code for the Arduino? There are certainly things we can do to simplify this or make it more clear.

 

Without that information, this is the best cleanup I can do to your code:



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 12
(1,892 Views)

your method seems to have worked and im getting proper readings now. however im curious why stopping the simulation and then running it again gives an error and then gives zero values again. its only when i close the VI and disconnect my arduino and open the VI again does the simulation work. i was also wondering if removing the wait of milliseconds in your block diagram will affect the rate at which i get my readings

here's my arduino code:

 

int END = 5;
int IN7 = A2;
int IN8 = A3;
int emgPin1=A5;
int emgValue1=0;
int emgPin2=A0;
int emgValue2=0;

void setup() {
  Serial.begin(9600);
  pinMode(END, OUTPUT);
  pinMode(IN7, OUTPUT);
  pinMode(IN8, OUTPUT);
}
void loop() {
  // put your main code here, to run repeatedly:
  long total=0;
  for(int i=0; i<10;i++)
  {
    total+=analogRead(emgPin1);
    delay(2);
  }
  emgValue1=total/10;
  //Serial.println("1st: ");
  delay(2);
  // second sensor
  long total2=0;
  for(int i=0; i<10;i++)
  {
    total2+=analogRead(emgPin2);
    delay(2);
  }
  emgValue2=total/10;
  //Serial.println("2nd: ");
  Serial.println(emgValue1);
  Serial.println(emgValue2);
}
0 Kudos
Message 7 of 12
(1,882 Views)

@Fai wrote:

your method seems to have worked and im getting proper readings now. however im curious why stopping the simulation and then running it again gives an error and then gives zero values again. its only when i close the VI and disconnect my arduino and open the VI again does the simulation work. i was also wondering if removing the wait of milliseconds in your block diagram will affect the rate at which i get my readings

here's my arduino code:


Sounds like you're Aborting the VI with the red circle? That often leaves the com-port open as you haven't closed it properly. As someone said: Using the Abort button to stop a VI is like using a tree to stop your car, it works but it has unexpected consequences.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 8 of 12
(1,769 Views)
Solution
Accepted by topic author Fai

I would make a teak to how you write your values over the port. To make sure you have proper synchronization with the values, combine them into a single write:

  Serial.println(emgValue1 + "," + emgValue2);

 

Now you will have a single message with both values separated by a comma. No more guessing if you got the order correct. On the LabVIEW side, you only need a single VISA Read. Use Scan From String to parse the data.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 9 of 12
(1,752 Views)

Hi,

 


@crossrulz wrote:

combine them into a single write:

  Serial.println(emgValue1 + "," + emgValue2);

I hope you live in a country where "English" regional settings apply.

Otherwise I would prefer to separate the values with a semicolon and set the format string to include "%.;"!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 10 of 12
(1,747 Views)