|AutomationDirect Live Chat|
How to use the Productivity3000 to display Dynamic messaging on the ViewMarq Display (messages less than 128 characters, including formatting)
REQUIRES Software Version 1.8 or Better
Suppose you want to switch dynamically switch between two messages like this. You could create two instructions where one has message A and the other one has Message B - right? Sure. But what if you wanted to switch between 10 or 20 or even a hundred different screens? Do you really want to create all of those separate ViewMarq instructions and every time you make a change you would have to update or change all of them? Again, you CAN do that, but with the Productivity 3000 there is a much easier way. It's called Dynamic Text. In the simplest case, instead of putting the text here, you just create a String Tag, and put that tag right here. Then when the program wants to change the message, it just puts whatever ViewMarq String it wants in this tag, re-toggles this instruction, and that updates the ViewMarq display. Now you are using one instruction to display any message you want simply by changing the contents of the TAG. And while that's pretty handy, there is still an even better way to handle large quantities of messages by using indexed arrays. And it makes your life so easy - let's take a look. In this program, this Init routine is called on the first scan. His whole purpose in life is to fill this ViewMarq Message array with ViewMarq Strings. Looks like we have these 5 messages stored in the first 5 slots of this array. Back in the main program, we just look to see if the index has changed, and if so, we send a ViewMarq Message. When that happens, this instruction is going to send whatever message is in this array at this index offset. And that's dynamic text -- it's exactly like before - this instruction is just going to send whatever string is in the TAG, instead of what was in this static text box. Note this little trick here -- when the index changes, we set the previous index equal to the index so on the next scan these two are be equal and they don't retrigger this instruction. Now anytime the program changes the index to a new message, this will be different and this instruction will get triggered. How cool is this -- Now I can add as many instructions as I want to this array and my PLC code that displays the messages never changes. My program just changes the index whenever it wants to change the ViewMarq display. That's it. This is a really great way to keep your code easy to modify and maintain. Let's try it. I'll transfer the project down to this controller. And bring up a data view so we can change that index. There's the index right there -- I'm going to write it out to give us a baseline. Let's pretend we're the program and somewhere else in our PLC code we decide we want to display a different message. Well, all our code has to do is change the index. Let's say he wants to display message 3. And BOOM, the ViewMarq display instantly updates. What if you code wants to display message 5? We'll it just changes the index, and again, boom, the new message appears. Easy So again, now you can have as many messages as you want, and never have to change your ViewMarq display code! Some folks may not be real familiar with arrays, so how do you create an array of strings like this ViewMarq Message string we used over here? Well, it's easy. Just go to the Tag Database. You add a tag. Give it a name. Let's call it VStrings. We want to create a 1 dimensional array of strings. We want each of those strings to be a max length of 128 characters. And let's create a set of, oh I don't know, maybe ten of those. So this array of strings can hold up to 10 strings. That's it, now you would just fill that string in with messages back here in Init and back here in main in our ViewMarq instruction we would just swap out this string array for the new one we created. That's it. That's all there is to it. Did you notice that the messages used in this example were all shorter than the 128 character max length of a Productivity3000 String? That was for the convenience of this video, of course, but truth is, most ViewMarq messages you use will be longer than 128 characters -- especially if you use a lot of formatting options and variables. So, what if you need to use a longer ViewMarq String? Check out part 2 to learn the trick ... It's the same thing we did here, but instead of using 1 D arrays, we use 2 D arrays. Well, That ought to be enough to get you going with SHORT Dynamic Text strings. Let us know if you have any questions. Automation Directs Customer Support is always free and just a phone call or e-mail away. Performance plus Value ... That's productivity. From Automation Direct.