Jump to content

Change library string (language) with a binary image/switch


Recommended Posts

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.

image.png.58a18ac0d9c79f5b93a116f0470a4b14.png

 

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.

Link to comment
Share on other sites

  • MVP 2023

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.

  • Like 1
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...