Posted 23 Oct 2023 (edited) Good morning, I'd like to start by saying that I am new to programming, so please bare with my very simple questions. I'm having issues trying to get a DataLamp on the HMI screen to change its behavior from lamp Off to lamp On after a specific process has been completed (not operated by a button). Is this possible or do lamps strictly operate by using a Button? Edited 23 Oct 2023 by Craig McCanada Share this post Link to post Share on other sites
Posted 23 Oct 2023 19 minutes ago, Craig McCanada said: Good morning, I'd like to start by saying that I am new to programming, so please bare with my very simple questions. I'm having issues trying to get a DataLamp on the HMI screen to change its behavior from lamp Off to lamp On after a specific process has been completed (not operated by a button). Is this possible or do lamps strictly operate by using a Button? Lamps operate using an expression. When the expression is true the lamp reflects the ON Color, and when the expression is false it becomes the Off Color. This expression can be any number of things but for your application you can just use the BOOL tag from your PLC. If you have a tag in the PLC that indicates the process is complete make sure it is a Global tag and then add it to your HMI mapped variables. You can then type the name of it in the expression for the Bit Lamp. Share this post Link to post Share on other sites
Posted 23 Oct 2023 Thanks Photozoltaic, that makes more sense than using a DataLamp. But how would I represent that in the PLC program? As an Input function? Share this post Link to post Share on other sites
Posted 23 Oct 2023 I'm not familiar with your program so I can't say for sure but when you toggle a bit that would be an output-type instruction (right side of the rung). There must be a section of code where you can toggle a BOOL true when the process is complete though I assume. Going to make up some logic to illustrate this - probably nothing like your program but hopefully gets the point across.. Share this post Link to post Share on other sites
Posted 23 Oct 2023 I just created a new rung and made it an output (named: HMI_CONTROL_STATUS), all the variables match the expression but when I run it with the NA Simulator the lamp doesn't change... Please see pics of what I've done. Share this post Link to post Share on other sites
Posted 23 Oct 2023 (edited) What you show looks correct. Are you sure you are running the simulator with both PLC and HMI? From the PLC menu, choose Simulation > Run with NA Simulator... or From the HMI menu, choose Simulation > Run with Controller Simulator... Edited 23 Oct 2023 by IO_Rack Share this post Link to post Share on other sites
Posted 23 Oct 2023 For a bit to be true in a coil the coil must display green and have preceding conditions true as well. I think like IO_Rack said you're not running both simulators. Share this post Link to post Share on other sites
Posted 24 Oct 2023 Morning guys, I was running the program yesterday properly. I selected "Run with NA Simulator" while I had the NX activated. I just didn't send you a picture of the NA Simulation. But I think I made this all work, I created some Structured text and when I simulated it and moved the certain IO's to true the Lamp changed. I didn't think this would be needed but it seems to be ok. Share this post Link to post Share on other sites
Posted 24 Oct 2023 16 minutes ago, Craig McCanada said: I created some Structured text and when I simulated it and moved the certain IO's to true the Lamp changed. What do you mean by this? In your example, the PLC will turn on HMI_CONTROL_STATUS in ladder then your BitLamp0 should turn green. Share this post Link to post Share on other sites
Posted 24 Oct 2023 That's the thing, the BitLamp0 doesn't turn green on its own when I ran it yesterday. By the sounds of it I may have some other issues in my program.. Ps. I'm very new to programming, I've only started about a month ago and have had zero experience in this field before. Lol Share this post Link to post Share on other sites
Posted 24 Oct 2023 Are you able to share your program? Share this post Link to post Share on other sites
Posted 24 Oct 2023 I can share it but first look at this picture and see what you think. Share this post Link to post Share on other sites
Posted 24 Oct 2023 (edited) Your problem is in the ladder. The output should be green inside the circle. This is showing that the output is not on even though the input conditions are true. 1) Make sure HMI_CONTROL_STATUS is not used as an output anywhere else in the program. Right click on the output and choose Fixed Target Cross Ref. You should only see it listed once in the Cross Reference window. 2) From the project tree, go to Task Settings > Program Assignment Settings (3rd icon from the top). Then make sure Program0 is listed and the Initial Status is set to Run. It looks like your simulator is in run mode but check the Controller > Mode > Run Mode should be shaded while simulating. Otherwise click it to put it in Run Mode. Edited 24 Oct 2023 by IO_Rack Share this post Link to post Share on other sites
Posted 24 Oct 2023 You said you wrote some structured text. Is this still in your program turning HMI_CONTROL_STATUS off? Share this post Link to post Share on other sites
Posted 24 Oct 2023 Thanks, I will look into that. And no, I took the structured text out as it would technically be redundant right? Share this post Link to post Share on other sites
Posted 24 Oct 2023 1 minute ago, Craig McCanada said: Thanks, I will look into that. And no, I took the structured text out as it would technically be redundant right? If it is accomplishing the same logic then yes. To illustrate what's likely going on - and this is a common ladder logic mistake - any time an output coil is duplicated the bit it toggles will have the value given to it by the last rung where it is used when you are looking at it online. It will have the correct value given to it in between the duplicate coils but your HMI will be polling in between logic cycles so it will always get the value given to it by the last instance. Cross reference it and it should be very easy to track down. This should help show what I'm referring to: Share this post Link to post Share on other sites
Posted 24 Oct 2023 I just looked at everything and it all checks out, and I only used that Output coil (HMI_CONTROL_STATUS) once. I've attached the program here, it's quite small. If you have time can you take a look? Thanks 12207_PLC-HMI_2023.10.24.smc2 Share this post Link to post Share on other sites
Posted 24 Oct 2023 I'm not sure when this came along but it's the first time I experienced it. Click the check box(es) next to Tasks in the PLC project tree. That stumped me for a bit. Share this post Link to post Share on other sites
Posted 24 Oct 2023 Note: There is no need for the END instruction. This apparently is implied with Sysmac Studio. (Maybe someone can explain better). Putting the END instruction there would prevent you from executing additional program sections. Share this post Link to post Share on other sites
Posted 24 Oct 2023 Eureka! The checkbox did work, I never would've thought of that. Thanks! And I'll delete the END function, i just assumed I needed it to end the program as that is the whole program there, it's not a big one at all. One last question, at the end of the process does the program automatically reset everything or would I have to add in a reset function of some type? Share this post Link to post Share on other sites
Posted 24 Oct 2023 1 hour ago, Craig McCanada said: One last question, at the end of the process does the program automatically reset everything or would I have to add in a reset function of some type? The program is cyclic.... or it continually scans the program evaluating the input conditions and refreshing the outputs every scan. There is no need to reset anything. For example (in your example), If the Print_PB is a momentary push button then it would turn ON LH_Printer_Output and RH_Printer_Output when pressed. When you release the button LH_Printer_Output and RH_Printer_Output would turn OFF. The refreshing happens automatically and continuously at the Task Execution Time. Share this post Link to post Share on other sites
Posted 24 Oct 2023 The check box is only for simulation so you can quickly turn programs on and off. To make that program run on an actual CPU, you need to go into Task Settings and put the program in a task. Share this post Link to post Share on other sites
Posted 24 Oct 2023 12 minutes ago, Crossbow said: The check box is only for simulation so you can quickly turn programs on and off. To make that program run on an actual CPU, you need to go into Task Settings and put the program in a task. It will run by default as it is Program0 and included by default. If you made a new program yes you would need to add it to a task. Share this post Link to post Share on other sites
Posted 24 Oct 2023 (edited) So right now the 12 buttons on the HMI (beginning of the program) are Toggle Buttons, which i want to keep highlighted until the whole program has been completed successfully. Will those automatically reset at end of the cycle (in my program as it is) or no because they're Toggle Buttons? Edited 24 Oct 2023 by Craig McCanada Share this post Link to post Share on other sites
Posted 24 Oct 2023 (edited) No, they won't. The quick and dirty method would be to program the button in the PLC as an output with an "R". (Right click and choose Reset Instruction). However, I don't recommend that. I would make the buttons momentary. Latch your Action bit in the PLC. "S". (Right click and choose Set Instruction). Wait for the Feedback to Reset the Action bit. Use the Action bit as VisualFeeback in your button. The idea here is to keep all the logic and logical decisions in the PLC. This is just my opinion and recommendation. There are many ways to program the same thing. I think this method makes it easier to troubleshoot since you can see all the actions in the PLC. The HMI is simply visualization of the actions in PLC. Edited 24 Oct 2023 by IO_Rack 1 person likes this Share this post Link to post Share on other sites