plat933x

GT Designer3 Script Problem

6 posts in this topic

Hi, 

I encountered a specific problem during work with GXWorks2 & GTDesigner3. In my part of group project I need to receive from proper script, array of values of sine wave. I need to get 1500 values of sine wave and fill registers in GXWorks and have no idea why my script does not run. I'm using simple while loop with no errors statement from Syntax Check. My script should calculate sine values from index 0 to 1500, and substitute it to registers D2000 - D3499. Look in attachments for better understanding my trouble. 

I'm looking forward to hearing from you as soon as possible. 
Greetings,
Jan


P.S. I'm new in Mitsubishi Equipment programming so if it's some kind of beginner's problem - please be merciful for me.

1.JPG

2.JPG

Share this post


Link to post
Share on other sites

I'm not sure which GOT you are on, but I did some testing setting up a simulator of GOT27.

After some testing and failing, finally success:

The problem is that the GOT (at least in simulator mode on my computer - didn't have a GOT here to play with), is not very happy about PLC variables directly inside the 'while' statement. Therefore, I modified your script a little, and used internal variables in the GOT only (GD). See the attached screenshot. Also: IMPORTANT NOTE: I went with GD20 as the index variable, GD0 to GD6 may be automatically assigned in the GOT if clock data is activated for GT21... I changed GD0 in my script to GD20 (you should also do this just to avoid any possible problems in the future).

Also: Make a note of the flt (FLOAT) I've used. Since calculating sin values will result in small numbers less than 1, you'll need to use REAL in the PLC, and they are 32-bit variables. You cannot calculate sin values into regular words, hence the script I've attached will be using from D2000 - D4999 in the PLC.

Let us know if you have questions.

GOT_Script.png

1 person likes this

Share this post


Link to post
Share on other sites

First of all, big thanks for you @kaare_t for quick and right answer. I've based my new-edited script on your advices and it worked, but I have another stranger issue regarding to script's results. I used exactly your script and got weird results which you can see in attachements in this post. I plotted 50 points starting from D2000 to show more clear what is the problem. 


Att.1. Why the obtained chart is so irregular with many peaks?It looks more similar to sawtooth wave. I must get more smooth sine wave chart. Is it some kind of problem with sampling frequency?
Att.2. Values in registers are in range of -32768 to 32767, i guess it's from Signed Word range, but is it possible to get, on chart, values e.g. in range 0-100? Should i make some conversion in GXWorks with received in D2000-D3499 values?
Att.3. On another screen i made script with exponential function instead of sine. You can see that all I got is something near rising sawtooth function. What is the simpliest way to get exp function with GOT's script?


I'm working with GOT1000 GT15-S and Mitsubishi FX3GE-24MT.

Greetings,
J.

21.PNG

22.PNG

23.PNG

Share this post


Link to post
Share on other sites

The reason you're seeing "strange" values in GX Developer is beacuse, according to the script I provided, use float (REAL) numbers and they are distributed over 2 words (32 bit in total). In other words, in the GOT you will also need to use float (REAL) numbers in your plot. It looks to me like you've used words in your plot, and you should be using floats (REAL).

Share this post


Link to post
Share on other sites

Thank You kaare_t . Can You advice, please, how to create a csv file with HMI tag's values on an USB stick inserted into GOT2000?

Is anywhere examples available?

 

Share this post


Link to post
Share on other sites

No problem. I'm really not sure how to do this, it should be possible but I've never tried it before... Did you solve it?

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