PLC Sample Code

Sign in to follow this  
Followers 0

RS Logix 500, 5000 etc...

86 files

  1. Tank program

    Homework completed...

    5222 downloads

    Updated

  2. SLC to a Mettler Toledo BBK Scale RS-232 (thru Devicenet)

    Here is a sample program that talkes to a Mettler Toledo BBK scale using a Point I/O RS232 ASC module on device net. Way powerful module!
    To query the scale you need to send an ASCII command:
    S<CR><LF>
    This is the capital "S" a carriage return then a line feed.
    In the Allen Bradley SLC PLC you'll need to send special characters.
    ST18:10 (see PDF file data_file.pdf page 25)
    string value to printer from PLC
    S^M^J
    ^M in Allen Bradley means = carriage return
    ^J in Allen Bradley means = line feed
    Next you have to parse the data the scale just returned to you.
    Starting at Rung 5 in the PDF read the string from the scale (through devicenet) and begin to parse out the "data".
    The scale sends the PLC a string like this:
    ^S^JS S 0.000 lb
    See ST18:0 in the data_file.pdf.
    Begin to count characters to the data you need weight in the case. Then "extract" the portion of the string into another ST18:1 register.
    You'll notice that the data has a decimal point in the string. Allen Bradley doesn't support "string to real" function so you'll need to extract the whole number then extract the decimal point value into two separate strings. Once you do that you can do a string to integer conversion. Once it's an integer format both the whole number and decimal place you can add the two values back together like it was before as a real type format or floating point using ladder logic to do the math.

    2212 downloads

    Updated

  3. ONE BUTTON 3 O/P

    one push button to on 3 output 1 by 1

    3455 downloads

    Updated

  4. TOGGLE-BIT BY STATUS BIT's

    toggleing bit using status bit's

    2532 downloads

    Updated

  5. LONG DURATION PRECISION TIMER.pdf

    From time to time a long time base precision timer may be required. The SLC .01 second timebase timer is good for only 327 seconds. Cascading a timer and a counter together is undesirable as it will introduce a cumulative error into the time because of differences between when the time period
    actually expires and when the timer is next scanned.
    By running two timers in parallel we can maintain an accurate time reference from which to compute a floating point time with .01 second precision up to 32767 seconds. The first timer has a one second time base and it is the primary timer. The second timer has a .01 second time base and it is
    used solely to compute the fractional seconds. By using a comparison to subtract one second from the .01 second time base ACC when ever it exceeds a full second we can maintain an accurate time independent of the processor scan time so long as the rung is evaluated more than once a
    second.

    2426 downloads

    Updated

  6. Micrologix 1200 HSC Configuration

    For a user of another forum

    4411 downloads

    Updated

  7. RsLogix 500 SQC SQO Basic Sequencer

    Here is the basic sequencer I use for RsLogix500 products. Let me know if any of it is not clear. I simplified an existing program just to show the sequencer parts

    8335 downloads

    Updated

  8. 1761-NET-ENI Series C Configuration Over Ethernet

    Here is a few lines of code I use to configure the 1761-NET-ENI Series C over Ethernet.
    From what I understand the Series D can be configured over Ethernet with ABs utility but we have many Series Cs so this works very well for us.
    I have never tested this on a Series A or B

    2627 downloads

    Updated

  9. Ethernet Link Status

    A Message instruction can be used to check the Ethernet link status of a 1756-ENBT or other ControlLogix family Ethernet module port to determine if there is a good Ethernet link.
    This example shows how to send a CIP Generic Message to Class 0xF6 Instance 1 Attribute 2.
    The applicable page from the EtherNet/IP Specification (www.odva.org) is included in the ZIP file. The program file was greated with RSLogix 5000 v15.

    2739 downloads

    Updated

  10. Conveyor FIFO (first in first out) w/Reject

    Classic example of a FIFO (First in First Out) Load and Unload.
    Application was bottles coming down a conveyor system at a "variable" rate and sporadic. Sometime 10 bottles would be grouped together all in single file others they would be spaced out oneisy twoisy.
    A photoeye was used in a vision cell up stream this photo triggered the vision system and loaded the FIFO at the same time.
    A photoeye was placed downstream next to an air blow off nozzle. This created a "zone" at which you could load and unload the FIFO and keep track of bad bottle in-between your zone. Bottle QTY could vary between the vision photoeye and reject photoeye.
    The vision system was triggered and part status was loaded into N7:0. A 1 means good part a 2 means bad part. The 1 or a 2 was loaded into a FIFO and placed into N7:1 at the reject air station. If the FIFO status equals 1 at reject it was allowed to pass if equal to 2 the air nozzle was turned on under a timed blow off.
    This was a field installed retrofit project that involved a 10 point Micrologix 1000 that cost $72.00 4 Keyence Vision systems and 2 Banner EZ-Beam photoeyes. Cake work.

    5794 downloads

    Updated

  11. Daylight_Savings_CLX

    This is a program to change the processor clock ahead one hour in April and retard the clock one hour in October.

    2352 downloads

    Updated

  12. Day of the week

    Day of the week

    3783 downloads

    Updated

  13. PC Module Status

    In applications where unreliable IP transports (such as wireless) are used some users report "flaky" Produced/Consumed tag connections and I/O connections over EtherNet/IP.
    Rockwell never recommends wireless Ethernet for I/O but some users overlook this recommendation or install links that should be reliable enough but due to installation or configuration issues are not and need to be troubleshot with the participation of the control system.
    This logic example is a diagnostic tool to provide a timestamp and duration for connection faults. It is written for a controller Producing data to another controller over EtherNet/IP but would work the same for a connection across ControlNet or the ControlLogix backplane or for an I/O connection.
    The program was written using RSLogix 5000 v12.06.
    Just putting the remote Controller into this Controller's I/O tree is enough to establish a connection; the Produced/Consumed tag (called Produced_Data on the producer side and Consumed_Data on the consumer side) is not strictly necessary.
    I've used logic like this to find interference from motion controllers or heavy motor starters as well as microwave oven interference in the 2.4 GHz range. It's not a cure-all diagnostic tool but it can tell you when and how often a connection is failing.
    This logic may be used in conjunction with the traffic analysis tool triggering example to capture data on an Ethernet network on both sides of a connection failure event.

    1660 downloads

    Updated

  14. Simple 48 Step Sequencer

    I've seen several Sequencers but not one quite like this. The Integer Bits trigger the step and the Boolean Bitrs end the step. You add the code to make that happen.

    5897 downloads

    Updated

  15. Cycle Countdown in mm:ss

    A simple cycle countdown for HMI displays, showing minutes and seconds remaining in clock format. Includes Start Stop and Pause functionality.

    3133 downloads

    Updated

  16. SLC500 Measure Resistance

    This was one of my early projects. I had to measure resistance in pretty
    wide range on a delicate circuit (subject was changing value and in range
    from few ohms to more than 1MOhm).
    Normally I would have used something like RTD transducer but I just couldn't
    find anything suitable for that range (every transducer I could find was
    stopping at some 8 or 10k i needed at least 100x more).
    The time was running out so I had to put something together and fast.
    This is it. Initially this circuit was using dedicated regulated
    low voltage power supply but since I had spare analog input(s)
    I replaced that power supply with voltage divider (Panel had existing
    24VDC power supply) and simply had to monitor that voltage because
    it was not regulated any more (the 24VDC was regulated but the output
    of divider was changing depending on test conditions).
    Although we like to avoid custom designs this turned out to be so simple
    cheap easy to use and worked extremly well. It is so small that there
    was no need for PCB two resistors ware connected directly to terminals.
    Accuracy off course could not match the 8-digits of precission benchtop
    multimeter but it was on pair with my multimeters which is more
    than I could ask for. I didn't test it for significant ambient changes
    (temperature and humitity).
    There are several ways to do the math for this and in fact used aproach is
    not the simplest or most efficient. But it is good example on how simple
    DC circuits knowledge and very basic match can be used in practice.
    R1 and R2 are not critical and don't need to be accurate either (just need to
    produce voltage that fits selected range for used input card.
    It is robust enough. In fact I was surprised to see results when R1/R2 ratio
    was adjusted to produce only 1 Volt (what kind of ADC they have in their cards?).
    ----- EDIT ----
    Download Link currently doesn't work so just click on
    "Click here for to join forum discussion"

    18803 downloads

    Updated

  17. MicroLogix 1100 Ethernet to Cognex Message

    Example of a couple of message instructions from the ML1100 to a Cognex 3400. I am not triggering the camera via ethernet. I started using the hardware trigger but then the customer wanted to add a "crack" inspection around a 360 degree object so I had to change my camera over to "continuous" trigger to be able to spin the part 360 degrees with a robot looking for a surface crack defect. So then I just message the crap out of the camera during this process.

    3568 downloads

    Updated

  18. MicroLogix 1500 DNet MSG to multiple PF40

    6-rung code example to read one parameter from multiple AC drives on DeviceNet.

    2036 downloads

    Updated

  19. ASCII Write/read to ML1100 and R320 scale

    This is a simple code the ASCII communication between
    Rinstrum R320 weighting indicator and Micrologix1100..... /wink.gif style=vertical-align:middle emoid= border=0 alt=wink.gif />

    3324 downloads

    Updated

  20. Read Monitoring Parameters from E3 with SLC-5/0x

    RSLogix 500 routine to read the first 20 parameters from an E3/E3+ overload relay on DeviceNet with an SLC-500 controller and 1747-SDN. This example uses the new DeviceNet Explicit Message (DEM) instruction introduced with OS302 Series C FRN10 firmware.
    The 21st parameter is also important but will almost always be part of the I/O connection so we're only reading 20 parameters which fits more snugly into a data array.
    This routine only reads from one E3+ device at Node 3 on the network.

    1253 downloads

    Updated

  21. Temperature Trend Direction Flag

    Operator wanted an easy way to tell if temperature was rising or falling in the tank. So without having to setup a full blown trend chart I came up with the "trend flag". If the flag or integer "Tank_1_Resin_Temp_Trend" was equal to "1" then the temperature is rising. If the flag is "0" then the temperature is falling. Easy fix with one rung.

    2438 downloads

    Updated

  22. MSG_PF40_Example

    This is an example of how to control (start/stop and speed reference) a PowerFlex 40 drive with 22-COMM-E interface from an SLC-5/05 controller over EtherNet/IP.
    I do not recommend this practice and this file is provided without warranty or support for illustration purposes only.
    DeviceNet is the preferred method to network AC drives to SLC-500 controllers.

    2440 downloads

    Updated

  23. 20-COMM-E Adapter Diagnostics

    To rule out problems with data traffic to AC drives sometimes I ask a user to monitor the DPI Diagnostic Items in the 20-COMM-E interface. These can be read using Drive Explorer Drive Executive or the 20-COMM-E embedded Web page.
    But the controller can also read these values with a little help from the 20-COMM-E User Manual and some ladder logic for messaging.
    The DPI Diagnostic Object is Class 0x99. The Diagnostic Item value is Attribute 1. But what's the Instance number ?
    The Instance number for Adapter items begins at 0x4000 (16384) and I am interested in Items 49 through 55:
    Item# Name Instance # Data Size (bytes)
    49 EN Rx Overruns 16433 2
    50 EN Packets Received 16434 4
    51 EN Rx Errors 16435 4
    52 EN Packets Sent 16436 4
    53 EN Tx Errors 16437 4
    54 Last TCP Reset 16438 2 (Read Only)
    55 Missed IO Packets 16439 4
    This ladder example just reads those 7 values repeatedly. I could be expanded to cover multiple drives.
    These values are all reset when power is cycled which is why I'm interested in having the controller read them instead of standing around looking at the software monitor all day or trying to have people read them before they cycle power to the drive.

    1304 downloads

    Updated

  24. TRUNCATE IEEE754 FLOAT

    Sometimes is necessary to truncate (remove the fraction) or round a floating point number that is outside the range of -32678 to +32767 - making it impossible to use a MOV to an integer to make the conversion.
    This is a program I worte that shows how to perform a truncation directly on the floating point number by copyng the 32 bit pattern of the float and then determining which bits of the mantissa to keep and clearing all the rest. It includes three subroutines two of which show two different methods of truncating the float and a third which rounds the float to the nearest whole float.
    An understanding of the IEEE-754 float format is helpful in understanding how this program works but its not necessary to use it.

    1674 downloads

    Updated

  25. 2 Button manual sealing bar

    2 button operation for a maual sealing bar. both buttons must be pressed at the same time in order to complete operation. Good for keeping the operators hands away form the sealing blade.

    2181 downloads

    Updated

Sign in to follow this  
Followers 0