LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial PORT WRITE

Hi !
I'm doing a serial communication between pic 17f877 and labview. I want to know how to write a number between 0-255 on the port ? with the vi serial port write.
For now, on labview i can read what the pic is sending, but when i want to write on the pic through labview, its seems like the pic receive only the last number, like if i send 255, pic will receive 5 ???

its looks like labview is sending the number in ascii, i want to know how to send it in 8 bits (binary)

thanks
0 Kudos
Message 1 of 9
(4,952 Views)
Create a string, right click on it and select "Hex display" - set the value of the string to FF. Now you have the string you need to send if you want to send 255 as a byte...

Generally it might be best to operate with numbers (here U8 or I8) in the program and then just type-cast it to a string prior to sending it to the port...
Message 2 of 9
(4,952 Views)
Mads.
What do you mean by type-cast it
to a string?

Thanks,
Van
0 Kudos
Message 3 of 9
(4,952 Views)
Actually it's pretty easy to do. LabVIEW includes a function to change a byte array to a string Functions -> Numeric -> Conversion -> Byte Array to String.

All you have to do is convert the number to an array.

I have included a short VI here that takes a U8 and converts it to a string.

Rob
0 Kudos
Message 4 of 9
(4,953 Views)
Dear Robert,

I just want to ask you.
Where should I put the conversion (U8 and converts it to a string.) in my serial program?
Sould I put it after the read vi or at the start?
Here I attach the program.
Really need your help.
Please

Thanks
Hussin

0 Kudos
Message 5 of 9
(4,640 Views)
Hi MFHussein,

I'm not sure what to make of this - you initially asked about writing this hex value, but in this VI I do not even see a VISA write anywhere. Am I missing something?
-Sam F, DAQ Marketing Manager
0 Kudos
Message 6 of 9
(4,615 Views)
Dear SAmboNI,

Can you read the message that I posted at this thread
http://forums.ni.com/ni/board/message?board.id=170&message.id=235782&view=by_date_ascending&page=2
Which include more detail about what I'm going to solve.
To be honest with you I'm not really familiar with this serail configuration.
Hope you can advise me on this.

Thanks
0 Kudos
Message 7 of 9
(4,608 Views)
Hi MF Hussin,

I will let the discussion continue there. In the future, please keep all questions relating to the same issue on one thread.

Best regards,
-Sam F, DAQ Marketing Manager
0 Kudos
Message 8 of 9
(4,590 Views)

Unrelated to your specific question, but looking over your VI, I found a few problems you will have in your program.

Your top loop will only execute once because of the true constant wired to the stop node.  And it is unlikely the case structure will run unless you have the OK button pressed before you start the program.

Your bottom loop will run forever because of the false constant wired to the stop node.  The only way you will be able to stop the program is with the abort button.

0 Kudos
Message 9 of 9
(4,581 Views)