04-12-2009 12:08 PM
04-13-2009 09:42 AM - edited 04-13-2009 09:42 AM
Ok.
I am trying out this example code from Arduino to write to a Serial port.
I think its writing to my computer USB Serial port , Com 5.
I want to read the bytes/hex/dec/bin of the data coming out of the serial to Labview.
I just want to display it on Labview screen for now.
The problems I am having.
1. The Arduino board only have 1 USB cable plugged in, in order for me to upload the Arduino board to the I/O board, Arduino needs to have access to it.
2. When I try it on LAbview, it said that the Com is Valid, but Visa doesn't have access to it? (maybe because the Arduino board is still writing to the serial?
Can you point me to the right direction on this.
// ASCII Table
// by Nicholas Zambetti <http://www.zambetti.com>
void setup()
{
Serial.begin(9600);
// prints title with ending line break
Serial.println("ASCII Table ~ Character Map");
// wait for the long string to be sent
delay(100);
}
int number = 33; // first visible character '!' is #33
void loop()
{
Serial.print(number, BYTE); // prints value unaltered, first will be '!'
Serial.print(", dec: ");
Serial.print(number); // prints value as string in decimal (base 10)
// Serial.print(number, DEC); // this also works
Serial.print(", hex: ");
Serial.print(number, HEX); // prints value as string in hexadecimal (base 16)
Serial.print(", oct: ");
Serial.print(number, OCT); // prints value as string in octal (base 😎
Serial.print(", bin: ");
Serial.println(number, BIN); // prints value as string in binary (base 2)
// also prints ending line break
// if printed last visible character '~' #126 ...
if(number == 126) {
// loop forever
while(true) {
continue;
}
}
number++; // to the next character
delay(100); // allow some time for the Serial data to be sent
}
04-13-2009 09:54 AM
Okay, so you don't want to control the board with LabVIEW? You just want to monitor what a different program is writing? You won't be able to do that because the OS reserves the port for a single process and you get the error.
It would make more sense for you to cotnrol what is written with LabVIEW.
04-13-2009 10:31 AM - edited 04-13-2009 10:32 AM
Okay, so you don't want to control the board with LabVIEW? You just want to monitor what a different program is writing? You won't be able to do that because the OS reserves the port for a single process and you get the error.
It would make more sense for you to cotnrol what is written with LabVIEW.
Well, the way I was thinking is...If I can get Labview to Read what the other board is reading..I can work around it to Write to the board.
But...
ULTIMATELY, I want to Write the String from Labview to the LCD Module to the Arduino board. That is my ultimate goal for this project.
That is the reason why I pasted the sample code at the beginning to display the string to the LCD.
my project is to take a webcam, scan the bar code. and display it on the LCD module. (that's what my teacher wants)
I already completed the webcam scanning of the bar code...
all I need is to learn how to display it through the USB serial port.
04-13-2009 10:39 AM
Did you read this? It sounds to me that all you have to do is close the serial program you are using and use one of the LabVIEW examples.
The sample code at the beginning has nothing whatever to do with serial communication and nothing at all to do with the example serial program you are using.
If you want to display an actual bar code, you need to verify whether the LCD supports this. If you want to display the decoded bar code, then that should be just a matter of doing a VISA Write.
04-13-2009 10:44 AM
"If you want to display the decoded bar code"
Oh yes, thats what I wanted to do...
I have decoded the bar code using Ni Vision and my Region of Interest.
Now, I want to write to VISA and display it on the Arduino board.
I haven't used C in a really really long time.
The first time I used it, i wasn't good at it either..
04-13-2009 10:57 AM
04-13-2009 11:14 AM
The way I made it work in my circuit, is that my USB is connected to the Arduino board, and I have created a RS-232 connection which communicates between LAbview and the Arduino board. I used maxim 3323 chip to make the RS-232 connection. To display the information in Labview, there is an example that shows you what you get form the arduino board, it is called simple write and read vi under the example folder in Labview. For my project i needed to display some info to an external 2X16 LCD, i used the "hello world" example in the Arduino library and then customized it to my needs (I also used an interrupt to reduce the delay).
Hope this helps
Max
04-13-2009 11:52 AM
I was trying it out during the last hour and didnt get back to you.
Sorry Dennis, but yeah, the post you mentioned for me to read works like a charm.
I got it to Turn on and off the LED using Labview through the Arduino board.
I am on my way of working this to work with the decoded bar code from Labview to the Arduino board.
04-13-2009 03:49 PM
Dennis,
I need your help again..
okay, so I got it to write from Labview to Arduino LCD.
From the Arduino software. I can write to LCD 1 time and display it once.
But when I am using the Advanced Serial Write and Read function on labview, it write to the LCD multiple times until i press STOP.
it must be the while loop.
I tried taking that out, but it doesnt let me continuously input in new data through the serial.
do you have any suggestions?