lenar Posted April 28, 2015 Report Posted April 28, 2015 (edited) 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 April 30, 2015 by lenar Quote
tashinz Posted April 28, 2015 Report Posted April 28, 2015 (edited) 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 April 28, 2015 by tashinz Quote
lenar Posted April 30, 2015 Author Report Posted April 30, 2015 (edited) 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 April 30, 2015 by lenar Quote
tashinz Posted May 5, 2015 Report Posted May 5, 2015 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 Quote
lenar Posted May 8, 2015 Author Report Posted May 8, 2015 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. Quote
IO_Rack Posted May 8, 2015 Report Posted May 8, 2015 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. Quote
Michael Walsh Posted May 8, 2015 Report Posted May 8, 2015 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) Quote
tashinz Posted May 8, 2015 Report Posted May 8, 2015 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. Quote
lenar Posted May 22, 2015 Author Report Posted May 22, 2015 (edited) 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 May 24, 2015 by lenar Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.