dunc

GOT 2000 scripting?

19 posts in this topic

has anyone used this and had much luck with it?

i have been trying to do something relatively simple and am struggling.

i simply want to add in a project script to log out a user after a set period of time.

initially i tried it by trying to write to the data register in the PLC and this didnt work. I then tried managing it all within the GOT and it partially works, but if i fire the simulator up with the login level already there, it just wont work?

below is the script i am using:

//if login level above 0 or login above 0 and login time count at 0
if (([w:GD0] > 0) || (([w:GD0] > 0) && ([w:GD1] <= 0)))  {
//set GOT seconds to login time count
[w:GD1]=[w:GS7];}
//while login level is above 0
while ([w:GD0] > 0) {
//if 60 seconds elapsed
if([w:GS7]-[w:GD1]>=60){
//set login level to 0
[w:GD0]=0;}}

 

i have tried lots of different iterations. i have tried using a 1 second sampling trigger point method as well as the method above with an ordinary trigger with no real joy.
could it be me using the simulator causing the issue and i should get some proper hardware, or am i just being completely stupid?

any guidance would be appreciated. thanks

Share this post


Link to post
Share on other sites

managed to get it to work. i cant get my head around how the WHILE statements work. if i use IF statements only it works fine!? am i being dumb?

anyway, this worked:

if ([w:GD0] == 0) {
[w:TMP0] = 5;}
if ([w:GD0] > 0) {
[w:TMP0] = [w:TMP0] - 1;
if ([w:TMP0] <= 0) {
[w:GD0] = 0;
}
}

Share this post


Link to post
Share on other sites

I'm, not very experienced in scripting in the GOT's, but I think that even if you specify "WHILE" statements it won't constantly run - maybe just at screen-load? I'm not sure, I've only briefly looked into scripting in the GOT's so I have no better guess...

Share this post


Link to post
Share on other sites

there are object scripts, screen scripts and project scripts. i used this script as a project script so should run constantly.

the second script i posted functions perfectly fine, i just cant see why i couldnt get it to work using "while" statements? on this occasion i got round it, but i may have an application where i cant just use "if" statements to achieve what i want!

 

hopefully someone will come along who has played around with them a bit more

Share this post


Link to post
Share on other sites

Did you download the project to a screen, or still using simulator?? I would also suspect that the simulator behaves differently, especially when it comes to CPU blocking loops... If I have time I will try and load some of your code onto a screen I've got and test it.

Share this post


Link to post
Share on other sites

i have only been using the simulator, so suspect that could be a potential issue.

i have ordered the screen for the project, but it hasn't arrived yet. if you have the chance to test it, that would be appreciated.

Share this post


Link to post
Share on other sites

I really don't understand why just now, but I cannot get 'WHILE' loops to work at all (neither in simulator nor on a physical GOT2000). I've created a simple script (tried several actually) but they never "do" anything at all. This is what I'm currently testing with:

GOT2104, Project Script, ScriptTrigger=M10 (always on in my project)

Script:

while([w:D1] <= 100)
{
[w:D1] = ([w:D1]+1);
}

 

It doesn't count up at all, it doesn't do anything at all. I've tried several different parameters in the while condition but without luck. I'm out of ideas... Will do some more testing when there's time. However, I did notice that the 'IF' statement runs almost like in a PLC (scan based), so if you use 'IF' you're probably good to go...

If anyone at Mitsubishi is reading, please shed some light onto this topic if possible... 'WHILE' / 'IF' statements and how the CPU scans the code in GOT2000...

Share this post


Link to post
Share on other sites

the GOT turned up about an hour ago (i was using a GT23), so gave it a try myself and got the same result.

like you say, it appears the 'while' loop is not working at all.

'if' statements are fine for alot of situations, but the 'while' statements should still work!?
perhaps 'while' statements do not work in project scripts for some reason?

Share this post


Link to post
Share on other sites
4 minutes ago, dunc said:

perhaps 'while' statements do not work in project scripts for some reason?

Yeah, maybe.... I'm not sure but I find it a bit strange. Will have to test some more later on...

Share this post


Link to post
Share on other sites

Which security method are you using? Level or operator?

LEVEL:

Setting the security level device will log-out and even elevate the security level when changed in the controller. Well it does in the simulation I have tried.

OPERATOR:

The manual explains out to log out an operator - I haven't simulated this one.

 

It seems that control from the PLC should be possible.

Share this post


Link to post
Share on other sites

tried this basic script and it works, but only for a short period of time, then it stops working?

while ([b:GB200] == 1)
{
[s16:GD200] = 10;
}

 

this is very odd?

Share this post


Link to post
Share on other sites
8 minutes ago, Veganic said:

Which security method are you using? Level or operator?

LEVEL:

Setting the security level device will log-out and even elevate the security level when changed in the controller. Well it does in the simulation I have tried.

OPERATOR:

The manual explains out to log out an operator - I haven't simulated this one.

 

It seems that control from the PLC should be possible.

previously i have just controlled it from the PLC, but after moving over from the E-series terminals to the GOT, i thought it would be nice to keep the same logout control done from the HMI itself to keep things neat.

i have got something that works, but whilst getting that to work, found that the 'while' statements are not really working as expected.

Share this post


Link to post
Share on other sites

OK.

This modified version of your first example works with an ordinary trigger:

//if login level above 0 or login above 0 and login time count at 0
if (([w:GD0] > 0) || (([w:GD0] > 0) && ([w:GD1] <= 0)))  {
//set GOT seconds to login time count
[w:GD1]=[w:GS7];}
//while login level is above 0
while ([w:GD0] > 0) {
[w:GD2]=[w:GD2]+1; //increment GD2 to show we are in the loop
//if 60 seconds elapsed
[w:GD3]=([w:GS7]-[w:GD1]); //check the calc
if([w:GS7]-[w:GD1]>=10){
//set login level to 0
[w:GD0]=0;}}

 

Only tried it with the simulator.

 

EDIT:

This is pretty much identical to your first example.  I have added some parts to help with debugging.  GD2 is incremented every scan of the HMI when the while loop is active. GD3 calculated GS7 - GD1 just to check if there was a problem with the this calcuation.

It now works with the additions edited out so that it is back to your original version as far as I can tell

 

Edit2:

If I cut and paste your original code it fails to work on the simulator.

Oh the simulator the while statement seems to block the screen refresh.

 

@dunc

Edited by Veganic

Share this post


Link to post
Share on other sites
59 minutes ago, Veganic said:

OK.

This modified version of your first example works with an ordinary trigger:

//if login level above 0 or login above 0 and login time count at 0
if (([w:GD0] > 0) || (([w:GD0] > 0) && ([w:GD1] <= 0)))  {
//set GOT seconds to login time count
[w:GD1]=[w:GS7];}
//while login level is above 0
while ([w:GD0] > 0) {
[w:GD2]=[w:GD2]+1; //increment GD2 to show we are in the loop
//if 60 seconds elapsed
[w:GD3]=([w:GS7]-[w:GD1]); //check the calc
if([w:GS7]-[w:GD1]>=10){
//set login level to 0
[w:GD0]=0;}}

 

Only tried it with the simulator.

 

EDIT:

This is pretty much identical to your first example.  I have added some parts to help with debugging.  GD2 is incremented every scan of the HMI when the while loop is active. GD3 calculated GS7 - GD1 just to check if there was a problem with the this calcuation.

It now works with the additions edited out so that it is back to your original version as far as I can tell

 

Edit2:

If I cut and paste your original code it fails to work on the simulator.

Oh the simulator the while statement seems to block the screen refresh.

 

@dunc

looks like the while loops time out after a time. if you have 10 seconds before you break out of the while loop, its fine. when i increased it to a minute, that gives up and appears to do nothing.
 

this rings true with my other more basic bit of code i tried.

Share this post


Link to post
Share on other sites

@dunc

 

GS385 Script Monitoring TimeSet

the monitoring time for one script in units of seconds. 
If a script does not end even when the set time has elapsed after the start of the script, the script processing stops. (Error code: 15) 
The setting range is [1] (second) to [300] (seconds). 
If 0 or any value greater than 301 is set, the value is processed as 10 seconds. 

 

The following shows examples of settings.
・When 0 is set for GS385, the monitoring time is 10 seconds.
・When 1 is set for GS385, the monitoring time is 1 second.
・When 10 is set for GS385, the monitoring time is 10 seconds.
・When 11 is set for GS385, the monitoring time is 11 seconds.
・When 301 is set for GS385, the monitoring time is 10 seconds.

 

You can check for errors here:

GS16 to GS47
Script Error DataStores the script Nos. and error codes of the script where an error has occurred are stored in order from the upper address of the storage area. 
When an error occurs, the script No. and the error code are stored in 2-word unit as a history. 
If 15 or more errors occur, the upper addresses are overwritten in order.

 

Edited by Veganic

Share this post


Link to post
Share on other sites
3 hours ago, Veganic said:

@dunc

 

GS385 Script Monitoring TimeSet

the monitoring time for one script in units of seconds. 
If a script does not end even when the set time has elapsed after the start of the script, the script processing stops. (Error code: 15) 
The setting range is [1] (second) to [300] (seconds). 
If 0 or any value greater than 301 is set, the value is processed as 10 seconds. 

 

The following shows examples of settings.
・When 0 is set for GS385, the monitoring time is 10 seconds.
・When 1 is set for GS385, the monitoring time is 1 second.
・When 10 is set for GS385, the monitoring time is 10 seconds.
・When 11 is set for GS385, the monitoring time is 11 seconds.
・When 301 is set for GS385, the monitoring time is 10 seconds.

 

You can check for errors here:

GS16 to GS47
Script Error DataStores the script Nos. and error codes of the script where an error has occurred are stored in order from the upper address of the storage area. 
When an error occurs, the script No. and the error code are stored in 2-word unit as a history. 
If 15 or more errors occur, the upper addresses are overwritten in order.

 

brilliant, that explains it then. i guess when you use a 60 second sampling time, it is running the script once every minute so it doesn't time out.

that does restrict its use somewhat, but at least i now know the limitations.

 

thanks

Edited by dunc

Share this post


Link to post
Share on other sites

Sorry, which language is used for scripting in GOT2000?

I remember,  a language similar to C was mentioned in GOT1000 manuals. Is it still the same?

Share this post


Link to post
Share on other sites

i believe it is similar to C when i was looking through the manual. it gave an example of slightly changing it to run in a C compiler. 

i think the issue i was experiencing was more to do with how the script is being run in the GOT rather than an issue with the script itself.

Share this post


Link to post
Share on other sites

Thank You for the answer. What actually means "similar to C", something from C works, something doesn't?

Last year I was asked to write a script for GOT1000. But, because of lack of knowledge how to do it (I could not find much in manuals and forums about GOT scripting) decision was made to migrate to Beijer  iX HMI, where scripting supported much better and You can get extra help from any C# forum.

 

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