Fede2712

Hi :slight_smile: I'm new in this forum. I created a program with Arduino Mega, which returns 12 values ​​related to the analog pins, ranging from 0000 to 1023, annexed to the constant "SCC200010001 " (on the serial monitor I see the same constant string repeated 12 times with only the last four values ​​that change). I want to read, with the VISA Read, only the last four values ​​of each string and insert each of these into a subVI, but when I run the program, the computer shuts down.
Someone have any ideas? This can be a problem of bytes count related to the VISA Read function? You must configure the Arduino before use with LabVIEW?

I do not know VISA Read, what the constant means or what a subVI is?

Which computer shuts down?
The PC of the Arduino MEGA

Someone have any ideas?

Can you post you code? That helps to understand the problem.
Use CTRL-T to auto format the code before copying and please use code tags.

please also update the title of your post to reflect the problem.

Hi, sorry I omitted that I'm using Labview for the acquisition data, so VISA Read is the function that returns the read buffer from Arduino reading a certain number of bytes. Instead the subvi is a subroutine in labview language. When I connect Arduino to the pc and run the program the pc shuts down.
This is the Arduino code:

#define sensor0 0
#define sensor1 1
#define sensor2 2
#define sensor3 3
#define sensor4 4 
#define sensor5 5
#define sensor6 6 
#define sensor7 7 
#define sensor8 8 
#define sensor9 9 
#define sensor10 10
#define sensor11 11
//Seleziona il PIN di input per il trimmer

int value0 = 0;
int value1 = 0;
int value2 = 0;
int value3 = 0;
int value4 = 0;
int value5 = 0;
int value6 = 0;
int value7 = 0;
int value8 = 0;
int value9 = 0;
int value10 = 0;
int value11 = 0;


void setup() {
  Serial.begin(9600);
  }//apre la porta seriale 
  
void aggiungi_zero (int x)
  {
  if (x<=9){
   Serial.print ("000");
   Serial.println (x);
   }
   else if(x<=99){
     Serial.print("00");
     Serial.println (x);
     }
     else if(x<=999){
       Serial.print("0");
       Serial.println (x);
       }
       else{
         Serial.println (x);
         }
         }
         
void loop() {
  value0 = analogRead(sensor0);
  value1 = analogRead(sensor1);
  value2 = analogRead(sensor2);
  value3 = analogRead(sensor3);
  value4 = analogRead(sensor4);
  value5 = analogRead(sensor5);
  value6 = analogRead(sensor6);
  value7 = analogRead(sensor7);
  value8 = analogRead(sensor8);
  value9 = analogRead(sensor9);
  value10 = analogRead(sensor10);
  value11 = analogRead(sensor11);
  
Serial.print("SCC200010001");
         aggiungi_zero (value0);
          delay(10);
Serial.print("SCC200010002");
         aggiungi_zero (value1);   
          delay(10);
Serial.print("SCC200010003");
         aggiungi_zero (value2);
          delay(10);
Serial.print("SCC200010004");
         aggiungi_zero (value3); 
                   delay(10); 
Serial.print("SCC200010005");
         aggiungi_zero (value4); 
                   delay(10);
Serial.print("SCC200010006");         
         aggiungi_zero (value5);
                   delay(10);
Serial.print("SCC200010007");         
         aggiungi_zero (value6);
                   delay(10);
Serial.print("SCC200010008");
         aggiungi_zero (value7);
                   delay(10);
Serial.print("SCC200010009");         
         aggiungi_zero (value8); 
                   delay(10);
Serial.print("SCC200010010");         
         aggiungi_zero (value9);
                   delay(10);
Serial.print("SCC200010011");         
         aggiungi_zero (value10);
                   delay(10);
Serial.print("SCC200010012");         
         aggiungi_zero (value11);
  delay(10);
}//Stampa il valore sulla porta seriale

This is the labview code:

Fede2712:
I want to read, with the VISA Read, only the last four values ​​of each string

It must be old age, but I could never have guessed that from the title of your Thread.

...R

Moderator: added code tags

With respect to your code, please investigate the usage of array's in C++ and loops.

Would simplify your code substantially.

See tutorial section