PLC Sample Code

Caps, LSS, CPT, Syswin, etc...

92 files

  1. CP1L and CP1H EasyModbus FB

    Ideally suited to multiple Omron inverters connected on Modbus RTU network and where the Omron FB is too memory hungry.<br />Reads <u>upto</u> 16 registers from register 20 and writes to two registers (Fixed at 1 and 2). <br /><br />Set the serial port to Serial Gateway and set the baud rate to match the inverters. Inverter default is 81N. In the V1000 set H5-01 to the address. It must start at 1 and have no gaps.<br />The baudrate works upto 115200 (with V1000)<br /><br />Data format suits V1000 F7 E7. Don't use for V7 or J7.<br /><br />Data is only written on a change. The change is managed in the PLC NOT in the inverter. Data is read sequentially from node 1 to 'MaxNodes'.<br /><br />Not tested on CP1L-L (one serial port version). I think its Easy modbus addresses are different to two port versions.<br /><br />You can choose addresses within CIO only.<br /><br />Refer to any inverter manual for modbus addresses.
    Edit: the CP1L 14/20 use port two EasyModbus addresses. I think you can select Port 2 but set port 1 to Serial Gateway. Can someone try this??

    4468 downloads

    Updated

  2. Omron CS1 Sequencer

    OMRON CS1
    This is an example of a sequencer using a reversible shift register instruction
    Easy to troubleshoot because you can see what step it is on when the sequence stops for whatever reason.
    Easy to add steps and not too bad to insert steps.
    This program example shows the ease with which you can move to a specific step in the sequence after an alarm or stoppage.

    2666 downloads

    Updated

  3. Calendar Calculation

    FB will output time different in btw system date/time [PLC] and input date/time [external]. Different time range from 0~9959 minutes. 9960~9999 is allocated for error code.

    2104 downloads

    Updated

  4. Pinstamp

    TASK:
    Do more with less.
    Write PLC code for an ancient Telesis pinstamp printer
    from the early 1990's, replacing a flaky ink jet printer
    that never worked properly
    Existing control system is an AB SLC500 PLC controlling
    a sixteen station assembly line.
    An AB basic module was used to communicate to the ink jet.
    Our options were:
    1) Modify basic module code to suit ancient pinstamp
    2) Find another way of doing it since we were in a hurry
    and didn't have enough experience with the AB system
    to do it in time.
    We opted to take an existing OMRON CQM1 PLC that we had
    gathering dust in the corner, and write code for the pinstamp
    Our part model and reject codes would be sent from the AB
    discretely as binary inputs to the CQM1
    Using the CQM1 RS-232 port, the Telesis functions strictly
    as a printer with no confirmation signals sent back to the CQM1
    Having installed a clock module in the CQM1 we were able to extract
    the Julian day and year and print it along with the model # and
    reject code .
    Not exactly the finest example of modern technology, but it
    works.
    Who said that OMRON and AB can't get along!
    P.S. - DM memory saved in project!

    872 downloads

    Submitted

  5. Easy to use Modbus RTU Master for CP1L CP1H CJ1 CJ2 CS1

    This application is a ready to use Modbus RTU master for CP1L, CP1H, CJ1, CJ2, and CS1.
    The user creates 'tables' of items to read and write. The ladder code automatically performs the communications as setup by the user.
    The CJ1 / CJ2 / CS1 solution requires the use of a Protocol Macro on an SCU31 / SCU41 module, and the CP1L / CP1H function uses the Serial Gateway function of the CP1H / CP1L on a CP1W-CIF11 or CIF12.
    Sample NS screens are provided with an Omron 3G3JX inverter as an example Modbus RTU slave.
    Updated 1/7/2011 to include 3G3MX2 screen for NS, and to include CJ1W-SCU22,32,42 in documentation.
    Updated 9/19/2012 to support 2 ports on an SCU card (CS, CJ1, CJ2) or 2 ports on a CP1L / CP1H.

    21539 downloads

    Updated

  6. CS CJ CP NSJ password set

    This is a Function Block to set a password in a PLC.
    It can be used to automatically set a password, so you don't have to do it from CX Programmer.

    3239 downloads

    Submitted

  7. Omron to AB EtherNetIP Explicit Messaging

    Example code to read and write integer and floating point data to and from CompactLogix, ControlLogix, and MicroLogix 1400 using EtherNet/IP.
    This works with Omron PLCs using CJ1W-EIP21 or CS1W-EIP21 EtherNet/IP modules, or CJ2H-xxx-EIP or CJ2M-CPU3x PLCs with built in EtherNet/IP.

    3675 downloads

    Submitted

  8. Analog Scaling Function block

    Function to scale an analog input. Allows input of lower and upper values for the range to which you are scaling, input for the maximum value of the analog input channel and the channel itself. There are three outputs that provide the scaled value in three formats: Real, Integer and BCD.

    6270 downloads

    Submitted

  9. FINS Ethernet Master / Slave Solution

    Drop in code for Single Master and up to 30 Slave PLCs on FINS Ethernet.
    The Master PLC can be a CP1L-E, CJ2M, CJ2H, CS1, or any PLC capable of sending FINS commands.
    Originally designed to share data across a network of CP1L-E PLCs.
    Each PLC shares 100 words in each direction with the master PLC.
    The reads can be setup to read as fast as possible, or at a given interval.
    The writes can be change of state (COS) driven, as fast as possible, or at a given interval.
    .pdf manual included.

    2368 downloads

    Submitted

  10. Lowpass filter function block

    Lowpass filter for Omron PLCs.
    Only tested on CJ-series CPU. Use at own risk!
    Many thanks to Peter Nachtwey @ PLCS.net for providing the mathematical formula.
    Unfiltered = raw unfiltered value in INT.
    TC = Time constant tau, given in seconds.
    Filtered = Filtered value in INT.
    FilteredReal = Filtered value in REAL.
    - The FB can be duplicated.
    - The FB can only be used in program parts that are scanned every CPU cycle, as it relies on the "P_Scan_Time_Value" variable.
    According to the working principles of a lowpass filter, it will take the filtered value tau amount of seconds to reach 63% of the unfiltered value.
    The value will reach within 1% of the unfiltered value in approx 5x tau.

    700 downloads

    Submitted

  11. FB : Password Set

    There was already a nice FB made available by PMCR, but it had little restriction which I didn't liked. So I made this one. This FunctionBlock enables you to set a password like '1234OOPS' rather instead of being limited by HEX digits (0-9..A-F)
    So it's kinda a alternative to the one PMCR made available.
    I also added another functionality. This Function Block is configurable to work in automatic mode (password will be set on certain PLC hour) and/or manual mode, where you can give a trigger to the Function Block which will set the password (as example, when you're finished with online editing you can trigger the FB)
    I think it will explain itself. If you have questions, you can PM me.
    Have phun!
    ^^

    1263 downloads

    Updated

  12. HHMMSS.cxf

    FB to provide a simple long timer with time remaining outputs. Time can be entered in HMS (or just mins for example).
    Time remaining is normalised to HMS though.
    Uses 2 other FBs. Create instances of HHMMSS as required.

    761 downloads

    Submitted

  13. Recipe Sample Code - Ladder program with supporting NB project

    This is a quick bit of code to show how a recipe function might be written if one were to do it in the PLC rather than the HMI. This is the basic building blocks with which a program could begin to be written. The BSET instruction combined with the indirect addressing method demonstrated would allow for a delete function. Copy and other functionality could be added using similar concepts.

    1453 downloads

    Submitted

  14. DATE Instruction for CP PLCs

    Sample code to set the RTC on a CP PLC. Individual sections can be enabled/disabled.

    94 downloads

    Submitted

  15. CJ2 to V680S (ETN version) using Socket Service function blocks

    This is a short bit of sample code using Socket Service function blocks to read and write data from / to a V680S RFID tag using the Modbus TCP (-ETN) version of the V680S.

    302 downloads

    Submitted

  16. Basic Servo Control Code for NJ and 1S

    This is a very simple ladder program that shows the basic steps to enable, zero and move a 1S servo using the NJ controller.

    559 downloads

    Submitted

  17. NJ/NX Get IP Address

    A Library containing a function Block that can be run on any Omron NJ or NX PLC. The Function Block will retrieve the host PLC's IP address, Subnet Mask, Gateway, and MAC Address. The Port Details are displayed through 2 structures , 1 per-port. In the event you only have 1 Ethernet port then the structure for the 2nd port will contain all 0s. Data Format:
    IP Address - USINT[4]
    Subnet - USINT[4]
    Gateway - USINT[4]
    MAC - BYTE[6]  (hex value)
    Access the retrieved details by the typical parent-child tag structure. ex. Port_1_Detals.IP_Address[0] will get the first octet of Port 1's IP.
    Tested on: NX1P2, NX102, NX502, NX7, and NJ301
    IMPORTANT: This Function Block should not be run immediately after startup. Allow the PLC a few seconds to establish a connection with the Ethernet network.

    75 downloads

    Updated

  18. valve_control

    A working example of an FB to control a valve from an HMI panel. Controls closing/opening times, plus a little visualization.

    49 downloads

    Submitted

  19. Function block on ST for algorithm DIFU DIFD

    An example on ST is the definition of the fronts of a discrete signal.

    29 downloads

    Submitted

  20. Function block RANDOMIZE on ST

    PRNG algorithm packed into a functional block. As an example of using ST language for Omron CJ series PLC.

    40 downloads

    Submitted

  21. CP1 Modbus TCP Peer to Peer

    This solution solves Modbus TCP Peer to Peer applications for CP1H / CP1L PLCs with CP1W-MODTCP61 adapter modules

    230 downloads

    Submitted

  22. Sysmac Studio Simple PID Example

    A simple test program and starting values for the PIDAT instruction in Sysmac Studio. Simply run the simulator (Simulation-> Run) and toggle the Test_PID bit. Simulated feedback will allow the loop to operate normally. The setpoint can be adjusted by modifying the PID_SP variable. There is a pre-programmed data trace that traces the SP, MV, and PV.
    To use the data trace navigate to DataTrace0 and start the trace, flip the Test_PID bit true and the trace will log 10k samples. Change the SP and view the behavior when the trace finishes.

    60 downloads

    Updated

  23. MY PIDAT CONTROLLER SIMULATOR IN CX PROGRAMMER

    this is my PIDAT simulator for CX programmer. D100 is the Steady State (50BCD  in the example), D410 is (simulated)  Process value. It needs a Omron PLC ( kind of CP1E) with n.01 AI, n.01 AO ( AO needs to be wired to AI to run the simulator). When starting set D410 (0:100) and start PIDAT to see the regulator at work.   Keep AT OFF to see tracking process. 

    22 downloads

    Updated

  24. MY AO DEAD BAND CONTROLLER IN CX PROGRAMMER

    here my simple dead band controller for Omron CP PLC with Analog IO capability, other than that  you may have a precise Voltage/Current reference + multimeter, however the controller can work in simulation mode too because only basic functions have been implemented. Proposed values are: Range 50-200, SP 125, dead band +/- 20.

    8 downloads

    Updated

  25. my DEAD BAND CONTROLLER ON/OFF

    in this simple example, very similar to the previous one, 190 AO is controlling the actuator at 0% 50% and 100% of is operating range and  91 AI is providing PV for the error comparator. This control could be beneficial where keeping exactely the SV is not mandatory plus the actuator  is operating poorly in the proportional band.

    9 downloads

    Submitted