farcry Posted November 2, 2021 Report Share Posted November 2, 2021 Hello. I have multiple MB's on one screen. I would like to toggle those MB's via HMI keypad (You can do this with MI's simply). Please help. Thanks. Link to comment Share on other sites More sharing options...
MVP 2023 Joe Tauser Posted November 3, 2021 MVP 2023 Report Share Posted November 3, 2021 Create a subroutine that only runs when the display is active. Set it up from the "Links & Jumps" tab on the display - In that subroutine, hard code the key system bits to toggle your working bits - Is this what you're looking for? If not, post your code so we can see the whole story. Joe T. Link to comment Share on other sites More sharing options...
MVP 2023 Ausman Posted November 3, 2021 MVP 2023 Report Share Posted November 3, 2021 If these are truly Digital Inputs on your 130 like your screen shot implies, toggling them as Joe suggests may not actually achieve the result you want if the input is actually connected to a switching device. The Device's state will always win. cheers, Aus Link to comment Share on other sites More sharing options...
MVP 2023 kratmel Posted November 3, 2021 MVP 2023 Report Share Posted November 3, 2021 4 hours ago, Ausman said: The Device's state will always win. IsDisplayed operand from the "Links & Jumps" tab can be used for disconnect all outputs from Device state and switch it to special Activation Display Toggled MB. Link to comment Share on other sites More sharing options...
farcry Posted November 3, 2021 Author Report Share Posted November 3, 2021 Thanks Joe Tauser. This is not what I'm looking for. In one display I have like 12 different MB's. (I run out of number keys). It is also not user friendly... What I would like is to jump to variable and change/toggle its state with arrow keys. The same way you change MI's. Ausman Only the first three MB's are trully MB's. And are RW type. I'm attaching small sample with NOT working MB toggle... Temp.vlp Link to comment Share on other sites More sharing options...
MVP 2023 Ausman Posted November 3, 2021 MVP 2023 Report Share Posted November 3, 2021 Kratmel, (or others) can you please explain this a little more. I think I might be about to learn something new. And need to correct my previous statement! I have always believed that nothing could alter an input's state from the initial read at scan start. cheers, Aus Link to comment Share on other sites More sharing options...
Sideway Posted November 3, 2021 Report Share Posted November 3, 2021 Hi everyone, I came out with an idea while reading this thread. Let us put the MBs in a contiguous area of your PLC memory, for instance you have your 1st MB "MB0" and your last MB "MB8". Let us assume that these MB are in a grid of 3x3 in your display. Let "MI0" be a counter variable. When you load your display, MI0 initiates to 0 and varies as follow : a. If you press Right arrow, MI increments by 1. b. If you press left arrow, MI0 decrements by 1. c. If you press bottom arrow, MI0 increments by 3. d. If you press top arrow, MI0 decrements by 3. If you want to toggle a given bit, press "Enter" when you are positioned correctly. By pressing "Enter", you need to trigger a bit toggle operand, going from MB0 to MB8 and shifted by MI0 value. You can find a simple example of my idea attached to this post. Cheers, Sideway. MB_grid.vlp Link to comment Share on other sites More sharing options...
farcry Posted November 4, 2021 Author Report Share Posted November 4, 2021 Sideway thanks for answer.. But V130 doesn't have Marking View property. If I would be using Vision with touch capabilities, I would use Touch Buttons for toggle. Link to comment Share on other sites More sharing options...
Sideway Posted November 4, 2021 Report Share Posted November 4, 2021 Hi farcry, I just gave an example on a new project, leaving the PLC config by default... which appears not to be V130 😛That's why i may have more options than you ^^ I think you can discard Marking View... Actually i only own a V130 myself ! So i do not even know what this option is doing i was just assuming while writing the code. The goal of my example was simply to show an alternative to toggle those bits on any vision screen. I did not think deeper about it, but we may find a way to trigger some indication on the display that the bits are ON or OFF ! Like using the "Hide" function with a drawn rectangle surrounding each bit on the display Cheers, Sideway. Link to comment Share on other sites More sharing options...
farcry Posted November 5, 2021 Author Report Share Posted November 5, 2021 Thanks again Sideway. I have modified yours perfectly working code to work with V130. I also used INVERSE bit to see which MB you are toggling. The only downside of this method is, that you have to have LINED UP MB's. For example MB0 to MB7. You can not have for example MB1,MB2 then MB8,MB9 and MB33, MB34. Thanks again for yours excellent idea. BR, Farcry. MB_grid_V130.vlp Link to comment Share on other sites More sharing options...
Sideway Posted November 5, 2021 Report Share Posted November 5, 2021 Hi farcry, thank you for your kind reply. I may have a suggestion for you, if your MBs are in various places. ***EDIT : I thought a bit more about the following suggestion... Be careful with the Struct object, i did not test my solution yet but i think it may generate overflows since i load a MI 16-bit value within a bunch of MBs (there are not necessarily 16 of them). Needs to be confirm by advised Uni-guru superheroes 😅 A solution i may have here is to add dummy bits if needed until you reach 16 bits /EDIT*** You may have a look at the Struct object (under vector functions list). This way, you can link every MB from any location with a contiguous register, such as an MI (which is basically 16 bits following eachother) for example. And actually, all you need to do is modify your MI value with the register toggle operand, which will toggle on/off your MBs indirectly. You can have a look at the Struct function help in VisiLogic, which illustrates how the function works. If you want, i can rewrite my example code to show you Cheers, Sideway. Link to comment Share on other sites More sharing options...
MVP 2023 Flex727 Posted November 5, 2021 MVP 2023 Report Share Posted November 5, 2021 There is a "Replace Operand" function that allows you to move operands to any address you choose. Link to comment Share on other sites More sharing options...
farcry Posted November 9, 2021 Author Report Share Posted November 9, 2021 Thanks again Sideway. I have modified project using STRUCT. But unfortunable this STRUCT function doesn't work like I thought it would. It creates ARRAY of MI's. Not just ONE MI... I could do this using SET/RESET bit, but this is time consuming and confusing method (If you use more MB's - like 30). I have attached sample. Do you have any other idea? MB_grid_V130_V3.vlp Link to comment Share on other sites More sharing options...
Sideway Posted November 9, 2021 Report Share Posted November 9, 2021 Hi farcry, That's what i was doubting about while writing my post 😕 It turns out you can only set packets of 8 bits (1 byte) with the Struct object, i forgot about that detail ^^ (for instance, according to what you wrote in your structure, your 1st byte sent in your MI vector is : [MB50 to MB57] stored in the bits 0 to 7 of MI150, then your 2nd byte is : [MB51 to MB 58] stored in the bits 8 to 15 of MI150... Then [MB55 to MB62] stored in the bits 0 to 7 of MI151... and so forth. So yes, my advice was not the best ahah. However, using the struct object would be fitting perfectly using words such as MI, ML etc. since they are packets of 16 and 32 bits But it's not what you are trying to do What i can suggest is simply the following : Solution 1) Do as Flex suggested : you can move your MBs with the "Replace operand" function. It may be a bit tricky to use, so i will show you how to proceed down below. Solution 2) Store your MBs that are in different locations to a contiguous MB vector. This way, you can keep your MB fields as they are, you just need to create more MBs : you may use contacts and direct coils to do this ==> Simply link a direct coil MB50 to a direct contact MB0 for instance, then MB51 to MB1, MB55 to MB2 etc. And then you work with your MB0 to MBx vector field. Example for solution 1 : Let's say you want to turn MB51 and MB52 into MB0 and MB1. Open "Replace operand" function (under Edit panel) and do the following : In "Select operand and Adress", write MB51. Press OK. In the new window "Select operand and Address to replace MB51", write MB0. Then, in "Replace" window, write "Vector length" = 2. This way, it will take both MB51 and MB52 into account and turn them into MB0 and MB1. If you had only 1 value to change, you would write 1 in the vector length. Check the boxes "Copy properties" and "Clear source operands". Press OK. And you are done Cheers, Sideway. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now