Category Archives: Timers

Omron CP1H Timers

The Omron CP1H series of programmable logic controllers are capable of having 4096 timers. There are twelve different timing instructions in the PLC. Six binary and six BCD instructions for the set values of the timers separate the six basic instructions. The memory area for timers have separate areas for the Timer PVs (Present values) and the Timer Completion Flags. We will be looking at the timer instructions in the CP1H along with some programming examples. Continue Reading!

Horner XL4 Modbus TCP AdvancedHMI Communication

Advanced HMI is a powerful, adaptable HMI/SCADA (Supervisory Control and Data Acquisition) development package that takes advantage of Visual Studio. There is no coding required and you can simply drag and drop items onto the page. The best thing is that the software is free. We will look at using AdvancedHMI with the Horner APG XL4 Controller. Using the program on the process tank application we created previously, we will be controlling and displaying information to the network. The AdvancedHMI package will communicate Modbus TCP over Ethernet to the PLC. We will be able to start and stop our process tank and monitor the parameters via the AdvancedHMI window. Continue Reading!

Click PLC Drum Instruction

Drum instructions are great tools when you have a simple sequence of events that need to occur at a set time interval or as a result of an event. They mimic an electromechanically drum sequencer. The Click PLC has a drum in the instruction set. We will discuss the drum instruction and look at an example of controlling traffic lights.  Keep on Reading!

PLC Programming Example – Delay Starting of 7 Motors

We will look at a PLC programming example of delaying the start of 7 motors. Each motor will be on a switch that the operator can select at any time. The motor outputs should have a 5 second delay between the outputs coming on.

This question originally came from PLCTalk.net. An original solution to the problem came from Peter Steinhoff. His solution is what we will be presenting. It is simple and straight forward.

We will be using the Do-more Designer software which comes with a simulator. This fully functional program is offered free of charge at automation directKeep on Reading!

Click PLC Timers and Counters

Continuing our series, we will now look at timers and counters and how they are used in the Click PLC. Previously we have discussed:
Click PLC System Hardware
Click PLC Installing the Software
Click PLC Establish Communication
Click PLC Numbering System and Addressing
The programming software and manuals can be downloaded from the Automation Direct website free of charge.  Keep on Reading!

Building a PLC Program That You Can Be Proud Of – Part 5

The Game of Simon
Learning all about bit manipulation and sequencers

Simon is a memory game introduced in 1978. It has four coloured buttons, each producing a particular tone when it is pressed or activated by the device. A round in the game consists of the device lighting up one or more buttons in a random order, after which the player must reproduce that order by pressing the buttons. As the game progresses, the number of buttons to be pressed increases. If the wrong button is hit the current game is over. Our game will have a high level score and a current level score.

We will be using AdvancedHMI to communicate Modbus TCP to the Automation Direct Do-More Designer Software Simulator.

Watch on YouTube : The Game of Simon Play (PLC / HMI)
Here is the end result of our program.

Note: The programs are provided free of charge and are an excellent way to learn PLC / HMI programming.

Here is a quick review of the programming series so far. If you are new to the site, we recommend reviewing the other parts in the series first. In part 1 we looked at writing PLC programs to control a traffic light using discrete bits and then using timed sequencing using indirect addressing. Part 2 used indirect addressing for inputs as well as output to control the sequence of pneumatic (air) cylinders in the program. Part 3 and 4 we returned to the traffic light application and expand our program significantly. We looked at the sequence of operation using Input, output and mask tables.

The first thing that we will do is look at the HMI programming. Please refer to the following post for information on setting up and using AdvancedHMI software.
Create a PLC with HMI Training and Learning Environment Free

The following table is the Modbus TCP memory map to the Do-More PLC:

Coil/Register Numbers Data Addresses Type Do-More PLC Table Name
00001-09999 0000 to 270E Read-Write MC1 to MC1023 Discrete Output Coils
10001-19999 0000 to 270E Read-Only MI1 to MI1023 Discrete Input Contacts
30001-39999 0000 to 270E Read-Only MIR1 to MIR2047 Analog Input Registers
40001-49999 0000 to 270E Read-Write MHR1 to MHR2047 Analog Output Holding Registers


Add the ModbusTCPCom control and set the IP Address. Also set the PollRateOverride to 50 so the response to our PLC is quicker.

The following map will apply to our game:
(Communication between the HMI and PLC)

40002 – MHR2 – Register – Game Sounds
40001 – MHR1 – Register – Current Game Level
40003 – MHR3 – Register – Highest Game Level
00005 – MC5 – Bit – Start/Reset Game
00001 – MC1 – Bit – Green Button Input
10001 – MI1 – Bit – Green Button Set
00002 – MC1 – Bit – Red Button Input
10002 – MI1 – Bit – Red Button Set
00003 – MC1 – Bit – Yellow Button Input
10003 – MI1 – Bit – Yellow Button Set
00004 – MC1 – Bit – Blue Button Input
10004 – MI1 – Bit – Blue Button Set


The DataSubsciber is used to read information from the PLC and manipulate the data in the visual basic code.  We will use this to determine what sounds to play.

The following is the code for the button when hit to play the sound and the DataSubscriber1 to play the sound when the playback from the PLC is required. (Console.Beep (Frequncy (Hz), Duration (msec)))

Private Sub PilotLight1_Click(sender As Object, e As EventArgs) Handles PilotLight1.Click ‘ Green Light
     Console.Beep(415, 420)
End Sub

Private Sub PilotLight2_Click(sender As Object, e As EventArgs) Handles PilotLight2.Click ‘ Red Light
     Console.Beep(310, 420)
End Sub

Private Sub PilotLight3_Click(sender As Object, e As EventArgs) Handles PilotLight3.Click ‘ Yellow Light
     Console.Beep(252, 420)
End Sub

Private Sub PilotLight4_Click(sender As Object, e As EventArgs) Handles PilotLight4.Click ‘ Blue Light
     Console.Beep(209, 420)
End Sub

Private Sub DataSubscriber1_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber1.DataChanged
If DataSubscriber1.Value = “1” Then
     Console.Beep(415, 420) ‘ Green
ElseIf DataSubscriber1.Value = “2” Then
     Console.Beep(310, 420) ‘ Red
ElseIf DataSubscriber1.Value = “4” Then
     Console.Beep(252, 420) ‘ Yellow
ElseIf DataSubscriber1.Value = “8” Then
     Console.Beep(209, 420) ‘ Blue
ElseIf DataSubscriber1.Value = “10” Then
     Console.Beep(120, 1500) ‘ Losing Sound
ElseIf DataSubscriber1.Value = “20” Then
     For x = 1 To 8
          Console.Beep(600, 90) ‘ Winning Sound
          Threading.Thread.Sleep(20)
     Next ‘x
End If
End Sub

We now have our HMI interface complete and can move onto the PLC programming.

Random sequence generator – MHR4
The first four bits of MHR4 will be used to generate the random sequence for each step of the pattern.
The first scan is to set (1) a bit in MHR0. This will also ensure that the rest of the bits in the word are reset (0).
The second rung will shift the bits left in the output word MHR0. This will happen once per scan of the PLC. When bit 04 turns on then bit 00 will then be turned on again. This way we will always have one of the first four bits turned on in the output word. (00, 01, 02 or 03) MHR0 is logically AND with Hex value 000F and the result is placed in MHR4.

Start the Game
The game will be started n the leading edge of the reset button. (MC5)
All of the registers and pointers are reset to start the game.
1     is moved into the current level – MHR1
100 is moved into the Play Sequence Pointer – V1
100 is moved into the Input Sequence Pointer – V2
100 is moved into the Current Level Pointer – V0
The random sequence MHR5 is moved indirectly into the Current Level Pointer V0 and this pointer is then incremented by 1.
An initialization bit is then set.

The initialization bit starts a timer for 600msec in order to give time for the HMI to respond. Once the time expires the Initialization bit is reset and the game start bit is set. (Y0)
Y0 – Game Started is used to determine if play is to continue.

Play the Sequence

Set the outputs to play the sequence.
This will also set the sound to play for each of the colours selected. (MHR2)

Reset the sound during the playing of the sequence.

Read the inputs from the HMI. (MC1 – MC4)
Set the bits in V501 so we can compare the word.

If the wrong button is hit, then play a sound and stop the game.

If the correct color is selected, increment to the next random colour in the sequence.

If the correct colour sequence has been entered, then the level has been completed.
Start a delay to ensure that the HMI has finished playing all of the sounds.

When the level is entered correctly and the time delay has expired, we will reset the play and input pointers. The level increases by 1 and  another random number is added to the sequence and the current level pointer is incremented by 1.
MHR1 – Level – Increases
V1 – 100
V2 – 100
V0 – New random number gets indirecly addressed and the pointer is incremented by 1

Setting the Highest Level achieved
If the current level is greater than the highest level, the current level is moved into the highest level.

If no key is hit for 45 seconds after the sequence is played a sound will be played and the game start bit will be reset.

If the game start bit is off for more than 500ms, the sound will be reset.

Download the PLC program and the Bin directory for the AdvancedHMI screen.

Watch on YouTube : Building a PLC Program that You can be Proud Of – Part 5 – Game of Simon

Part 6 will look at a sequencer controlling seven cylinders that can be taught. The cylinders can be operator programmed from the AdvancedHMI screen.

If you have any questions or need further information please contact me.
Thank you,
Garry



If you’re like most of my readers, you’re committed to learning about technology. Numbering systems used in PLC’s are not difficult to learn and understand. We will walk through the numbering systems used in PLCs. This includes Bits, Decimal, Hexadecimal, ASCII and Floating Point.

To get this free article, subscribe to my free email newsletter.


Use the information to inform other people how numbering systems work. Sign up now.

The ‘Robust Data Logging for Free’ eBook is also available as a free download. The link is included when you subscribe to ACC Automation.

PLC Programming Example – Paint Spraying

We will look at a PLC basic tutorial of a paint spraying station. Following the 5 steps to program development this PLC programming example should fully explain the procedure for developing the PLC program logic. Ladder will be our PLC programming language.

We will be using the Do-more Designer software which comes with a simulator. This fully functional program is offered free of charge at automation direct.

Define the task:

What has to happen?

Paint spraying system where boxes are fed by gravity through a feeder magazine one at a time onto a moving conveyor belt. Upon the start signal, boxes are pushed towards the conveyor by valve 1. This is a cylinder which extends and retracts which operates switches S1 and S2 respectfully. A spraying nozzle paints each box as it passes under the paint spray controlled by valve 2. A sensor (S3) counts each box being sprayed. When 6 boxes have been painted the valve 2 shuts off (paint spray) and valve 1 (cylinder) stops moving boxes onto the conveyor. Three seconds later the conveyor stops moving and the hopper with its load moves forward (valve 3) where it is emptied. Ten seconds later the hopper returns to the original position. The cycle is then complete and waits for a start signal again.

Define the Inputs and Outputs:

Inputs:
Start Switch – On/Off (Normally Open) – NO
Stop Switch – On/Off (Normally Closed) – NC
S1 – Valve 1 (cylinder retract) On/Off – NO
S2 – Valve 1 (cylinder extend) On/Off – NO
S3 – Box Detected- On/Off – NO
Outputs:
Motor – On/Off (Conveyor Run)
Valve 1- Cylinder to feed boxes – On/Off
Valve 2- Paint Spray – On/Off
Valve 3- Cylinder to move hopper – On/Off

Develop a logical sequence of operation:

Fully understanding the logic before starting to program can save you time and frustration.

Sequence Table: The following is a sequence table for our paint spraying application.


1 – Input / Ouput ON
0 – Input / Output OFF
x – Input / Output Does not Matter
When power goes off and comes on the sequence will continue. This means that we must use memory retentive areas of the PLC. The stop pushbutton will stop the sequence. The start will resume until the end.

Develop the PLC program:

The best way to see the development of the programmable logic controller program is to follow the sequence table along with the following program. You will see the direct correlation between the two and get a good understanding of the process.

This is the main process start and stop bit. V0:0 is used because it is memory retentive.

Control of the Motor (Conveyor) and the paint spray is done with the V0:0 contact in front of the actual PLC output. The conveyor and paint spray will stop when the timer 0 is done. This is the delay after the last box is detected to allow the box to be painted and loaded onto the hopper.

Control of the box movement onto the conveyor. As long as we have the process start and the hopper count is not complete this will allow the cylinder to put boxes on the conveyor.

Count number of boxes in the hopper via S3. The counter is memory retentive.

Timer to stop the conveyor and spray after the last box is detected for the hopper. This will allow time for the box to be sprayed and loaded into the hopper.

Hopper movement to load and unload the boxes.

The hopper unload timer is to unload the boxes and will then trigger the reset conveyor timer, box counter and the process start bit (V0:0).

Test the program:


Test the program with a simulator or actual machine. Make modifications as necessary. Remember to follow up after a time frame to see if any problems arise that need to be addressed with the program.

Watch on YouTube : PLC Programming Example – Paint Spraying
If you have any questions or need further information please contact me.
Thank you,
Garry



If you’re like most of my readers, you’re committed to learning about technology. Numbering systems used in PLC’s are not difficult to learn and understand. We will walk through the numbering systems used in PLCs. This includes Bits, Decimal, Hexadecimal, ASCII and Floating Point.

To get this free article, subscribe to my free email newsletter.


Use the information to inform other people how numbering systems work. Sign up now.

The ‘Robust Data Logging for Free’ eBook is also available as a free download. The link is included when you subscribe to ACC Automation.

PLC Programming Example – Process Mixer

We will apply the five steps to PLC Program development to our next programming example of a process mixer.

1 – Define the task:


A normally open start and normally closed stop pushbuttons are used to start and stop the process. When the start button is pressed, solenoid A engergizes to start filling the tank. As the tank fills, the empty level sensor switch closes. When the tank is full, the full level sensor switch closes. Solenoid A is de-energized. Mixer motor starts and runs for 3 minutes to mix the liquid.  When the agitate motor stops, solenoid B is engergized to empty the tank. When the tank is completely empty, the empty sensor switch opens to de-engergize solenoid B. The start button is pressed to repeat the sequence.

2 – Define the Inputs and Outputs:

Inputs:
Start Pushbutton – Normally Open – On/Off
Stop Pushbutton – Normally Closed – On/Off
Empty Sensor Switch – On/Off
Full Sensor Switch – On/Off
Timer 3 minutes done bit – On/Off (Internal)

Outputs:
Mixer Motor – On/Off
Solenoid A – Fill – On/Off
Solenoid B – Empty – On/Off
Timer 3 minutes – (Internal)

3 – Develop a logical sequence of operation:

A flow chart or sequence table is used to fully understand the process.  It will also prompt questions like the following.

What happens when electrical power and/or pneumatic air is lost? What happens when the input / output devices fail? Do we need redundancy?

This is the step where you can save yourself allot of work by understanding everything about the operation. It will help prevent you from continuously re-writing the PLC logic. Knowing all of these answers upfront is vital in the development of the PLC program.

4 – Develop the PLC program

Since we need to continue the sequence when the power goes off then memory retentive locations in the PLC must be used. In our example we will use the ‘V Memory’ locations.

The first thing in our program is to control the start and stop functions. This is done through a latching circuit. From the sequence table we know that to reset the sequence we need to have the timer done and the empty sensor off.

The filling of the tank is done through Solenoid A. It is turned on by the start signal and off by the full sensor switch. (Sequence Table) You will notice that we have a memory retentive output and the actual output to active the solenoid.

The memory retentive timer will start timing when we have the start sequence signal and when the empty and fill sensors are on. The timer will reset when the empty and fill sensors are off. Mixing motor will be on when the timer is timing and when the timer is not done.

Solenoid B turns on to empty the tank when the timer is done and the full and empty sensors are on. It will reset when the empty sensor switch goes off.

5- Test the program

Test the program under many conditions. Check to see what happens when power is removed.

Using this five step to program development technique will shorten your programming time. The result will be a better defined logic and easier to understand program, because it has within the documentation the logic flow chart or sequence table.

Watch on YouTube : PLC Programming Example – Process Mixer

Factory IO provides a 3D simulation of the process. Testing of the program is important and should be done in a variety of ways. Factory IO provides a straight forward method of seeing your program in action before you wire your application.

We will be using the BRX PLC Modbus TCP Server (Slave). Factory IO will be the Modbus TCP Client (Master). When the tank fills up we will start a dwell time instead of the mixer time for the simulation.
Here is the mapping of the inputs and outputs using Factory IO.

Factory IO Website is at the following URL:
https://factoryio.com/
Documentation is well done. Start at the ‘Getting Started’ at the following URL:
https://factoryio.com/docs/

You can download the PLC program and Factory IO scene here.

Watch the following video to see this simulation in action.

Watch on YouTube : Process Mixer Test Simulation
If you have any questions or need further information please contact me.
Thank you,
Garry



If you’re like most of my readers, you’re committed to learning about technology. Numbering systems used in PLC’s are not difficult to learn and understand. We will walk through the numbering systems used in PLCs. This includes Bits, Decimal, Hexadecimal, ASCII and Floating Point.

To get this free article, subscribe to my free email newsletter.


Use the information to inform other people how numbering systems work. Sign up now.

The ‘Robust Data Logging for Free’ eBook is also available as a free download. The link is included when you subscribe to ACC Automation.

The Secret of Using Timers

Timers are used in the majority of PLC programs. There are also a wide variety of off the shelf industrial timers that you can use. The implementation of timers can be vast, however it all starts with a TIMING CHART.

A timing chart is the secret behind understanding of the timer that you need in your application. Making a timing chart before writing the program will ensure that all of the information will be accounted.

The timing chart is mapped out on a x and y plain. The ‘y’ plain has the state of the input on/off (1 or 0). The ‘x’ plain will show time.

Lets take a look at a timing chart for an On-Delay Timer. This is the basic operation for an Omron H3BR industrial timer.

Power –  When dealing with PLC’s we must consider when power to the unit is removed what happens to the current time and output conditions.
Start – In this case the start signal is momentary to start the time cycle. (t) We could modify this signal to be maintained until the output switches.
Output – The output will show when it turns on. This can also indicate the opposite, and show when it turns off.
Time – Time is shown by the relationship between the start signal and the output. Our example shows timing starts on the leading edge of the Start. This could have also been on the trailing edge.

Here is the same on-delay timing chart with some more detail. Several conditions are added to the chart.

These conditions prompt us to ask the following questions.
What happens when:

  • Power is removed / restored
  • Multiple start signals are received
  • Do we need a Reset signal. If so what happens during its operation
  • Do we need a display of the time. Present Value (PV) / Set Value (SV)

As you can see the timing chart is vital in determining how the sequence will be performed. This is the exact same method that I use when determining timing sequences in a PLC program.

Lets look at an example.

When we hit the start button, the warning light then comes on. After a fixed time the warning light goes off and the motor starts. The motor will run until the stop button is hit.

We will start by using the Start / Stop Circuit we did earlier.

You will notice that we have added an internal memory bit (C0) as our Start Sequence. This is a memory retentive bit, so we can use the (ST0) $FirstScan to make this circuit non-memory retentive. If power goes off, or the PLC is put into program mode the circuit does not remember the last state. It will default to be off.
The sequence is as follows:

  • Start pressed
  • TMR starts to time (10seconds)
  • Warning output comes on
  • After TMR (10seconds)
    • Warning output goes off
    • Motor output comes on
  • Stop pressed
    • TMR is reset to 0
    • Warning light off
    • Motor is off

Every PLC has timers. They all have different types depending on what you are trying to achieve. It will all start with your Timing Chart.

Watch on YouTube : Learn PLC Programming – Free 8 – The Secret of Timers

If you have any questions or need further information please contact me.
Thank you,
Garry



If you’re like most of my readers, you’re committed to learning about technology. Numbering systems used in PLC’s are not difficult to learn and understand. We will walk through the numbering systems used in PLCs. This includes Bits, Decimal, Hexadecimal, ASCII and Floating Point.

To get this free article, subscribe to my free email newsletter.


Use the information to inform other people how numbering systems work. Sign up now.

The ‘Robust Data Logging for Free’ eBook is also available as a free download. The link is included when you subscribe to ACC Automation.