LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to establish serial communication between Labview and Arduino Duemilanove board

I am trying to establish a serial communication between Labview 8.6 and Arduino Duemilanova board via USB. I read that USB is the same as RS-232 serial communication just that the USB has a built in USB/RS-232 adapter in it. Please correct me if I am wrong.
I tried to establish the communication using Labview's Basic Serial Write and Read vi example however it was not successful.
 
In the String to write box on front panel of labview, do I need to specify a string or a command that is used to program the Arduino board via the Arduino software?

Any help will be appreciated. I am new to Labview, so please give as much detail as possible when responding.

Thanks
Max
Message 1 of 35
(26,866 Views)

No, you are not correct at all that USB is the same thing as RS-232. A USB connection on an instrument may emulate an RS-232 but that is actually pretty rare, I believe. Some instruments will use the USBTMC (Test & Measurement Class) and if that's the case, then simple VISA Writes and Reads will work. Other instruments will use other USB classes (such as HID). You need to ask the vendor or if they provided a driver and .inf file, look there to see what is being used. Some basic understanding of USB might be in order. See http://www.usb.org/home.

0 Kudos
Message 2 of 35
(26,852 Views)

I have a better felling that when you are using the communication example that you are just having a variable communication error.    Break out that boards manual and go read if there is a standard communication string that can be sent like "Hello", that will send a response back to the PC. 

 

Also, when you are doing this use the continuous run and not the 1 time run.  It takes some time for things to respond, and a single run may not give the desired results. 

 

0 Kudos
Message 3 of 35
(26,836 Views)
Using the continuous run button is not correct at all. It causes more problems that it solves and beginners especially should avoid it. If it takes time for an instrument to respond, then additional wait is needed after the write. It is not correct to send the command again and again.
0 Kudos
Message 4 of 35
(26,831 Views)

Dennis,

 

He is just trying to establish communication with it.   I am not telling him to do that forever,but just to get the dang thing to talk.  He isn't going to break it or set it on fire, or anything like that.  The worst it can do is throw some error code his way while he tries different things... which may make him a happy little man.  

 

Its good for a novice to do this kind of stuff, but bad when you and I do it (or have to do it).  They can learn form it, and can screw around and have some fun with it too.  

 

0 Kudos
Message 5 of 35
(26,823 Views)

You don't get the point at all. A failure to get a response is not going to be solved by repeating the VI over and over again especially when the op has a basic misunderstanding of USB instruments. If it was a simple timeout, then the wait in the example can be increased. If the command being sent is incorrect, it won't be fixed by a continuous run either. Run continuous really accomplishes nothing to fix the problem or to diagnose it. Don't you think that the op might have clicked the run once button more than once? How is that any different than running it continuously?

 

And I don't agree at all that it is good for the novice to use the run continuous button. It's far better for the novice to learn how to use a while loop if some code is to be repeated. 
0 Kudos
Message 6 of 35
(26,816 Views)

Have you installed the Arduino Core software and communicated successfully with the board? If so, you're nearly there.

 

The Arduino Duemilanova board uses an FTDI USB to serial UART interface module to communicate between the board and your PC. Serial here refers to the TTL level serial pins at the Arduino end of the link. At the PC end, the connection is thru the USB Universal Serial Bus Controller. To expose the link, the FTDI Driver poses as a virtual serial port that lets the board connect to your application software with a COM port.

   

To set the COM number for the Arduino Core software, or to see the actual port being used, click on Tools/Serial Port in the Arduino Core app. 

 

To make a connection between LabVIEW and the Arduino, you'll need to load a program onto the Arduino that will use the port. Using the Arduino Core software, try uploading the Sketchbook/Examples/Communications/ASCIITable program and connect to the board with the Excitable Arduino serial monitor. You'll see the app start by itself and scroll thru a list of ASCII characters. Close the Arduino serial monitor and close the Arduino Core app.

 

In LabVIEW, load the "Advanced Serial Write and Read.vi" from the NI Example Finder. Set the VISA resource to the COM port used by the Arduino Core. Leave all the other controls at their default values. Run the VI and see the same display as before.

To further explore communication with the Arduino, build a sketch that listens at the Arduino for a serial message or use the Dimmer example which wants you to send a single character followed by a carriage control to change the LED.

 

If you want to actually deploy programs for the Arduino with LabVIEW, you'll need to master the Arduino bootloader or the command line editor to get the program loaded onto the Arduino.

Message 7 of 35
(26,753 Views)

"Have you installed the Arduino Core software and communicated successfully with the board?"

 

I am working on a similar project and I did got the Arduino software to communicate with my Arduino Mega board.

 Here is the C code example I got from the web.

Can someone please guide to to use this with labview?

 

How would I display what the C code displayed Labview?

 

#include <LiquidCrystal.h>

// Connections:
// rs (LCD pin 4) to Arduino pin 12
// rw (LCD pin 5) to Arduino pin 11
// enable (LCD pin 6) to Arduino pin 10
// LCD pin 15 to Arduino pin 13
// LCD pins d4, d5, d6, d7 to Arduino pins 5, 4, 3, 2
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

int backLight = 13;    // pin 13 will control the backlight

void setup()
{
  pinMode(backLight, OUTPUT);
  digitalWrite(backLight, HIGH); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.
  lcd.clear();                  // start with a blank screen
  lcd.setCursor(0,0);           // set cursor to column 0, row 0 (the first row)
  lcd.print("Hello, Tuan");    // change this text to whatever you like. keep it clean.
  lcd.setCursor(0,1);           // set cursor to column 0, row 1
  lcd.print("You Rock!!!!");
 
  // if you have a 4 row LCD, uncomment out these lines to write to the bottom rows
  //lcd.setCursor(0,2);         // set cursor to column 0, row 2
  //lcd.print("Row 3");
  //lcd.setCursor(0,3);         // set cursor to column 0, row 3
  //lcd.print("Row 4");
}

void loop()
{
}
 

Best regards,
Krispiekream
0 Kudos
Message 8 of 35
(26,238 Views)
That code appears to be using some hardware to drive it (a micro?). What are you planning to use? There also appears to be quite a bit missing in that code fragment.
0 Kudos
Message 9 of 35
(26,232 Views)

woww that is some fast response....

that code is C.

its an LCD Example to make the Arduino Mega microcontroller Atmega1280 chip to display into an LCD.

I got it to say 

"Hello Tuan, You Rock!!!... on the LCD.

How Would I display that on Labivew string indicator or vice vista?

Do you have any clue?

I haven't done anything like this, maybe someone have and can help me out.

 

Best regards,
Krispiekream
0 Kudos
Message 10 of 35
(26,220 Views)