aTURBOPMAC2USER Posted April 16, 2013 Share Posted April 16, 2013 Dear All, i connect some switches to the outputs of Acc-11E, and write a plcc to make the switches on if P100=1, something like: /////////////////////////////////////////// m3300->address of output 1 m3301->address of output 2 m3302->address of output 3 open plcc 1 clear if(p100=1) m3300=1 // switch 1 m3301=1 // switch 2 m3302=1 // switch 3 p100=0 endif disable plcc 1 close ////////////////////////////////////////// After downloaded the codes to pmac, and issuing p100=1 in the termianl, i find only one switch acts, the switch 3. But if i add a short delay between the three switches, they all act after issuing p100=1: ///////////////////////////////////////// open plcc 1 clear if(p100=1) m3300=1 // switch 1 I5111=... // delay m3301=1 // switch 2 I5111=... // delay m3302=1 // switch 3 I5111=... // delay p100=0 endif disable plcc 1 close ///////////////////////////////////////// i am puzzled at why the delays must exist, and don't want the delays exist between the switches, can you give me some advise? thank you. PS:one turbo pmac2 ultralite, one macro and one acc-11e. Link to comment Share on other sites More sharing options...
TheTruth Posted April 16, 2013 Share Posted April 16, 2013 This will occur if customer is writing to outputs individually as opposed to writing once to the entire 24-bit word or 16-bit word in once shot. Example: M10->X:$78420,0 M11->X:$78420,1 M12->X:$78420,2, if all set to zero intially. If you write M10=1, M11=1, M12=1 in sequence, you might get M10=0 M11=1 m12=1. The problem is that m10 did not get set correctly. The reason it occurs is because the MACRO CPU firmware will perform an entire read/modify write to the entire 24 or16 bit word for each output bit. For example, if you write M10=1, you are really writing to the entire 24 or 16 bit word and it takes time for the MACRO CPU to perform this task. The proper way to do this is to write to the output with one write statement instead of 16 or 24 (or 3 for that matter) simultaneously. The reason you put the delay in between each output in your example is to allow the outputs to be processed properly on a bit by bit basis... the example in the manual builds the output word bit by bit and then with one write statement, you will write to the entire node address instead of 24 individual writes. #define Inputs M4000 ; M-Variable pointer to hold 24-bit inputs #define Outputs M4001 ; M-Variable pointer to hold 24-bit outputs Inputs->X:$78420,0,24,U ; I/O Node 2 24-bit register (inputs) Outputs->X:$78424,0,24,U ; I/O Node 3 24-bit register (outputs) #define InMirror M4002 ; M-Variable pointer to hold inputs mirror word #define OutMirror M4003 ; M-Variable pointer to hold outputs mirror word #define OutState M4004 ; M-Variable pointer to latch current outputs state InMirror->X:$10F0,0,24,U ; Reserve unused memory register (to hold inputs) OutMirror->Y:$10F0,0,24,U ; Reserve unused memory register (to hold outputs) OutState->* ; Self referenced OutState=0 ; Initialize =0 on download Open plc 1 clear If (InMirror!=Inputs) ; Inputs state changed? InMirror=Inputs ; Update inputs mirror word to match current state EndIf ; If (OutState!=OutMirror) ; Outputs state changed? OutState=OutMirror ; Update state of outputs mirror word Outputs=OutMirror ; Update outputs EndIf Close Link to comment Share on other sites More sharing options...
Gregs Posted April 16, 2013 Share Posted April 16, 2013 Are you attempting to write directly to the individual bits of the MACRO output words? If so, that would be a problem because only full words should be used, or individual bits in a "mirror" word. See the examples in the MACRO section of the ACC-11E manual. Link to comment Share on other sites More sharing options...
aTURBOPMAC2USER Posted April 23, 2013 Author Share Posted April 23, 2013 This will occur if ... @TheTruth: Dear TheTruth, as a beginner of PMAC, after a long time to understand the codes you give me and the manual of Acc-11E, I find it‘s still difficult to write the proper codes for my special application. Because of the other outputs will be used, I want those outputs will not be changed when changing output1-3. Can you give me a more dailted example? PS:The configuration of my Acc-11E is: ////////////////////////////////////////////////////////////////////////////////// I6841=$0FB33F;Enable nodes 0,1,2,3,4,5,8,9,12, & 13 at PMAC Ultralite M980->X:$78421,8,16;IO word #1, 1st 16 bit word node2 M981->X:$78422,8,16;IO word #2, 2nd 16 bit word node 2 M982->X:$78423,8,16 MS0,MI69=$20C0A1308800 MS0,MI975=$C;enable node 2 and 3 for I/O MS0,MI19=4 And the adresses of output1-3 are: M3301->X:$78422,16 // OUT1 M3302->X:$78422,17 // OUT2 M3303->X:$78422,18 // OUT3 //////////////////////////////////////////////////////////////////////////////// Thank you very much. Link to comment Share on other sites More sharing options...
aTURBOPMAC2USER Posted April 23, 2013 Author Share Posted April 23, 2013 Are you attempting to... @Gregs: Thank you. Link to comment Share on other sites More sharing options...
aTURBOPMAC2USER Posted April 24, 2013 Author Share Posted April 24, 2013 I find one way finally: /////////////////////////////////// open plc 1 clear cmd"&1b1r" disable plc 1 close open prog 1 clear m3300=0 dwell 0 m3301=0 dwell 0 m3302=0 dwell 0 close /////////////////////////////////// Thanks to everyone who kindly attention this question. Link to comment Share on other sites More sharing options...
TheTruth Posted April 25, 2013 Share Posted April 25, 2013 The proper way to add a time delay in a plc is to use our "countdown registers" and scale them into msec intervals. The countdown decrement every servo cycle. So if you have 2.25KHz servo rate then you would set the register to 2250 to add a one second delay. Using this method allows the uner to add delays in the plc without jumping back and forth from motion programs and plc programs. It also keeps you program logic readable for anyone who has to look or modify your code. Further below, I have added an example of using the plc countdown timers. But your main issue to use the IO mirror word technique that we show in the manual. This allows you to build your output word based on your logic and then in one shot, you write to the MACRO output word. If your wanted to process the examples you gave earlier (M3300, M3301,M3302) you would need the mirror word to point to the equivalent bits. M4300->Y:$10F0,8,16 M4330->Y:$10F0,16 M4331->Y:$10F1,17 M4332->Y:$10F2,16 So, in you code, you would process the individual outs as need by your logic, and since they are a subset of M4300, then the code will handle the state of the outputs whether they are on or off when it sets M981=M4300. PMAC PLC TIMER DELAYS Since DWELL and DELAY commands can only be used in motion programs, PMAC countdown timer registers can be used to issue time delays in a PLC program. The units of these count-down timer registers are in servo cycles. These registers are continuously decremented each servo cycle. At the factory default servo cycle rate of 2258.65 Hz, I10 is set to 3713991. Servo Cycles/msec = 8388608/I10 = 2.25865 cycles/msec = 2258.65 Hz TURBO PMAC Countdown Timers Turbo PMAC’s have 32 countdown timers which are defined by coordinate system I-variables (each coordinate system has two, Isx11 and Isx12) Variable Timer C.S. Variable Timer C.S. I5111 1 1 I5911 17 9 I5112 2 1 I5912 18 9 I5211 3 2 I6011 18 10 I5212 4 2 I6012 20 10 I5311 5 3 I6111 21 11 I5312 6 3 I6112 22 11 I5411 7 4 I6211 23 12 I5412 8 4 I6212 24 12 I5511 9 5 I6311 25 13 I5512 10 5 I6312 26 13 I5611 11 6 I6411 27 14 I5612 12 6 I6412 28 14 I5711 13 7 I6511 29 15 I5712 14 7 I6512 30 15 I5811 15 8 I6611 31 16 I5812 16 8 I6612 32 16 Example: If you wanted a 1 second delay in a PLC program for Turbo PMAC open plc 1 clear . I5111=(1000)*8388608/(I10) ;use C.S. 1 countdown timer while (I5111>0) endwhile . close Link to comment Share on other sites More sharing options...
steve.milici Posted April 25, 2013 Share Posted April 25, 2013 This is not the reccomended method. You should use the “mirror-image” method as described in the ACC-11E manual. The code provided by “TheTruth” is also this method. Transposing to your addresses and your M-variable selections (for outputs only) the following should work for you: #define Outputs M4001 ; M-Variable pointer to hold 24-bit outputs #define OutMirror M4003 ; M-Variable pointer to hold outputs mirror word #define OutState M4004 ; M-Variable pointer to latch current outputs state Outputs->X:$78422,0,24,U ; I/O Node 2 24-bit register (outputs) OutMirror->X:$10F0,0,24,U ; Reserve unused memory register (to hold outputs) OutState->* ; Self referenced OutState=0 ; Initialize =0 on download Open plc 10 clear If (OutState!=OutMirror) ; Outputs state changed? OutState=OutMirror ; Update state of outputs mirror word Outputs=OutMirror ; Update outputs EndIf Close m3300-> X:$10F0,16,1 m3301-> X:$10F0,17,1 m3302-> X:$10F0,18,1 open plcc 1 clear if(p100=1) m3300=1 // switch 1 m3301=1 // switch 2 m3302=1 // switch 3 p100=0 endif disable plcc 1 close Link to comment Share on other sites More sharing options...
aTURBOPMAC2USER Posted April 26, 2013 Author Share Posted April 26, 2013 @TheTruth & steve.milici Thanks a lot. Best regards. Link to comment Share on other sites More sharing options...
Recommended Posts