07-01-2009 01:37 AM
Hi I am using the "Basic Serial Write and Read.vi" example in labview.
Can anybody tell me how to write a string with a time delay after each line?
The reason I need to do this is the modem that I'm sending data to needs a 100ms delay between strings.
For example:
Text1 blah blah blah/n need a 100ms delay
Text2 blah blah blah/n need a 100ms delay
Text3 blah blah blah/n
Your help is appreciated.
Kind regards
Mark
07-01-2009 03:41 PM
Hi Markwtc,
I would try putting a for loop around the serial write and wait commands, that way you will call your write three separate times after waiting the specified amount. You will need to create an array of strings, one entry for each write, and then index them through the wall of the for loop.
Let me know if that works for you.
Thanks
Scott M.
07-01-2009 08:31 PM
Hi Scott,
Thank you for your reply. I am a novice learing Labview. I have spent a few hours learing how to make arrays but need some adivce to put it all together.
Can you please have a look at the attached file and offer some advice.
Kind regards,
Mark
07-06-2009 10:59 AM
Hi Mark,
The for loop needed to be around the serial write command, and the "-" character in your strings was "subtracting" the rest of the string. You can delete the "read" section from the code if your not going to be using it. Have a look at this see if it gets you going in the right direction.
Scott M.
07-06-2009 11:37 AM
For my purposes it would be nice if there was a way that it didn't matter how many lines of command the user wanted to send, and there was just a time delay in between every new line that was input into a "write" command box. This is if I don't know a maximum for number of commands someone using my program will want to send.
Thanks so much for any help
07-06-2009 01:01 PM
If you want the ability for a user to type multiple lines in a string control, you can have code that separates the lines into an array.
07-06-2009 02:30 PM
What code would separate the lines into an array? Will that still include the time delay in between each line? I am working off of the screen shot from above, but using a serial read and write that writes one byte at a time.
I'm not sure what settings to use for the string array, which looks like this in my program:
I can't find anything in LabVIEW that tells me what either box is supposed to mean, or what values I should be putting in, but I do know that I can create more of the one on the right side.
07-06-2009 02:47 PM
Sorry, but I don't know what you are asking now. You can use the example posted with an array of commands. You or the user can enter each command into a single element of the array. If you don't want to use an array on the front panel, you can use a single string control and then create the array with something like Spreadsheet String to Array. You would use either a carriage return or line feed as the separator (I don't remember which will work). Use the rest of code above.
Your comment about 'what either box is supposed to mean' is confusing. It's just a string array (a numeric for the index value and the string box for data) and the values you enter into the array are whatever commands you want to send to the instrument. None of the commands are going to be documented in LabVIEW, of course.
07-07-2009 11:41 AM
I got it to work without using an array. Since I know the number of characters in each command (6), I was able to have it sending only 6 characters at a time from a string composed of many commands typed one after the other. I put in an option for the user to control how much time elapses between each command sent. Keep in mind I started out using the serial-write-and-read-1-byte.vi that is available on this site, so it looks different than the ones above. However, the elements and wiring I used to carry out this task would also work for the programs above.
Here is my diagram:
07-07-2009 11:52 AM