LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

License plate reader with LabVIEW and Arduino

Solved!
Go to solution

Hello everyone!

I'm currently making a project connecting Arduino to a VI in LabVIEW and I have some problems...
Note that I'm just a beginner and there's a lot of things that I don't really know, and I'm kinda lost so just asking for help.
I just want to make like a parking barrier that stores data in an excel, and just there I encounter one of my current problems, the dimension of the source is 1 and the dimension of the sink is 2. Is there any way I can make the source convert to a 2 dimension array?

The second problem comes with the arduino communication. I just want that when the camera reads a plate from a car sends a signal to one of the arduino pins and move a servomotor. Right, so moving the servomotor only with arduino program is easy, but I just don't know what blocks and connections I have to do to send it to arduino...

 

I already trained the ocr and all that, so yes, the program is actually reading those license plates.


Here is my program in labview:

Zuzguluddi_1-1746301644436.png

 

And here is the arduino code:

#include <Servo.h>

Servo barrera;
const int pinServo = 9;

void setup() {
  Serial.begin(9600);
  barrera.attach(pinServo);
  barrera.write(0);     // posición barrera abajo
}

void loop() {
  if (Serial.available()) {
    Serial.println("Puerto serial disponible");
    char c = Serial.read();
    if (c == '1') {
      Serial.println("Subiendo barrera");
      // sube la barrera
      barrera.write(90);
      delay(3000);        // deja la barrera abierta 3 s
      barrera.write(0);   // baja la barrera
    }
  }
}
If you could provide some help it would be very much appreciated😁
0 Kudos
Message 1 of 6
(381 Views)

The first question, how do you turn a String into a 2D Array of String, is easy.  You've done half of it -- you turned a String into a 1D Array of String.  Now turn that 1D Array of String (using the same technique) into a 2D Array of String.

 

Or you could do it in a single step -- use Initialize Array to initialize a 1x1 Array.

 

String to 2D Array of String.png

Bob Schor

0 Kudos
Message 2 of 6
(310 Views)

I see several general problems that might not function the way you think they should:

 

altenbach_0-1746368140396.png

 

 

  • A >0 string comparison will do a lexical comparison, not a numeric comparison. What are you actually trying to detect here? For example a string of "?" would be >"0", right? Do you want to maybe see if the string is empty?
  • Once that comparison is true, you configure a new serial connection and trap all code inside an inner loop until the user interacts. While that inner loop is running, the outer loop cannot proceed to the next iteration.
  • etc. etc.

Maybe you want to rearchitect this as a simple state machine instead.

0 Kudos
Message 3 of 6
(301 Views)

 

Right, so it looks that I need to understand some basic things yet...

Just what I want is that if the machine reads a plate, activates the arduino signal, maybe it will be good like this the conversion?

Zuzguluddi_1-1746430297148.png

Decimal string to number?

0 Kudos
Message 4 of 6
(266 Views)
Solution
Accepted by topic author Zuzguluddi

Maybe it is because I learned programming with Text-based languages (my favorite was Pascal) that when I started learning LabVIEW (about two decades ago), I quickly stopped using the Number/String Conversion functions and settled on "Format into String" and "Scan from String" functions.  Particularly when you are dealing with data from Arduino coming in over VISA (where Best Practice says "Read an entire String in a single command" by using a Termination Character (typically <LF>) and a VISA Read of 1000 (or 1024) bytes (expecting a much smaller string whose length is in the range of 10 to 70 bytes, usually).  Now you just need to know how the data are separated ("punctuation" such as commas, tabs, or header strings such at "Width = 5 inches   ", where you want the number "5" as an Integer).

 

Take a look and see if this works for you.

 

Bob Schor

0 Kudos
Message 5 of 6
(252 Views)
Solution
Accepted by topic author Zuzguluddi

@Zuzguluddi wrote:

 

Right, so it looks that I need to understand some basic things yet...

Just what I want is that if the machine reads a plate, activates the arduino signal, maybe it will be good like this the conversion?

Zuzguluddi_1-1746430297148.png

Decimal string to number?


No, in many countries license plates are a combination of letters and numbers. You need to look at the string and decide what is valid.

0 Kudos
Message 6 of 6
(235 Views)