Sign in to follow this  
Followers 0
cghaba

How it is best?

22 posts in this topic

I have to write a program for a Mitsubishi FX1N plc that controls a manipulator whose operation has about 130 steps. Can anyone suggest which is the best way/language to write the program? I have only Melsec Medoc FX-Win (no GX Developer). cghaba

Share this post


Link to post
Share on other sites
There is no rule that said which language to use but you shall choose a language that is suitable for your application, according to what programmer you have and what is more easy for you . if you have to program application where there is a clear sequence. you may want to use stepladder or Ladder, if you only have an handheld programmer you may want to use instruction list.

Share this post


Link to post
Share on other sites
I usually use simple sequencer consisting of DECO and INC instructions and bunch of rungs to check the step complete. It works for me and I find it very effective method compared to some of the others I tried in the past. With 8bit limit one DECO instructions should give you up to 256 steps but you can always use more than one to get any number of steps you want. I never went that high, normally I run multiple sequencers in parallel instead of one large but that also depends on application and personal preference. I'm trying to keep sequencers at 20-40 steps range. If one cannot do it, I make it master and all little tasks that run arroud are slave tasks called by master. You need bunch of consecutive bits for steps and one integer. On every scan you decode integer into step bits. Then you make rungs to check if each step is complete. If any step is complete (Thanks to decode instruction there is only one active step at the time so that should be the one that's complete) you increment the step counter (the integer we mentioned). For example (simplified): D10 is step counter M100-M115 are step bits M200 step complete bit ---|Always on|---------------[Deco D10 M100 k4] ---|M100|----| |-----------------+----(M200)                                  | ---|M101|----| |-----| |-----| |-+                                  | ---|M102|----| |-----| |---------+                                  | ---|M103|----| |-----| |-----| |-+                                  | ---|M104|----| |-----| |-----| |-+                                  | ---|M105|----| |-----| |-----| |-+                                  | ---|M106|----| |-----| |-----| |-+                                  | ---|M107|----| |-----| |-----| |-+ etc. ---|AutoMode|--|RunAutoCycle|----+---|M200|-----[INC D10]                                  |   ---|StepMode|--|NextStepPulse|---+ Not labeled contacts are conditions to complete step (cylinder extended, button pressed etc.). I hope it helps.

Share this post


Link to post
Share on other sites
The selection I was asking for was between ladder and STL/SFC. Unfortunately in MELSEC MEDOC FX/WIN the SFC view has restrictions regarding displaying SFC which my program has outrun. I have used STL instructions but the program I have written wasn't performing as it should (or I have thought it should). Sometimes it performed unpredictible which made me think that there are some STL implementation details, not documented, that should be well konwn in order to write a good STL program. Threfore I was searching alternative ways for dealing with sequences in PLC programs. Has anyone experience with STL? Hints, tips? Using the sequencer with DECO and INC, the outputs are activated by the step bits? This kind of sequencer can be used for sequences to be executed in parallel? Can step devices (S1...Sx) be used as step bits? cghaba

Share this post


Link to post
Share on other sites
i Can agree with you that STL program can sometimes behave unpredictly, i have once written a program i STL where i use a coil multiple time . This is alowed when using STL or even allowed in Ladder???. What i have noticed is that when on coil was turn on in part of the STL progam , all the other coil where also active. This is not supposed to happened. only the coil that in the active state should be turn on. i tried to figure ou the caused of the problem. In all the state the part of the program this coil was together with an intener PULse functionl.(M8013). It turn out that this (M8013) was causing the problem. after knowing this i have make good use of it in the same program. what you should do is find out what is causing the strange behavior in your STL program, Check the double coils, Check the interlocked between states because two because two consecutive state will both active for one scan, if you don,t this to happened use interlock. i would really like to know what the strange behavior in your program is , try to describe it.

Share this post


Link to post
Share on other sites
I don't use STL since all customers insist on ladder only but if you turn one coil on all instances of that bit are on - even other coils, even if it's in another program, even if that other program is not running. It's because it's one and same bit - whole addressable I/O and device range is treated as global memory. Controllers that support local memory for different task work the same. The only difference is that in this case you could have two different bits with same name so it will look like that one coil is on and other is off. In fact it's two different bits with different scope.

Share this post


Link to post
Share on other sites
I have never ask myself How STL function internally in the PLC CPU. I think you maybe write about how it function internally. But fact is that with STL you can have one coil turn off in part of a program while the same coil(other bit with the same name????) is off. Personally i Think STL is very usefull in applications where there is a clear sequence. I would be very difficult to program an aplication in fully STL, even though is possible.what i do is program clear sequences in STL and the rest of the program in normal ladder.

Share this post


Link to post
Share on other sites
Panic mode, In your DECO-INC sequencer, how do you deal with changes in the program? If for example, in your program you have to introduce one of more steps between steps M103 and M104? Jerrycat I have described my problem in a previous post on this forum (STL programming, page 5) where I gave a very simple code example. On short, the same sequence behaves differently if is executed after the plc reset, first pass through sequence, or in the subsequent passes. An other problem with STL is that I can not use CALL cghaba

Share this post


Link to post
Share on other sites
Ok, I use STL quite a lot in my programs and there are lots of undocumented features. (note features instead of surprises) Originally, I wrote lots of practice programs to see what happens and I was surprised more than once. So here is my most important tip and one that I always use. I never use outputs in my STL stages. I use M bits (flags for the outputs) This way, there are no problems with double coil syndrome Auto and manual is much easier to impliment Outputs can be written sequencially in the program. ie -------------------------------[stl s20] ARM FORWARD ---|X0|----------------------(M20) ARM FORWARD FLAG ARM F LIMIT (further on, not in stl) ------|m0|----|m20|------|X0|----(y0) arm forward        auto   |          |                --|m1|---                 manual   Not the exact ladder just the idea. 2nd tip Lots of zone resets, especially on power cycle. I have seen active states still active after power loss or cycle watch counters and timers within STL - again lots of resets One more tip - lots of small steps, not fewer big ones (one action, one step if possible) Follow these few rules and STL is very good and a breeze to program

Share this post


Link to post
Share on other sites
Albert, Because you said you have experience with STL programming, is there a way to remember the step the PLC was in when a power failure occurs and after that, on power up, to restart from that step? cghaba

Share this post


Link to post
Share on other sites
There are several ways of remembering which state was active before power loss. A special data register D80** (cant remember without the book) keeps track of the active state. This can be MOVed to a retentive data each step and used after power loss Or Even a retentive M, set and reset between stages.

Share this post


Link to post
Share on other sites
I am not aware of retentive M coils unles they are treted differently with STL (which I doubt). You can use L coils or any device type that is retentive. On FX you really need to read the manual to see what devices (or range of devices) are retained after power los (check D registers for example, some are latched) . On larger procesors you can specify range to be retained on most devices. I always choose to keep D registers for example. It's easy to delete content of register or to reset bit - either on power up or any time processor is running. But it's a real pain to deal with limited amounts of retentive memory. I don't like GX Dev functionality. For example I usualy avoid L coils. They are latched and that's fine. When you copy program to another CPU you can copy data tables as well which is also fine (you can alway reset it if that's needed). The problem is that if you are working on (troubleshooting) offline copy of the program you don't know state of bit devices. For word type memory (like D registers values for example) you can look in the datatable.

Share this post


Link to post
Share on other sites
cqhaba, I normally plan sequence of operation before writing the program. Even then I leave some spare steps just in case but you are right, there are times when you need to insert or otherwise manipulate sequence. GX Dev has function to replace (or shift) range of devices in whole program and it takes only seconds even on a large program. It is easy to make mistake so make sure you have working backup. Since the M coils used for steps are grouped together, it takes only single copy and paste to shift comments forward as well.

Share this post


Link to post
Share on other sites
I once found that after upgrading from and A1S-S1 to a AH??? a program (in ladder) acted differently. After much troubleshooting I found that a coil set/reset in multiple places was held to the first condition instead of last as if the scan was running back wards. That was the last Mitsubishi project I was on so I don't know if it was just a short term bug or what.

Share this post


Link to post
Share on other sites
Albert , If you want to start the Program in the state it was in, before a power Failure you can used a latched State Relay(S) for that step . If you want the program to function from the point correctly again you should also check the condition in the rungs.

Share this post


Link to post
Share on other sites
I utilize STL, I have practices with the FX WIN (SW0PC-FXGP/WIN)- Has some bugs in the construction of STL (for myself, occurs messages error), If question, as program STL with FXWIN, of way to do not cause you fail in the code or error of the program, I have some rules. IF it call files STL in CDROM, my drive bad... not possible fix samples picture STL

Share this post


Link to post
Share on other sites
Macgyver BR, Can you repeat? I didn't quite understand you wanted to say. Is there a known list of Melsec Medoc FX_WIN bugs? cghaba

Share this post


Link to post
Share on other sites
Just to clarify a few things. Retentive M relays; All fx models have retentive M's and 'A' series have retentive L relays But The A series does not support STL (STep Ladder) programming (maybe you didnt know that) So all STL programming is done on FX models. I said there was several ways of remembering which state/s are/were active after power cycle and retentive S states are another way. I just never use retentive S's (my preference) After power failure or cycle, I like to clear the board and have the operator decide to continue in auto or to be in manual mode.

Share this post


Link to post
Share on other sites
Albert, I have a FX1N PLC whose all S relays are retentive. So there is no choice. You said "After power failure or cycle, I like to clear the board and have the operator decide to continue in auto or to be in manual mode". What does "continue in auto mode" means? Continue from the state in which the PLC was in the moment of power failure or continue from the auto cycle start, reached after a "zero return" sequence? cghaba

Share this post


Link to post
Share on other sites
You are Correct , The Fx1... only have rententive S relays but the FX2n also have non rententive S relays. I think he means continue from Auto mode means continue the program at the state at was before the power Failure. In manual me the operator will have to make the hoice to go on from the state the program in or clear the state and have the program start from the beginning again.

Share this post


Link to post
Share on other sites
Yes, sorry for mis-information cghaba, on the FX1n all State relays are retentive :( Other models are not. What I meant was (and it really depends on the individual process) that it might or might not be desirable to continue from the same point, in the event of a power failure. Keeping a seperate memory of where it was (retentive M say) and resetting all states will allow the operator to continue or reset to the initial starting state. Safety is paramount in any process, in fact it is an all consuming over riding factor above all else. So I would never want a process to just continue from where it was automatically, just because someone turned the isolator back on. (another reason for not putting outputs within states)

Share this post


Link to post
Share on other sites
I have a mitsubishi fxon-60mr-es and I want to load another program(using melsec medoc fx/win) but the plc is password protected, on the older versions of plc I could erase de memory simply by removing the battery, this one seems that doesn't have one, can anyone tell me what can I do to load another program sequence or to reset(bypass) the password?

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