Sign in to follow this  
Followers 0
BenJones

Mitsubish FX3u - GX IEC developer.

38 posts in this topic

Hi, I am using a function block 'IntScale' so that I can scale the analogue inputs from the FX4AD_ADP analogue input cards. I have 16 inputs and wish to scale all differently. If I use the IntScale FB this works but I have copied and pasted it 16 times in the program and this takes up a lot of memory. Is there a way to keep CALLing the FB so that I can input different values each time ? I guess I would need to MOVE each input and output to a seperate memory address ? Is there an easier way than this without taking up much memory ? I'm new to programming and not sure how to do this. Many thanks in advance, Ben

Share this post


Link to post
Share on other sites
Use the Beijer scaling function instead (EngCalc). Uses a lot less memory (less steps and rescources): 1 IntScale uses 825steps 1 EngCalc FB uses 141steps If you're using many (like 8 or 16), use the function instead of the function block (the EngCalc library is provided with both a 'function' and a 'function block'). You'll see the difference when defining more than 2 or 3 blocks: 16 EngCalcFB (Function blocks) uses 2211steps 16 EngCalc (Functions) uses 978 steps You can find the library here: http://www.beijer.no/web/web_aut_no.nsf/do...125728E0059B4C9 If this is still too much space you'll have to make arrays of your values, and just index through them in a loop or in a sequence and use one FB to update all your values. Edited by kaare_t

Share this post


Link to post
Share on other sites
And people were saying in previous posts the function blocks on the Mitsu site were old. This one clearly states GX IEC 5.02 on the website.

Share this post


Link to post
Share on other sites
In my opinion, it doesn't matter if the FB is "old" as long as it does what it's meant to do.... The 141steps still work fine for me, and I can't seem to find anything that should have been updated with this specific FB. You don't modify anything that works - you either add/remove functions, or you fix bugs.

Share this post


Link to post
Share on other sites
Great kaare_t, Thanks very much for that, very useful ! I have installed the .sul library and it has compiled no problem at all but it won't transfer to the PLC. Not sure why. I've ran it in software version GX IEC Delevoper 7.03 with an FX3U plc. Do you know if it is compatible with this ? Thanks again, Ben

Share this post


Link to post
Share on other sites
Oh sorry, pay no attention to my last reply....got it working no problem at all ! Thanks very much for that ...brilliant ! Ben

Share this post


Link to post
Share on other sites
That's good! And just to be clear: The FB is created in GX IEC 5.00 or something, but I've used it several times with GX IEC 7.03 and FX3U without any problems (I've even opened and checked the function block myself).... I don't know why Beijer don't update the text or something to state that the block is compatible with newer versions but there's no problems at all!

Share this post


Link to post
Share on other sites
I never said it should be updated... I was just commenting how people said the function blocks on Mitsubishi's site were out of date, and this one is older.

Share this post


Link to post
Share on other sites
Hi, With this scaling function, does it only take INT values ? I wish to scale between 0 and 3.5 so do I have to use REAL number ? If I change this in the header from an INT to REAL it doesn't work. How can I get around this ? Muchos thanks again, Ben

Share this post


Link to post
Share on other sites
I think you have to open the program of the function block, and modify the code (you could replace the function with real-number functions instead of standard INT/WORD functions.....). Or, you could just scale all the numbers (before converting them to real), and then convert the results to real numbers, and divide by 10 if you wan't 1 decimal....

Share this post


Link to post
Share on other sites
Try to do this function in ST it should use less resources than beijers scale_int function.. The scale_int function is in a way really bloated just open it and look.. FUNCTION SCALE_TO_REAL : REAL VAR_INPUT Raw_In : DINT; Raw_Min : DINT; Raw_Max : DINT; Scaled_Min : REAL; Scaled_Max: REAL; END_VAR VAR_TEMP Input : DINT; END_VAR BEGIN IF Raw_In>Raw_Max THEN Input:=Raw_Max; ELSIF Raw_In<Raw_Min THEN Input:=Raw_Min; ELSE Input:=Raw_In; END_IF; SCALE_TO_REAL := (Scaled_Max - Scaled_Min) / DINT_TO_REAL(Raw_Max - Raw_Min) * DINT_TO_REAL(Input - Raw_Min) + Scaled_Min; END_FUNCTION

Share this post


Link to post
Share on other sites
Made som modifications and this code uses only 490steps for 16scalings.. One disadvantage is one must assign the array parameters outside the block.. dont know how many steps this could be.. Attention this code is written as Siemens scl in mitsu the variabel declarations is done in the header and the keyword begin isnt used.. FUNCTION SCALE_TO_REAL16 : Array[1..16] of REAL VAR_INPUT Raw_In : Array[1..16] of DINT; Raw_Min : Array[1..16] of DINT; Raw_Max : Array[1..16] of DINT; Scaled_Max : Array[1..16] of REAL; Scaled_Min : Array[1..16] of REAL; END_VAR VAR i : INT; Input : DINT; END_VAR BEGIN FOR i:=1 TO 16 BY 1 DO IF Raw_In[i]>Raw_Max[i] THEN Input:=Raw_Max[i]; ELSIF Raw_In[i]<Raw_Min[i] THEN Input:=Raw_Min[i]; ELSE Input:=Raw_In[i]; END_IF; SCALE_TO_REAL16[i] := (Scaled_Max[i] - Scaled_Min[i]) / DINT_TO_REAL(Raw_Max[i] - Raw_Min[i]) * DINT_TO_REAL(Input - Raw_Min[i]) + Scaled_Min[i]; END_FOR; END_FUNCTION Edited by Henric

Share this post


Link to post
Share on other sites
No life tested some again and it seems that one assignement takes 10 steps.. In this case we would have 32 DINTvalues (RawMin,RawMax) wich will do 320steps and 32 reals (ScaledMin,ScaledMax) this sums up to total of 640 steps for assignements.. 640+490 makes 1130steps for scaling 16 values with different rawmax/min and scaledmax/min values.. If the rawmin/rawmax always would be the same this variable would not have to be an array and the code would reduce some..

Share this post


Link to post
Share on other sites
Hi All, I don't know too much about ST but does that code have divide by 0 protection? Anyway i've posted a project that may be of some interest to you inregards to scaling to your INT to REAL's. This project's library uses modified Beijer function blocks that i've modified for my own use. They still use quite a few steps, but not as many as you've stated earlier. Inside the project you will function blocks to convert most common data types. There are two types of each FB, one type has some built in alarms driven off the scaled output side, the other doesn't. I have the FB's set up to use REAL inputs as alarm set points which is what i like. You might want to rip open the FB's and then use INT's as the set points which will save you some steps. May not be the solution you want steps wise, but i know these will do the job you wish to do... Cheers - Chris. P.S - I'm half asleep as i'm piecing this demo project together, so if the project doesn't work for you let me know and i'll sort it out !! FX_ANALOG_SCALING_PROJECT.rar

Share this post


Link to post
Share on other sites
Divide by zero shouldnt happen if one have given the raw max - raw min values.. But i shoud simulate to se what will happen if these are zero.. If that gives me some troubles it isnt a problem to test against zero.. but the code gets a little bit more bulky.. Sadly these small mitsu plc has so little memory.. One shouldnt have to bother about memory these days.. Made a MotorBlock earlier today in ST to make it movable to all platforms.. But it takes slightly over 1000steps so using that in a fx cpu is impossible.. I mean i have to have some room for other logic to..

Share this post


Link to post
Share on other sites
I don't know if this is how things are done in IEC but would a simple for-next loop be an answer to the original question? The FX3u has 64k (I think) which is quite a bit compared to the other Fxs.

Share this post


Link to post
Share on other sites
Now we have several soulutions, this is the fun with plcs but shouldnt be needed with this trivial problem.. 64k steps is much compared to 8k steps or what the small mitsu cpus have but its still small if one thinks of how cheap memory is today.. But as we all know the FX series has been here many years and I for one would like to se an upgrade to make them more competable with siemens cpus.. And i think the ladder editor in GxIEC sucks.. Compared to Siemens.. I mean i shouldnt be bothered with overlapping connectors, overlapping symbol names etc etc.. if an element needs more space give it more space automaticly.. The ST editor i dont like either I want to declare my variables in the code.. As for doing the for next loop and using the "standard" function that was neat but if working with reals i would prefer my soulution, why? When working with reals i think my soulution gets better accuracy.. And if i must change the code or add some functionallity i think my code compared to that in beijers block is more readable.. But thats my personal opinion.. In a perfect world I wouldnt need my function just do 16 calls of beijers and we would be home free..

Share this post


Link to post
Share on other sites
Hi there POCKO, The file you sent is a .pcd file. Is this a kodak camera file as I can't open it. Is it possible for you to post the .SUL or .ASC file and I can try and upload your modified function block and use it with GX IEC deleloper my end. I'm getting really frustrated now as I've spent days trying to scale something to one decimal place; all I'm trying to do is scale 0 - 4.0. I'm no expert but surely it shouldn't be this hard ! I can scale with integers no problem at all. I have used the Beijer function and I'm not too worried about about the memory usage for that block as it is much smaller the IntScale FB. This is what I have done so far. I've tried to use the DIV and MOD function and combine them so the output shows the quotient + the Modulus (to 1 decimal place). This would give eg. 2 + 0.6 i.e. 2.6 for example up to 4.0. The ladder logic that I've done here compiles but doesn't give the desired value to 1 decimal place. The other thing that I can think of is that I've not allocated my memory usage correctly. Do I need to change something in options from 'D' to 'R' as I think I need a 32 bit output for a floating number. I'm not sure if I should use a D register (is this just int?) or where I should save the quotient and modulus in the memory. The only 32 bit memory slots I have are Couters. I realise that I may have to use one data register to store the INT quotient part and the next register to store the modulus (decimal) part, but not sure how to re-combine this using E-Designer. Getting confused about all this. If my boss was nicer he'd send me on a training course but I think he enjoys watching me struggle in pain....hmmm. Ben

Share this post


Link to post
Share on other sites
OK... The .pcd file i posted is a complete project backed up from inside GXIEC Developer V7.01. Open up IEC Dev and on the top menu click on "Extras" and then on "Project Restore". A window will pop up, click on the top Browse button and navigate to the saved location of the file i posted, then click on the bottom Browse button and create a blank project wherever you wish. Then your project will be compiled ready to go. I know the function blocks with REAL data outputs will go to five decimal places, I'm not sure after that... Be careful with your mapping of the D register's if you use REAL's. Using INT's your D addresses may be eg. D0,D1,D2 etc. For REAL's leave a gap as they are 32bit, so they will now be D0,D2,D4 etc. Break open the different FB's and take a look at the data conversion instructions and read up on them, particularly the INT_TO_REAL instruction. Good luck - Pocko. P.S - Just noticed you make mention of using E-Designer. Stupid question, but i have to ask - Do you actually need your logic to do stuff based on the REALS or are you only doing it to display them on the HMI screen? The Beijer screens can read the analogs, do the conversions and scaling's inside the screen and it may save you steps if you don't need the REALS inside your logic. They can also be made to read, scale, convert the 16 bit data and spit it out as 32 bit data back into the PLC converted ready for you to use in your logic if you desire. They are a nice screen to work with. Actually used one on the current job purely to get floating point Modbus RTU data into an older Mitsu PLC. Edited by POCKO

Share this post


Link to post
Share on other sites
Great Pocko, thanks for this, one preoblem though, when I click extra's and then fill in both fields (Project restore file and project path) it then asks me to 'Please insert source diskette # 2'. What is this and what do I do here ? Thanks again, Ben

Share this post


Link to post
Share on other sites
Can't say i've ever seen that message. In the second box use a path such as C:\MELSEC\GX IEC Developer 7.01\Example\TEST\ and see how you go... What version of IEC Dev is it? Edited by POCKO

Share this post


Link to post
Share on other sites
It says in the help file for 'Project Backup' that if the project is too large to fit one one disk then it is automatically split across the required number of disks. Is there maybe another disk or smething ? Thanks also for the tips on the data registers, you confirmed what I thought which is always good Once I get can the analogue scaled value to one or two decimal places I'll then try and view it on the HMI we are using (E1101) with E-Designer. There is a block called Analogue Numeric and you can specify the number on decimal points and the type of number. Hopefully this will work.

Share this post


Link to post
Share on other sites
It's IEC developer 7.03. I'll try that file path now

Share this post


Link to post
Share on other sites
mmm, no joy I'm afraid. I tried that exact file path and also changed the IEC developer 7.01 bit to 7.03. Still no joy. Is there any other way that I can upload it ? Thanks again for your help, Ben

Share this post


Link to post
Share on other sites
Hey Pocko, think I've fond the poblem : http://www.mitsubishi-automation.de/servic...name=faq_search Strange because I'm not running any virus scan software !

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