PLC Sample Code

Sign in to follow this  
Followers 0

RS Logix 500, 5000 etc...

86 files

  1. TOGGLE-BIT BY STATUS BIT's

    toggleing bit using status bit's

    2532 downloads

    Updated

  2. 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

  3. Micrologix 1200 HSC Configuration

    For a user of another forum

    4411 downloads

    Updated

  4. 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

  5. 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

  6. 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

  7. 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

  8. 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

  9. Day of the week

    Day of the week

    3783 downloads

    Updated

  10. 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

  11. 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

  12. 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

  13. 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

  14. 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

  15. MicroLogix 1500 DNet MSG to multiple PF40

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

    2036 downloads

    Updated

  16. 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

  17. 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

  18. 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

  19. 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

  20. 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

  21. 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

  22. InView 2706-P42C w/Ethernet IP ASCII Example Code

    Here is the sample code I wrote for an Allen Bradley InView display I recently did. Well a year ago recently...I just finished up a First Experience article that I will reference this source code for.

    2294 downloads

    Updated

  23. TShark Triggering

    This is a writeup and two examples of using a ControlLogix or an SLC-5/05 to trigger the TShark IP analysis program on a PC using the SerialKeys feature of Windows.
    I am placing this file on the MrPLC website both for sharing and so I can find it again when I need it !

    1153 downloads

    Updated

  24. Generic Sequencer

    This program is used to construct a sequencer with both input and output sequencing. The excel file is used to design the sequencer and includes features to update the user selectable files in a PLC using DDE. The PLC program sequences the inputs meaning that the input pattern for each step determines when the sequencer advances. A mask file is used for the inputs so that those that are irrelevant for a particular step can be ignored. This program does not use the classic sequencer instructions but uses MEQ and MOV instructions with indirect addressing instead. This leaves the end user more flexibility for controlling the step number.
    Update r002: Added CLR instruction to the diagnostic word so that it does not hold "old data" as the sequencer advances.
    EDIT: Added a beefed up version* for a real world machine (OK International 220 Servo bag inserter.) This program is not fully polished, I think the version here was after a few hours of refinement, and then stripping it down for speed. Today, I hit a full 17.5 bags per minute replacing logic that was running at 14.5 bags per minute. I ended up removing another input conditon for the seal bar timer, finding that it doesn't need to inhibit the opener from opening. I need to put in a discharge timer to keep the belt running long enough to send the last box out when finished even when the downstream is blocked, but continue to hold back the input clamps. it would be handy to cycle stop and have the machine empty itself too.
    My main next goal on this particular machine, is to find out why the Ultra drive is not ready and homing quickly enough. I think my reset times are worse than the old logic! It seems I have to wait 5.5 seconds after the drive is ready before I can send it a successful home trigger. Today, I tried keeping logic power applied, and it did well until someone had to physically move this linear device and caused regeneration which triggered a non-recoverable (must power cycle)... E41...So, I can't cheat with two black wires unless I add a shunt or an output contactor to dodge this hard fault. The extra effort will be an amazing improvement in recovery times when they have to open the doors. Now it take almost en seconds sometimes to reset and then reset. I must be sequencing the output logic to the Ultra drive incorrectly,.but I have altered it several times with little improvement. There will be more trial and error with the wiring and perhaps a DB to get this right.
    *The 2nd file includes a rate calculation (boxes per minute in this case) as well as a programmable minimum and fault timeout for each step, multiple modes (auto, manual, single step, bag only).
    Known limitations: I have realized the need to add a macro button to the xls sheet which would read back the PLC sequencer data and populate the bit fields in the sheets. I also still need to lock the references so you can move the raw data without hosing up the references on other sheets. For use as-is, just don't drag the raw bit data or insert data, copying and pasting is fine to move steps forward and backward.
    I also need to add to the excel sheet some columns for minimum time in step, and fault times so they can be edited from the workbook too.

    4499 downloads

    Updated

  25. Assembly machine

    I once programmed these many years ago.  A guy from Allen Bradley setup the program and structure.  I haven't programmed since and I am getting back into it.  I thought the method he used to setup the different tabs, steps and description was rather unique at least for mechanical guy like me.  Easy to follow once you got it down.  Could someone open these a create a .pdf of them?

    106 downloads

    Submitted

Sign in to follow this  
Followers 0