Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Length of string to send via RS232

I've used the "Basic Serial Write and Read" VI to communicate with a microcontrollerbased trainer kit via RS232.

Problem is: I would like to write exactly 4 characters from my VI to the µC. This is supposed to be a time (i.e. 23.5 seconds), so I guess I need to set the length of the string to be sent.
If I write '5', I would like the VI to transmit '00.5', if I write '2.3', the VI transmit '02.3', and so on...

I've looked through some examples using string subsets and so on, but as far as I could tell, this didn't resolve my problem.

Could anyone help me out? 🙂


0 Kudos
Message 1 of 4
(3,712 Views)

Not sure why you posted that code. It's just the shipping example with a much smaller front panel.

You could use the Format Into String function with a format string of %04.1f. With a numeric input of .5, you get '00.5' out and with a numeric input of 2.3, you get '02.3' out.

0 Kudos
Message 2 of 4
(3,702 Views)
Let us know if this solves your problem or if the ASCII codes of the 4 characters must be sent instead of the characters.




Message Edité par JB le 02-21-2008 05:37 PM
0 Kudos
Message 3 of 4
(3,701 Views)
Sorry for my late response (been having some other problems with my PIC18).
Your solution worked just fine, thanks for replies Smiley Happy
0 Kudos
Message 4 of 4
(3,648 Views)