Jump to content

Sending string variable to serial printer

Recommended Posts

Using Visilogic 9.8.65. I have a project where a product recipe name is entered as a string and stored in a vector of MI integers (via the string variable edit box). The recipe name (integers) is stored in a data table. When the machine is running, from time to time it outputs the name of the recipe and other recipe parameters to the serial port. Currently I have the send function configured to send the line id of the data table, because I cannot seem to find an easy function to send the characters to the printer. It would be more meaningful for the operators to see the name of the product on the printout instead of looking at a numeric value. How do you send a user editable, variable string to the serial port ? Thanks

Link to comment
Share on other sites

I am not 100% sure what you are referring to, but I started poking around in the protocol send FB trying any possible options that could result in the previously entered string variable (product name) rebuilt from a vector of integers which are stored in the data table.  The solution was to  stream the vectors of MIs from the data table, converting one linked register to two bytes. I feel this is far from being trivial, maybe there was an example to demonstrate this operation or maybe there is a far simpler way to achieve what I was trying to do.

1. String variable entered by operator 


2. MI40-MI 49 (20 characters) saved in a data table


3. reading the content of the data table and decoding the integers to pairs of characters


4. As a result, I finally see the decoded product name in the serial printout. Yay !


Do you think there is an easier way to print the user entered string variable to the serial port ?


Link to comment
Share on other sites

  • MVP 2023

You got the Protocol Send right.

You can create a string data type in a data table that will make your life much easier.  Just right-click on the column header and define the string length.  It looks like you've already figured out that you can rename the column.  Double-click on the cell to edit it - remember to save.



Retrieve the data with a Data Table Read Row into an integer array



Then load the array into your Send block and trigger it.

If you want to post your program I can poke at it for you.  I'm always happy to help those who have put some effort in.

Joe T.


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...