Sign in to follow this  
Followers 0
PdL

CX-Designer macro works in test mode but not in NS terminal

17 posts in this topic

I have created a sheet with a button bar at the bottom. 4 Buttons open a popup page with submenus. The popup pages are set to close when the base screen switches, which all of the other buttons on the bar do. In the popup screens a copy of the button which opens the screen is placed at the exact same position which is set to close the popup screen, so it looks like the button toggles the popup screen. But I also want to popup pages to close when another popup screen is opened (another one of the 3 buttons pressed) so you can cycle the 4 menus. I use the following macro code in the all 4 popup screen properties set to run "when loading a screen". 'When opening this popup screen, detect if there is already a popup screen opened 'besides this screen, so which is not equal to this screen. $W110=BIN($W1); 'convert $W1 (system memory 1st popup screen number) to decimal $W111=BIN($W4); 'convert $W4 (system memory 2nd popup screen number) to decimal IF ($W111 <> 10); 'if the 2nd popup screen is not this screen CLOSEPOPW($W111); 'close the 2nd popup screen ELSEIF ($W110 <> 10); 'if the 2nd popup screen is this screen and the 1st popup screen is not this screen CLOSEPOPW($W110); 'close the 1st popup screen ENDIF; I use the $W1 and $W4 system memory values which are the 1st and 2nd opened popup screen numbers. Each of the 4 buttons runs the same macro, only the screen numbers which are compared differ, the number is that of the popup screen the macro belongs to. Now in test mode it works fine, I can cycle the 4 screens by pressing the 4 buttons one by one, and only the last opened popup screen is open, the previous one is closed. But when I download the project to my NS terminal, it doesn't consequently close the popup screen when another one is opened. Sometimes I can open 2 or 3 popup screens and the previously opened screens don't close. I monitor the $W1 and $W4 words and they reflect the right screen numbers. Anyone knows why it doesn't work in the hardware ? I am no coding guru so I am always doing trial and error when it comes to this but as it works in test mode I don't know where to look for the problem. Perhaps the execution time difference between test mode and NS ? Are there any other ways to accomplish what I want ?

Share this post


Link to post
Share on other sites
I may be reading what your trying to acheive wrong, but what I understand is that if a popup screen is selected, then the popup that it was selected from will close? If each of the popups are unique, ie. fans = screen no. 1, cond = no.2 etc, could you not just execute the closepopw for each of the other screens when the button is pressed, and then use the showpage command to display the popup that you want? I am no guru either, but for the amount of code that you are putting in, it may be easier and quicker to just have the command 4 times, using the actual screen no? If I understand this correctly let me know, I can look at this more later.

Share this post


Link to post
Share on other sites
Hi Scott and thanks for your reply. Yes I also thought it would and should be that simple. But when putting in a code on the buttons touch on timing like this: CLOSEPOPW(20); CLOSEPOPW(30); CLOSEPOPW(40); SHOWPAGE(10); none of the macros seem to run as nothing happens when pressing the button. Not even the SHOWPAGE command is executed. This confused me somewhat and I tried playing around with only running the macro on one button and nothing on the others. Then I could open the 3 other screens and when pressing the button with the macro, only the first line of code seems to be executed (first popup window closes), but not the following 2 CLOSEPOPW commands and the SHOWPAGE command. Then I tried to find another way around to do this and I agree it looks like a bit too complicated for this job but until now the only way it works. In test mode that is.... Attached are 2 projects. One with my code (running on the "when loading screen" condition of the popup screens), and one with the simple code (running on the buttons "touch ON timing"). Again thanks again for your help. Pim Test_simple_macro.zip Test_working_macro.zip

Share this post


Link to post
Share on other sites
v2.0.... If you want I can create the same project in V1.0.

Share this post


Link to post
Share on other sites
Here are the test projects for CXD V1 Test_working_macroV1.zip Test_simple_macroV1.zip And here are the test project for CXD V2 Test_working_macroV2.zip Test_simple_macroV2.zip Aargh!! The macro that I created which works when in test mode with CXDV2 doesn't work in V1 I have recreated the same project and all options were also available in CXD V1 but somehow it doesn't work, I don't see the active popup screen numbers reflected in $W1,$W4 and $W7 although they are enabled in the system memory list they stay 0, and I am able to open all popup screens. As expected the simple macro also doesn't work in V1. I think I have exhausted my own resources to figure this out and will (have to) move on with building the rest of the application but if anyone has a suggestion or some other solution I would be grateful!

Share this post


Link to post
Share on other sites
I just tried this in test mode, and came to the same conclusion. To make it simpler, you could just make it so that the popup has to be closed before another one can be loaded, this is what I have done. Not ideal, but will save a lot of time, and if someone has to follow it later could make it tricky. Scott

Share this post


Link to post
Share on other sites
Yeah that's what I am thinking now too... This is done relatively easy by unchecking the "enable input on other screens" setting at the popup page properties. I just hate it when I can't understand why this or that is not working.

Share this post


Link to post
Share on other sites
a new approach...how about just assigning PLC bits to the buttons and using @MOV to display the various screens. Edited by ECSI

Share this post


Link to post
Share on other sites
Yes have also thought of this option. It's just that I don't want to have screen control in the PLC program. Also because I am not working on the program, and the screen will have more than one host. Thanks guys.

Share this post


Link to post
Share on other sites
In your macro shouldn't the statements be: CLOSEPOPW(n) instead of CLOSEPOPW($W111) or CLOSEPOPW($W110) where n = the actual project screen number used for the popup? EDIT: OK nevermind, it looks like you already tried this. How about using CLOSEPOPW($SW4) and CLOSEPOPW($SW1). Edited by ECSI

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites
That's the problem. I don't know if the screen to be opened will be loaded in the $W1 when it is the first to be opened, or in $W4 when it is opened after another one should close. So I can't just close $W1 or/and $W4, I have to know if the screen which is supposed to open is already loaded and then I shouldn't close it. I am surprised you can still follow me!

Share this post


Link to post
Share on other sites
LOL...it is getting a little confusing: Here's something I just tried. I created a main screen #0 and 4 popup screens #1,2,3,4. I created the 4 buttons on the main screen just like you did. Each button is set as Function 'None'' and in the macro for Touch ON Timing I put a simple statement $SW1=n; where n equals either 1,2,3,or 4 depending on which button is pressed. This will display the corresponding popup for whichever button is pressed. Set the popup window properties to enable input on other screens. You shouldn't need to copy and overlay the buttons onto the popup screens. This works for me in test mode. I think it is what you are trying to accomplish.

Share this post


Link to post
Share on other sites
KEWL I thought it was a read only adress! Stupid me... Will try tomorrow. Thanks!

Share this post


Link to post
Share on other sites
Thanks ESCI, It works great Only thing I don't really understand is the difference between $SW1 and $W1. I know the S stands for system memory, but in the memory allocation list one assigns $SW1 to $W1 !? In test tool both adresses reflect the same values and can be set a constant which opens the popup window, but in the macro setting a constant to $W1 doesn't work, it only works when using $SW1. Learned a lot again !

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
Sign in to follow this  
Followers 0