Vinicius Posted June 3, 2020 Report Share Posted June 3, 2020 Hello There's some way to change the string library with a binary image/switch? I tried with two buttons, each for a language, and worked. But now I would like to change with a binary image/switch. Every touch in the button, will change the country flag and the language, but the screen starts to blink. I created this logic, when the button is touched, incremends MI 19, if MI 19 > 1, then will return to 0. If MI 19 == 0, the languange would change to portuguese, bur if == 1, would change to spanish. This subroutine is called when the screen "configuration" is displayed. Quote Link to comment Share on other sites More sharing options...
MVP 2022 Joe Tauser Posted June 3, 2020 MVP 2022 Report Share Posted June 3, 2020 Do NOT call the Set Str Lib function continuously. Create a coil with your equal block and then a transitional contact off of that. 2 hours ago, Vinicius said: This subroutine is called when the screen "configuration" is displayed. It's common for someone new to Unitronics to go overboard using all the flexibility the PLC offers on subroutine calls. Unpredictable results almost always happen because unlike a computer language the Vision doesn't have local variables that are created and destroyed when the subroutine runs. You are always operating on global variables, and when you exit a conditionally called sub the value of those variables freezes. They do NOT reset to 0. You've mentioned in other posts about your subroutine strategy. Flex has already pointed out to use subroutines that are called continuously. I would highly recommend you follow his advice at this point in your programming journey. Create subroutines to organize your code but call them all the time from the Main. You can set a bit that is on when a display is active to put in front of the code you want to run. If you do it this way, the coils you use will reset to off, as you probably expect them to. Trust me, the the PLC is fast enough and the odds are very high that all your code won't even come close to slowing down. Joe T. 1 Quote Link to comment Share on other sites More sharing options...
Vinicius Posted June 3, 2020 Author Report Share Posted June 3, 2020 Thank you, Joe. I understand. I will follow Flex's advice, and yours. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.