LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with Saving data to arrays or tables!

Hello Comunity,

Im Kind of new to Labview... 
I'm working in a proyect with Arduino and Labview... All the arduino code is almost done... The comunication is via Serial.... I'm using VISA.
Let me explain a little bit:

Arduino Code moves a stepper motor limited by, high/low sensors...
Via Labview I send letters... "char"(Using pushbuttons and events) .. to the arduino to activate some options... No problem there.... 
One part of the project needs to obtain "time" from the arduino from 9 laser sensors..... just the timea little ball passes through.... (Code in arduino is done and running)...
What I cant do is save this data...Well... I actually saved it... but it sends infonon stop, so when the sensors are activated, I can see this info for a secondand then it saves in a larger Array filled with ceros (Cause, as I said It reeds non stop).
What I need is for the data start/stop reading just when I need it to... 
I tried with Case.. but with no succes... I tried with an event linked to a "Runing" button.. but nothig... 
Please help.. I ran out of ideas and I'm sure Im doing something wrong...
I hope u can understand me... thanks a lot!

0 Kudos
Message 1 of 2
(1,993 Views)

There are numerous things wrong with your VI.  Here are some suggestions to help you design it better:

  • Write some documentation that says What you want to do.  Don't worry about how to accomplish this, just paint "Broad Strokes".  Looking at your code, I'm uncertain that I understand the "What".
  • LabVIEW, because it uses a Data Flow paradigm, can undertake Parallel Processing.  When you write the Documentation, keep this in mind and describe the various parallel Tasks you want to accomplish.  Example of a Task is reading from the VISA device (I presume this is the Arduino) -- my guess is you want to "read continuously" (until you decide to end the program), but possibly only (in a parallel task) process some of the data.
  • A common mistake beginners make with VISA is not paying attention to the Configure Serial Port function, the first one you use.  Read its Help.  Notice you have "Use Termination Character" set, by default (this is good, but you did it "by accident").  Notice that the default termination character is a Line Feed.  Is this what the Arduino sends when it sends you data?  [If the Arduino is not sending a "terminated String", i.e. a string followed by <CR>, <LF>, or <CR><LF>, then fix it so it does!).  Why does this matter?  Because you do not want to use "Bytes at Port", but rather configure your VISA Read to read, oh, 1000 bytes, knowing it will stop reading and return the "terminated String" to you when it finishes getting the entire message from Arduino.
  • The easiest, and most "user-friendly" (= understandable, = maintainable) way to parse a String is to use "Scan from String".  It would also be a Very Good Idea (for someone who might want to help you) to make a Free Label (a.k.a a Comment) in your code that says "Expected String:  "4 minutes, 23.1 pounds, -23.4 inches, hair color = brown" from which you want to extract the numbers 4, 23.1, and -23.4 and the string "brown".This can be done with a single Scan From String function with a single Format statement.  Read the Help for the function.
  • When you write the Documentation, describe any timing considerations ("The Arduino will send data consisting of a String of about 20 characters every second.  When we get the Start Command, we want to save 20 seconds of Arduino data to disk, plotting the (20) points on a graph, wait 15 seconds, then do it again until we get the Stop Command").
  • I notice your code has the VISA line branching and being read from two (parallel) VIs.  This will only cause you grief!

Bob Schor

Message 2 of 2
(1,979 Views)