I am looking to dynamically change the color of a basic shape, such as a circle, based on the values of different tags (e.g. HSD, HI, LO, LSD). Despite creating a sophisticated program for this purpose, I am facing challenges with its functionality. The program code and a text document are provided below, along with a screen image for reference. I am wondering if there is something crucial that I might be overlooking. Additionally, I am curious if it is possible to run a real-time version of the program, similar to using the Allen Bradley viewer, while remotely connected to the HMI and PLC. Program Code: if(HSD) return 1; if(HI) return 2; if(LO) return 3; if(LSD) return 4; else { return 5; }
If you're looking to explore remote viewing, I'm happy to assist with that aspect. As for adjusting the colors, I may need to experiment a bit as it's not a method I've used before. To enable remote viewing, navigate to the Web Server settings and activate it, then head to the features tab to enable both Remote Viewing and remote Control functionalities. From there, open a web browser and enter the IP address assigned to your HMI. Your browser may display a security warning, but you'll need to proceed despite this hurdle.
When setting the visibility of an element, make sure to use the Visible property instead of adjusting the Figure/Fill Format/Tag Back settings. Also, if you want to change the color of a Tag value displayed on the screen, ensure that 'Get From Tag' includes Colors selected. I have created a basic program that I can share, but note that the emulator is not functional in version 3.1, so I developed it using version 3.0. The emulator does work in version 3.2.
Your advice was right on point and everything seems to be working properly. By inputting a simulation value between 1-5, I am able to update the display and have the color reflect the state. I also included the scaled data on the circle to show both the value and the corresponding state. Check out the pictures. Thanks for the information, it's exactly what I needed to achieve.
It seems like your program is dividing into different outcomes based on the tags, but you're using "if" statements consecutively without any "else if" in between. This might lead to unexpected behavior if multiple conditions are met simultaneously. Try using switch cases or "else if" statements to make it clear what order the outcomes should be in. Regarding real-time functioning similar to Allen Bradley Viewer, you might need mutually compatible middleware that can interface with your PLC and HMI while providing real-time data. Have a look into OPC servers for real-time communication, many industrial systems use them.
After looking at your code, one thing jumps out at me. You're using 'if' conditions without an 'else if', which means that as soon as one condition evaluates to true, the function will return and not check any other conditions. This might be why your program is not functioning as expected. Also, about running a real-time version of the program while connected to the HMI and PLC, it's likely possible but heavily depends on the hardware and software you've got. Some platforms allow for live debugging or monitoring while others don't. You'd need to check the specifications of your setup.
One thing that immediately jumps out to me is your if-else logic. Those conditions are sequentially checked and the function immediately returns on the first true condition, meaning if, for example, `HSD` is true, your function will return `1` and will not check for the remaining conditions. This may be causing some of your functionality problems. Are the tags supposed to be mutually exclusive? If they are not, you might want to revise your function to account for potential overlaps. As for the second question, depending on the model of the HMI and PLC you're using, and the software they support, you should be able to monitor and intervene in real time remotely. It’s always best, though, to carefully review your system's specifications and perhaps reach out to the manufacturer’s technical support for accurate information.
It sounds like you're on the right track, but make sure your conditions are mutually exclusive and that you're properly checking the tag values—they should be structured so that only one condition can evaluate to true at a time. Also, for real-time functionality, consider setting up a direct socket connection to your HMI/PLC so you can pull the latest values on the fly. Have you looked into libraries that support real-time updates? That might streamline your workflow significantly!
✅ Work Order Management
✅ Asset Tracking
✅ Preventive Maintenance
✅ Inspection Report
We have received your information. We will share Schedule Demo details on your Mail Id.
Answer: 1. How can I dynamically change the color of a basic shape based on tags like HSD, HI, LO, and LSD? - You can achieve this by using conditional statements in your program code to map each tag to a specific color value for the shape.
Answer: - Challenges may arise in ensuring the correct functionality of the program code, mapping tags to color values accurately, and handling unexpected scenarios.
Answer: - It is important to carefully review the logic in your program code, ensure proper tag-value associations, and consider any potential errors in the implementation.
Answer: - Yes, it is possible to create a real-time version of the program that allows for dynamic color changes based on tags and can be accessed remotely through tools like the Allen Bradley viewer.
Join hundreds of satisfied customers who have transformed their maintenance processes.
Sign up today and start optimizing your workflow.