https://www.automationdirect.com/do-more (VID-VW-0009)
Live demo showing how to use variables with the ViewMarq LED Messging display.
Check out all of our videos at https://www.AutomationDirect.com/Videos
To subscribe: https://www.youtube.com/user/automationdirect?sub_confirmation=1
Facebook: https://www.facebook.com/AutomationDirect
Twitter: https://twitter.com/AutomationDirec
LinkedIn: https://www.linkedin.com/company/automationdirect
**Prices were valid at the time the video was released and are subject to change.
In the previous videos we simply sent static text to the Viewmarq Display. What if you want to update the display in real time with things time, or counts, or temperature, or fluid levels, etc.? Do you have to continuously re-send all that formatting information over and over again? No, you don't. The good news is you can use variables with the Viewmarq. And it is so easy - You just setup the formatting once with place holders for the variables, then later all you have to do is send the variable and the Viewmarq will format it and put it where it belongs automatically. Let' see how that's done. Over in the Viewmarq software we create our message. Let's see, we're using a 4x12 display, and our unit has an ID of one. On the first line we'll display the number of units completed. So we type "Units:" and then hit this button to insert a numeric variable. We choose 1 of 32 possible numeric variables -- we'll choose number 1 right now -- how many total digits will be needed, how many decimal digits will be needed and you can see an example of the result right here. In our example we are going to pretend that the factory can't produce more than 100,000 units per day, so we'll need 6 place holders for that. And we're producing whole units so we don't need any decimal digits here so I'll dial those down. This is what our final result will look like, 6 decimal digits. When we go to set the variable from the PLC we will want to copy this string right here. That's the one that actually sets the variable. We'll come back to that later. For now, let's just insert this variable into our string. And we can see how it looks. Now one thing I like to do -- I'm going to double click on this to go back to the dialog -- is I like to set the leading zeros. That way I can see visually how much space it is going to take up on my display. To display time down here on line 4, we'll use Numeric Variable #2 -- we only need two digits to display the hour -- and we don't need any decimals. Again, I'm going to use the leading zeros. Well add a colon, another numeric variable, use number 3 now, we only need two digits for the minutes, and no decimals. Another colon, and our last numeric variable for the seconds. We'll use numeric variable number 4 here. Again, he only needs two digits for the seconds, and no decimals. I forgot to add leading zeros so let's go back and do that. Let's add a few features to that. Let's leave the Units Green. We'll make the numeric variable RED. And let's make all of our time yellow. While we are at it, let's make this whole line 4 inches so it will show up a little better. And let's make sure the time I center justified. Perfect. Let's copy this formatted string to our clipboard and note that this formatted string is less than 256 characters. Over in the DoMore software we send the initial format string just like before. We use the STRPRINT instruction. We'll put that in String Long Zero because we know it can handle up to 256 characters, and we just paste our string in place. We add our termination character. An end quote and a beginning quote just like we did before. And say ok. And again, just like before, we do a STREAMOUT. We'll send it out the internal serial port. And we want to send that String Long variable we just created out that port. We only need to do that once so we'll do it on the first scan. And let's update our unit count, oh how about ten times a second. To do that we copy the string that updates the variable from the ViewMarq software -- here it is -- I just press the copy and it copies that string to the clipboard. Go back to my DoMore -- use another STRING PRINT instruction. We'll use a String Short variable because we know it is going to be less than 64 characters and paste it in. As usual we need to remember to add our opening quotes, our end quotes and don't forget to set the unit ID number to your ID. Is there any reason we can't set all the variables at the same time? This is our count, let's go ahead and copy this, and add one for the hours, minutes and seconds. The count was in string variable 1, the hours -- variable 2, Minutes were in variable 3, and seconds were in variable 4. Now all we have to do is insert our variable. This "n" is a place holder, so we are going to close down the string, put our variable that has the count in it, we used V100 in this case, and then open up the string again. Variable 2 was hours. So we close the string, we grab our hours, and open up the string again. Variable 3 is our minutes. And variable 4 was our seconds. And don't forget to add the termination character. Now we just need to send that string out to the ViewMarq with a Stream Out instruction. Again, going out the internal serial port. We're going ot send SS0, and we are done. We want this to run at 100milli seconds. And let's go ahead and increment the count every 50 milli seconds just to give us something to look at. And while we are at it, let's give ourselves a way to reset the count to zero. That's our whole project. So on the first scan, were going to format the display and send it out. Then every 100ms we are going to create a string with just variables in it and send that out. We have a 50 milli-second timer incrementing our count. And we have the ability to clear that count if we want to. Well, let's try it. Accept. Save it and write it to the PLC. And just like that we have a real time count and time showing up on our ViewMarq display. If I reach down and toggle X7, it resets my count. Perfect. And remember, all we are doing is updating the variables -- we don't have to regenerate all the formatting over and over again. The Viewmarq does all of that for us. Very cool. That ought to be enough to get you going. Please let us know if you have any questions. Automation Direct's Customer Support is always free and just a phone call or e-mail away. Spend Less Do More With Automation Direct.
Voted #1 mid-sized employer in Atlanta
Check out our
job openings