petercolquhoun Posted September 9, 2014 Report Posted September 9, 2014 Hi, I'm new to PLC programming but have years of experience in embedded C, I am currently using a V1210 to control an industrial process and I'm so far impressed with the Unitronics kit. I do have the following issue though.... I have a several indicators on the HMI that all require the same processing steps (apart from the input variable) and was wondering if it is possible to create my own FB to process these rather than repeat the ladder multiple times. I have a subroutine to perform the processing but I can't see any way of making this act on different HMI variables. Please excuse my ignorance if there is a simple solution to this. Best Regards Pete.
EduMarg Posted September 9, 2014 Report Posted September 9, 2014 Hi Petercolquhoum. Custom FB is possible in the new UniStream series of Unitronics. Unfortunately in Vision series this is not possible to do. One possible workaround is to use a Data table with the values for the process and a different MI operand for each of the values you’ll like to see on the HMI. Call the subroutine as many times as you need but before calling the subroutine, increment an index so you will read from the corresponding row of the DT the value and linked it to the operands to be use in the process. At the end you link the result to each of the different varaiables you’ll like to display on the HMI screen. Hope this helps.
petercolquhoun Posted September 10, 2014 Author Report Posted September 10, 2014 Uni Guru, Well.... I tried but without much success, I'm now a bit concerned that I am using the wrong approach and would be grateful for some advice.... I have a number of HMI elements (Lists of Images) that present Leds etc as the same bitmap but with different colours. Each image list has 4 similar images with different colours Red, Green, amber and white. So the Link parameter is used to switch the colour of the HMI element. I also have, for each HMI element, a MB that indicates if that element is flashing. Flashing is achieved by switching between the currently displayed colour (Red, Green or Amber) and white. I am also using a PWM FB to generate a 1/2 second toggle, this is running continuously. I'm not sure if this is the best way to achieve this. So switching between colours is simple, just change the value of the link parameter MI. When the flash MB is set, (positive transition) I store the currently displayed image index for that HMI element in an MI and using the PWM toggle switch between this image and the white image. When the flash MB is reset (negative transition) I restore the "saved" image index. The 3 rungs used to do this are repeated for each HMI element, obviously if elements are added to the HMI it becomes painful to extend the ladder and each HMI element must be tested because it is possible I will have made errors when creating the new ladder. Using Data tables or vectors may reduce the level of testing required and simplify the process of changing the HMI during development. I attempted to follow your idea by defining each HMI element in contiguous memory so that I could access the elements through vectors but I couldn't see a way of generating a positive transition on an MB via indirection, It also looked like I would need to copy elements of vectors into temporary operands to perform comparisons and store operations. I'm sorry for the brain dump but I would be very grateful for any advice you have, is similar repeated ladder common practice ?? Or am I missing something. Best Regards Pete.
MVP 2023 Joe Tauser Posted September 12, 2014 MVP 2023 Report Posted September 12, 2014 Posting your code would be helpful. Joe T.
petercolquhoun Posted September 12, 2014 Author Report Posted September 12, 2014 Joe, Of course... The file is big to upload so I have created a smaller project, the code for the motor led in the main routine is repeated multiple times in my project for different HMI elements. Toggle MB1000 to start / stop the led flashing. Many thanks Pete
Walkerok Posted September 14, 2014 Report Posted September 14, 2014 Hi Pete. A couple of things after taking a look at the program. You do not actually need the PWM block. The SB3 1 second pulse is actually on for 1/2 second and off for 1/2 second, so in line 4 of the program just make it true SB3 on one line and false SB3 on the other. On the actual color image you want to have shown you can make it a little easier on yourself. You can delete line 3 all together. Leave MB1000 as tue on line 4 and on line 5 change MB1000 (negative transition) to MB1000 not true. This will let you have only two rungs doing the job of the original 4 you had. Since I don't know if on your multiple images that you want to show in the full program if you are concerned with just one image at a time or multiples at the same time. I would assume that you have multiple images that could be active randomly at the same time. You have the following MI1000 shows the final image you want in the image by list. You are using MI1100 to put in the image you want to be shown to MI1000. Multiple images are just the same............. MI1000=image 1 (by list), MI1001=image 2, MI1003=image 3, Etc. MI1100 is stored into MI1000, MI1101 is stored into MI1001, ...Etc. The decision to flash to white is MB1000 for image 1, MB1001 for image 2 and so on. That is really all there is to it. Here is a sample 3 image flasher. You obviously have to have logic behind what color you want to show and when you want it to flash but for what its worth. Good luck Keith Sorry I uploaded the program as a V570. I did not have a V1210 to run this on and forgot to change it back. Image flasher test.vlp
petercolquhoun Posted September 15, 2014 Author Report Posted September 15, 2014 Keith, Thank you very much, that is really helpful. I didn't know about SB3! Where could I find a documented list of the system operands or am I best looking in the operand tab in visilogic?? Once again many thanks. Pete
s.pratt Posted September 15, 2014 Report Posted September 15, 2014 Hello Pete, A full list of System Operands can be found in the Help files of VisiLogic: Ladder> Operands> "Operands". Within this page, you can scroll down until you see the title "System Operands". Please click on the blue highlighted "System" for the full list. Also, if you choose the "Operands" tab at the bottom left side of VisiLogic, you will see a pink list of the operand types on the bottom left side of VisiLogic. If you scroll through, you can read the descriptions to the operands to see what they can be used for. This way helps you to categorize between system bits, integers, and so forth. Hope this helps.
petercolquhoun Posted September 16, 2014 Author Report Posted September 16, 2014 OK, thank you for all your help. Pete
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