PLC Program


Blog: Build your own Hangglider and Paraglider Winch

PLC program

In the picture right below you can see a good overview of the PLC program and the visual interface made in Codesys, which is a open source industrial PLC program.
You can find a lot of videos on youtube about Codesys 3.5 programming, as it is the most common program used in the industry.
The program is divided into “program sections” and and “function blocks” that contains all the code.

Codesys also allows you to make web visualisations, so you are able to interact with the winch through a browser on your mobilphone, table, etc.

The whole PLC program can be downloaded here: version71.

But you can find screendumps of the whole program right below this picture, that make you able make the code in another type of program.

Explanation of the structure

The whole PLC program is divided into three tasks. One “Drum”, “Sled” and “Misc”.

The screen dumps below, differs a little from the latest program update. But the overall functionallity is almost the same.


Drum is the “main” program section that controls the main inverter/motor for the drum that pulls the wire.

Sled is a program section that manage the control of the sled that winds the wire up in a zig zag pattern. 

Misc is the third section for miscellaneous, such as battery control and control of buzzer, amber beacon, etc.


The picture below shows the drum section.

The program has several “function blocks” that each covers an underlaying program. These function blocks has some inputs at the left side and one or two outputs on the right side.

When the commandoword tells “8” or “9”, it means you have pressed the button, and want to pull up a pilot with with the low or high respectively. But before the electric motor provides full torque, serveral sequences are needed to start up smoothly, secure the wire is tightened up and to give the pilot a smooth tow.

The sequences are divided into serveral function blocks, and these function blocks are more or less connected in series. The last one sends the final references to the variable speed drive.

Main program

Decoding of input signals

A decoding of incomming inputs makes your program more simple and flexible. Then you can easily adapt to a change in the wiring, and easily share the same program with another winch with only minor corrections.

Each winch can be in one of these 6 modes:

  • Inactive
  • Wirecut
  • TotSlow
  • TotFast
  • PullLow
  • PullHigh

Inactive means that the winch are doing nothing, except keepting little resistive tension in the wire if the wire is being pull out. This is to avoid “tape jam” on the wire/drum.
The resistiv tension is typical set to 5-10 kg.

Wirecut means that the wirecut is active.

TotSlow is a function to pull in the wire with a very slow speed and typically only 10-20 kg tension.

TotFast also pulls with only 10-20 kg but with a higher speed, typically 30 km/h.
The function is very usefull when you have to pack down the winch and the wire is not pulled in.

PullLow and PullHigh are the two modes that can pull the pilots into the air. These are default set to 50kg and 85 kg respectively. Both modes starts with a sequence that slowly pulls in the wire with a little tension (like TotSlow) and ramps up the tension if the winch detects that a pilot is coupled to the wire in the other end.

Only difference between PullLow and PullHigh is the tension.

Hanggliders typically starts directly in PullHigh.
Paragliders starts in PullLow and shifts to PullHigh when they reach the treetops.

The commandoword “CMD_W” tells the actual mode by a number. The decoding of binary input signals allows an easy and flexible connection between the physical electric input to the PLC and the program.

Start sequence

In order to make failsafe control that only requires a minimum knowhow from the winch operator, it is nessersary to make a start sequence.


This start sequence has 4 states:


Start conditions OK

Start run detected.

When the no one are pushing the pull button PullSeqStatus is 0 which means inactive.

When someone are pushing the button the PullSeqStatus is 1 and the winch starts to pull with only 10 kg and 5 km/h.


When start conditions are OK (battery level, wire speed ~ 0 km/h, potentiometer at 100%) and the wire have been stretched and hold for 3 seconds, PullSeqStatus shifts to 2 and the winch increases to tension to 20 kg and removes the speed limit.


When the pilot starts to run, PullSeqStatus changes to 3, and the tension reference changes to the setpoint for PullLow or PullHigh depending which which of the commands are active.

Command box

This box gathers information from the commando word, start sequence, potentionmeter and the two tension setpoint for PullLow and PullHigh and converts it to a action in terms of a max speed and ternsion reference.


When the winch is inactive SetMotorSpeed is 0 and the TensionRef is 10 kg.

While the is towing the SetMotorSpeed is 3000 rpm (unlimited) and the TensionRef is typically 85 kg.


However, depeding in the command, potentionmotor, startsequence these values could be any where in between.

Slope limitation of the tension reference

To make the pull sequence fully automatic and to insure the pilot gets the same feeling every time he/she gets towed it is important to have a slope limiter of the tension.


Depending on the commando word, tension ref and potentiometer the ramp time differs between 3 to 10 seconds from 0 to full tension.

Typically the slope is fast at low tension force and slow when the slope reaches 100% of the setpoint.

Speed reduce

To avoid the wire is going to be pulled too much in, this box ensures to lower the speed when pilot has released and the wire approaches the winch.


The speed is gradually reduced to zero as more the wire approching the winch. At the end 10 meter wire is left out.

Variable Frequency Drive commands

This box send the final commands to the variable frequency drive.


It also controls the resistive torque when the wire is pulled out again to avoid wire jam.