Sign in to follow this  
Followers 0
lenar

Problem with Add function ( 400) - SIGNED BINARY ADD WITHOUT CARRY

9 posts in this topic

Hello everybody.I faced the problem, function ADD (400) doesn't work. Could somebody help me?In attachment you can see the part of my program, which doesn't work and the full program.I tried to change number of D, which I wanted to add with each other, also I tried to change function from 400 to 401, but it also haven't helped me. Edited by lenar

Share this post


Link to post
Share on other sites
this is the problem: in step 1745 you move once (on W5.05 diffup) #0 to D28. then in step 1771 you add #4 (BCD) to the location written in D28 since you use BCD type indirect addressing ( * is BCD and @ is binary indirect addressing). since in D28 is value 0 your instruction do this: D0(which has some value e.g. 2) + #4 = D0(which now has value #6). You also use binary add +(400) instruction and BCD addend word (this #4), this works for numbers #0 - #9 but for bigger numbers it's wrong, since e.g. #10 is &16 etc. So use appropriate instruction. Finally, in step 1795 (couldn't tell which section cannot see Russian characters) you always (P_On) move content of CIO2001 to D0. So you overwrite with value of CIO2001 the content of D0 which you have previously used to add 4 to. that is the problem hope I helped. regards Edited by tashinz

Share this post


Link to post
Share on other sites
In my previous message I attached wrong programm. I fixed problem with "move content of CIO2001 to D0". Now I attached actual programm. I tried to do what you say, change *d28 to @d28 and #4 to &4. But it does not help. I want to describe principle of working my programm. W5.05 is active when first shift is activated. D28 it is counter of workpieces for first shift. W5.08 it mean that cycle is finished and I should increase counter of workpieces for 4 units each time when w5.08 is on. For increasing I use (+400). In generally it looks in next way: in step 1745 I move once (on W5.05 diffup) #0 to D28. then in step 1769 I add &4 to the location written in D28. since in D28 is value 0 my instruction should do this: D28 + &4 = D28 (e.g. 0+4=4). But it does not work. D28 is always = 0. fata_2.cxp Edited by lenar

Share this post


Link to post
Share on other sites
I think this is the same program, you move CIO2001 to D0 (step 1795) and earlier you you add &4 to D0 which is indirectly addressed by the D28. when you use @D28 and if content of D28 is &0 (or #0) that is address D0. So adding operation in step 1769 is overwritten by move in step 1795. regards

Share this post


Link to post
Share on other sites
Ok. Could you explain me how I should write my program or send me example. I realy don't understand where is my error. When I used direct adress (D28 + #4( # - it means constant)), it also doesn;t work.

Share this post


Link to post
Share on other sites
If D28 = 0 then if you write to *D28 (or @D28) you are writing to D0. This is how you do "Indirect Addressing". If I understand correctly, this is NOT what you want to do. Remove the (*) and (@). ________________ +(400) Signed Binary ADD D28 &4 D28 ________________ This will ADD 4 to the current value in D28 then store it in D28.

Share this post


Link to post
Share on other sites
Make sure to use a differentiated contact though, or it will add 4 to D28 every scan (it will constantly count up if the function remains true)

Share this post


Link to post
Share on other sites
indeed, you should remove @ sign if you want to operate with D28. now it shoud work on diffup of M_521 (W5.08) but only if M_56 (W5.06) is ON. But later, in step 1781 you add D28 (here too remove * from every instruction parameter) to D31 (remove *) and write it to D34 (remove *). D34 should be OK. But as I can see you are regularly using indirect addressing (with * or @), so abandon that approach. If you want to work with address D0 you write D0, D28 you write D28 etc. regards.

Share this post


Link to post
Share on other sites
Thanks everybody, who tried to help me. The theme is closed, I use direct adrress and everything is working. Also I wanted to add that I used +400 function, because then I try to use +401 I get thetransfer to the next word (one part of result from D28 is going to D29), for me using of +400 function is the best solution, because the max value which I really can get is 2500-3000 for per shift. Thank you very much. Edited by lenar

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