Craig McCanada

DataLamp (NA5) HMI - (NX) PLC - Sysmac

32 posts in this topic

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 by Craig McCanada

Share this post


Link to post
Share on other sites
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.

Capture.PNG

Share this post


Link to post
Share on other sites

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

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..

 

Capture.PNG

Capture2.PNG

Capture3.PNG

Share this post


Link to post
Share on other sites

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.

Ladder pic.png

HMI screen.png

variables.png

variables_2.png

Share this post


Link to post
Share on other sites

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 by IO_Rack

Share this post


Link to post
Share on other sites

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

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
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

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

Are you able to share your program?

Share this post


Link to post
Share on other sites

I can share it but first look at this picture and see what you think.

Run with NA simulation.png

Share this post


Link to post
Share on other sites

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 by IO_Rack

Share this post


Link to post
Share on other sites

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

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
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:

Capture.PNG

Share this post


Link to post
Share on other sites

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

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.

MrPLC_SimIssue.thumb.JPG.752262e2cdf1f2f

Share this post


Link to post
Share on other sites

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.

MrPLC_SimIssue2.thumb.JPG.8c8a31943eb3a2

Share this post


Link to post
Share on other sites

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
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

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
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

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 by Craig McCanada

Share this post


Link to post
Share on other sites

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 by IO_Rack
1 person likes this

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now