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 

1203658190_printstringvariablefromdatatabletoserialport1.JPG.b37390da10f4aa152d7756bb916100f9.JPG

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

1549792134_printstringvariablefromdatatabletoserialport2.JPG.15907f968cbd4deacaf81260b01e5239.JPG

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

449938420_printstringvariablefromdatatabletoserialport3.JPG.251231b848c834c42e5279f583e623c9.JPG

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

917495712_printstringvariablefromdatatabletoserialport4.JPG.f671c2aa0b178ab7d224c3a135787c0e.JPG

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.

image.png.f17057fb57feb699b1f5c08d07befe5f.png

image.png.f4cc33c19b6502ff71f467a333fcf7ae.png

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

image.png.6aa40f13c8c63314d345362b8cecb928.png

image.png.50a82b29f96b0d6fc234b673c3b60731.png

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.

Guest
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...