cfordyce Posted December 20, 2011 Share Posted December 20, 2011 Hello, I was wondering if someone would be willing to explain how you set up an ACC-14E using an OPTO board as the input/output interface. I'm struggling with how to set up each memory address as either an input or an output. I think I gathered that you have to setup them up in blocks of 8 (either input or output). Do you have unusable inputs (cannot be used as outputs) if you have less than a block of 8? What I would like to do is set up my card to have 40 inputs and 8 outputs. Then I need to know what I have to change to invert individual inputs if I need to (NO vs NC switches). Thank you for your help. Casey Link to comment Share on other sites More sharing options...
steve.milici Posted December 21, 2011 Share Posted December 21, 2011 The control register works in groups of 8-bits. PMAC will allow bits within a byte programmed as outputs (bit value of zero in matching location of the control word's bits 0-5) to act as an input as long as the output state of the bit is off (non-conducting) - only read the bit. When using the register select control bits for inversion control (bit 6=1 and 7=0) the maching bits in the addressed I/O register (BASE+0 thru BASE+5) allow for individual inversion control. This is described in detail in the ACC-14E User Manual. Link to comment Share on other sites More sharing options...
mbalentine Posted December 21, 2011 Share Posted December 21, 2011 The set-up may appear at first to be a bit tedious - not to worry, it IS a bit tedious (also a byte tedious in this case, but I digress). I'll cite the manual pages for better explanation, there are really only 3~4 pages needed to understand a basic setup. The configuration options allow more flexibility than you're likely to find in other products, and although we are writing bits & bytes, this allows the programmer (you) to have exactly what you want without designing your own hardware. You are correct that the bits must be defined as inputs or outputs in consecutive blocks of 8. If you need only 6 inputs, you must define 8. Input and Output definition is handled as a byte. 0) Your post indicates general purpose I/O, so we'll not worry about latching the data as would be required for position feedback data. If you are using Opto22 boards (or equivalent) you'll want to remove jumper E5 (see page 7, 51, 52) so that pin #48 on the 50 pin headers (two of them) do not carry a signal. I would recommend removal unless you have a specific need for the OCLK signal. 1) Decide where you want to place this board in memory so that it does not conflict with whatever else you have in your system. Page 10 shows the options for setting SW1-1,2,3,4. Note that SW1-5,6 should always be ON. In the upper RH part of the table, we can select Y:$078F00 - Y:$078F07 as our memory footprint by setting SW1 = 111100 Note the table tells us the IO bits are in the lower 8 bits of the first 6 addresses (078F00 - 078F05) The other two addresses are where the confusion begins. 3) Direction Control is done in blocks of 8 bits (pp 11). Since each of the first 6 addresses hold 8 IO bits, we are using 1 bit in the control register to control whether these blocks of 8bits (byte) are used as inputs or outputs. So we're associating the first 6 bits (0-5) of the control register with definition of the 6 I/O bytes (addresses 078F00,0,8 - 078F05,0,8) We'll set your board up for 16 inputs + 8 outputs + 24inputs 078F00,0,8 - inputs bit0=1 078F01,0,8 - inputs bit1=1 078F02,0,8 - outputs bit2=0 078F03,0,8 - inputs bit3=1 078F04,0,8 - inputs bit4=1 078F05,0,8 - inputs bit5=1 So we need to write to the control register Y:$078F07,0,8 = 0011|1011 ($3B) We'll do the actual write later 4) Inversion Control is done in setup register1, which exists at each address. Unlike direction control which is byte based, inversion control is done bit by bit. Defining this is a three step process: - First, write 01 to bits 6&7 of the control register to select the Inversion Control function Y:$078F07,0,8 = 0100|0000 ($40) see table pp11 - Second, write the inversion definition to the data area of each address. A '0' means invert, a '1' does not invert 078F00,0,8 = 1111|1111 ($FF) do not invert inputs 0-7 078F01,0,8 = 1111|0000 ($F0) invert inputs 8-11 078F02,0,8 = 1111|0011 ($F3) invert outputs 18&19 do not invert 16,17,20-23 078F03,0,8 = 1010|0101 ($A5) you can invert individual bits in any pattern desired 078F04,0,8 = 0000|0000 ($00) 078F05,0,8 = 1000|0001 ($81) - Third, turn off this configuration mode by setting bits 6,7 back to zero Y:$078F07,0,8 = 0000|0000 ($00) - In general, inversion set to 1 will give expected results of Input high=1 and 1=Output conducting 5) Read Control - I think most people leave this at 0 for reading of the pin state rather than the register. If you want to change it the procedure is the same as Inversion control, except you write Y:$078F07,0,8 = 1000|0000 ($80) as the first step. You could write all zeros to be certain of the configuration if you like. Be sure to clear bits 6,7 when done 6) Define an M-variable to each of the IO addresses. See example on pp13. 7) Use a 'run once & done' PLC to configure the card on start-up. Be sure to return bits 6,7 of the control register to zero, and bits 0-5 for In/Out configuration determined in section 3 above. Your PLC will be something like this (using Mvars to write to the addresses) OPEN PLC1 CLEAR ;pseudo code, Mvars will need to be defined to point to the addresses shown ;set inversion control Y:$078F07,0,8 = $40 ;turn ON inversion setup function ;inversion data Y:$078F00,0,8 = $FF ;inputs Y:$078F01,0,8 = $F0 ;inputs Y:$078F02,0,8 = $F3 ;outputs Y:$078F03,0,8 = $A5 ;inputs Y:$078F04,0,8 = $00 ;inputs Y:$078F05,0,8 = $81 ;inputs Y:$078F07,0,8 = $00 ;turn OFF inversion setup function Y:$078F00,0,8 = $FF ;write actual data to inputs to initialize as inputs Y:$078F01,0,8 = $F0 Y:$078F02,0,8 = $0C ; clear outputs to OFF state using complement of inversion setup data Y:$078F03,0,8 = $A5 Y:$078F04,0,8 = $00 Y:$078F05,0,8 = $81 Y:$078F07,0,8 = $3B ;set direction control bits DISABLE PLC1 CLOSE All in all it's probably easier to read the manual Link to comment Share on other sites More sharing options...
cfordyce Posted December 21, 2011 Author Share Posted December 21, 2011 Thank you for the excellent explanation! I am just getting my panel switches wired to the Opto board. I hope to get this to work this week. I'll post back with stories of success, or failure... Link to comment Share on other sites More sharing options...
mbalentine Posted December 21, 2011 Share Posted December 21, 2011 For inversion control I would recommend setting to all 1's. You can then invert in the PLC or Motion programs using XOR. This will be more clear for documentation. I would generally avoid the mix & match usage or some poor sap (the original programmer) will pull their hair out 6 months later. M1005->Y:$078F01,4,1 ; an input bit ; you can buffer to another bit M2005=M1005^1 ; M2005 is now inverted from actual input IF (M2005 = 0) ; true if input bit =1 ;or use invert logic at each point of usage (my preference) IF (M1005^1 = 0) ; true if input bit =1 Steve points out that you can cheat the system (new to me) and use bits that are part of an Output byte as inputs (!) by leaving them off and then reading their state. Steve knows. .... the rest of us are mere mortals. Link to comment Share on other sites More sharing options...
cfordyce Posted December 27, 2011 Author Share Posted December 27, 2011 This is probably more like a Delta Tau 101 question, but I haven't been intimate with my control in a while and I have forgotten something that is probably fairly simple. When I try and download my plc1, like the example above, it says that I need to have a buffer open first when it gets to the line "M6000->Y:$078F07,0,8 = $40 ;turn ON inversion setup function". How do I download this PLC to the controller? Thanks Link to comment Share on other sites More sharing options...
Richard Naddaf Posted December 28, 2011 Share Posted December 28, 2011 You are probably downloading correctly (yellow "download" button in the editor window). I suspect that your board base address is NOT at $078F00. mbalentine is showing an example of his setup. Check the dip switch settings on the board, or use the UMACconfigPro2 under Tools to identify the cards in the rack. Link to comment Share on other sites More sharing options...
cfordyce Posted December 29, 2011 Author Share Posted December 29, 2011 I set my dip switches to the same as his example. I am using the Focus program to write and edit the plc. I'll try downloading it from Pewin32pro2. Link to comment Share on other sites More sharing options...
cfordyce Posted December 30, 2011 Author Share Posted December 30, 2011 I tried to download it from Pewin32pro2 without success. It still wanted to have a buffer open. I confirmed that my switches are set to the correct address. It is probably something very simple, but I can't find it... Link to comment Share on other sites More sharing options...
mbalentine Posted January 3, 2012 Share Posted January 3, 2012 If your PLC has the line of code as shown in your email, I don't think that is acceptable to PMAC. M6000->Y:$078F07,0,8 = $40 In my example I put the physical address as pseudo code to make the associations easier to see. You will need to define the Mvar outside the PLC, I usually do this in a seperate file, but you can also place the definitions in the same file as the PLC - but outside of the PLC itself. Commands outside a PROG (motion) or PLC buffer will execute immediately (Software manual divides commands into two categories, those that will execute immediately [On-LINE] either from terminal window or from a file download, and those that are buffered to PMAC for execution as a program [PROGRAM COMMANDS].) In general the immediate execution is used to configure PMAC for your application. The buffered commands are those that PMAC executes in 'real time' when running the user application. There is some 'bleed over' in that most Ivars can have their values changed in a motion or plc program, and a COMMAND"...." statement can be used inside a program to execute certain "ON-LINE" commands. ;BEGIN FILE******************** ; start file with comments ; and revision notes M6000->Y:$078F07,0,8 ;execute definition statement immediately ; other Mvar definitions as needed OPEN PLC1 CLEAR ;this is actually a combination of immediate commands that directs PMAC to not try to execute but rather buffer the following instructions. ; these instructions will be buffered to PLC1 and executed later when the program is active M6000=$40 ; other commands Disable PLC1 ;turns itself off ; CLOSE ; turn OFF buffering ;END OF FILE******************* As mentioned above I generally break my projects into three *.pmc download files: 1) Immediate commands for: a) DEFINE USER BUFFER command and any other buffer commands for linearization, etc. Any PMAC features that require a specific buffer. b) AXIS definition statements (including coordinate systems) c) I variable setup for axis in use (reset PMAC & do a dummy configuration BACKUP of the Ivars only and then use this file as a template to build your *.pmc download file. It will have default values and functional comments for each variable) d) M variable definitions 2) PLC & PLCC programs 3) Motion programs Link to comment Share on other sites More sharing options...
cfordyce Posted January 3, 2012 Author Share Posted January 3, 2012 mbalentine, Thank you for your explanation. You just confirmed that I have revised my code correctly. Another motion guru told be about the mvar definition rules. I placed all of my mvar definitions in my system initiation file that I just download and save to the PMAC. I used my PLC1 to set up my I/O as you showed in your other post. I haven't had time to download the new code to my PMAC, but I'm confident it will work. Link to comment Share on other sites More sharing options...
cfordyce Posted January 20, 2012 Author Share Posted January 20, 2012 My I/O is functioning properly. I haven't had a chance to use any outputs yet because I don't have my second OPTO board wired in yet. Link to comment Share on other sites More sharing options...
Recommended Posts