Sign in to follow this  
Followers 0
trm

(newbie) isntruction question

12 posts in this topic

Hi as for now i have never have the need to check a whole data reigster (i.e D?). I have used AND D100.3 for example And also ADD , SUB, DIV, MUL, MOV, BMOV, MOVP, AND=, OR=, etc instruction i have used with D? registers but how to do this if( REGD10 & 0x0203) ... LD D10 AND H0203 looks fine, but LD loads only _bit_devices like M,X,Y, etc ... :( I know it's a funny and maybe stupid question ,but .. here it is ... Edited by trm

Share this post


Link to post
Share on other sites
Compare instructions. Compare D10 to the hex value. You didn't say which PLC.

Share this post


Link to post
Share on other sites
Yes i had this in mind, but what if i need to apply some other logical/math action after it/later ? For example: D10 = 90F1 mask 8010 -> result 8010 and now i want D10 = 8010 so i can apply later new masks just for check or again to modify the D10 mask 1000 -> result 0000 ??? ----- I use it like this just for a simple check: LD M8000 AND= D10 H0203 as I wasn't sure if AND= needed control instruction ,but i think it doesn't, but just to be sure ... or i needed something like this in C: if( variable ) { ... } or if( variable != 0) { ... } which both means _if_variable_is_true ... LD<> D10 H0 or LD= D10 H0 INV which logically is the same The PLC is FX3U-16MR Edited by trm

Share this post


Link to post
Share on other sites
Hey trm, As crossbow mentioned, use the compare commands. For FX3U you can use LD>, LD<, LD= and LD<>. These are usually used for comparing the value of a data register with another value. The AND= instruction can also do this job for you. All of the above mentioned instructions are used in series with other contacts. If you want to logically and two words, use the WAND instruction.

Share this post


Link to post
Share on other sites
I have one strange problem , i have the following lines of code: LD M8022 CJ somewhere This code makes the PLC in state "dead". The error led on the PLC doesn't blink it is always on and there is no communication withthe PLC ideas ? Only way to make it work again is to turn power off and then turn it on. ps: if the code is LD M0 OUT M1 RST M0 CJ somewhere it works without errors I really want to say 'what the f***' ... :| Edited by trm

Share this post


Link to post
Share on other sites
No idea. Maybe the issue is using the M8022 special address? Or are you 100% certain that the destination label somewhere exists in the current program?

Share this post


Link to post
Share on other sites
Yes ! If it doesn't i get error something like "label doesn't exists" or it was "no such label" ;) :) I rewrite my code to use FOR and i workaround this issue , but it's really strange. One more thing is that i need(ed) to use CALL in a FOR and as far as i know/understood from the documentation it is permissible( i mean allowed ;) ). But when i have this code: FOR TIMES CALL FUNCTION NEXT It compiles ok, but then when i run it on the PLC i get ERROR_LED ** btw: i now use a lot wand, wor, wxor function, so thank you for telling me for them , i somehow was missing them :) OFFTOPIC ** ii "hate" when this led goes on , it means ... "well we know you are frustrated cause our IDE and compiler didn't warn you, but hey it was not going to be so fun without such possible scenario: to have a 0 errors , 0 warning program , but crashing in the PLC :D , also we are happy you paid us so much so we can screw with you End of OFFTOPIC Edited by trm

Share this post


Link to post
Share on other sites
FOR TIMES LD TRUE CALL FUNCTION NEXT

Share this post


Link to post
Share on other sites
Thank you a lot , my program now works as expected and looks the way i wanted :) :) Thank you all again ! Although the program works perfectly and gives correct results i have PLC error (when i check PLC Diagnostics) --- I have a suggestion that it is because of missing END but when i try to add END GX IEC Developer tell me "he" puts them , not I. And when I add FEND it tells me i can't add more than one and i have only one ;( Very odd , but most likely it is also something i have read but missed Have a nice day and "Happy coding" :-]]

Share this post


Link to post
Share on other sites
I don't know what documents did you read. The END command is being added automatically while compiling in IEC Developer.

Share this post


Link to post
Share on other sites
I know this, but FEND i have to add !?. So why it is telling me there is two FEND instruction.... Instantly it comes to my mind that the IDE adds and the FEND instruction automatically ;) :) ps: but what about the operational error i get :???

Share this post


Link to post
Share on other sites
If your program has function(s) and/or function block(s) that are used without macrocode, the FEND command is being added automatically too. To understand the cause of PLC error is need to check the program code.

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