0:05
Good morning everybody. Thank you for joining us on this webinar on PWM inputs and outputs.
0:12
We’ll just go through the usual routine.
0:14
If you have any questions anybody just put them in and we can get to them at the end. Hello and welcome to today’s webinar.
0:20
In this webinar we are going to be looking at PWM inputs and outputs with Horner controllers.
0:26
We will start by covering what is PWM and what it is used for.
0:31
Then, which Horner controllers support PWM, followed by creating PWM outputs in a Horner controller, and reading PWM inputs into a Horner controller.
0:43
At the end, we will have plenty of demonstrations and we will finish with a Q &A session.
0:49
Let’s begin by discussing what is PWM. PWM stands for Pulse Width Modulation.
0:56
It is a digital technique for achieving analog-like control with a pulse train signal.
1:03
With a PWM pulse train signal, your signal amplitude is kept at a constant.
1:09
For most PLCs like Horner, the standard would be 24 volts.
1:15
Your signal frequency is also kept constant, for example at 1000 Hz.
1:21
However, the signal on time varies over this period.
1:27
In the diagram on the right, we can see an example of a pulse train with a signal on time of 50%.
1:37
On time, as a percentage of total period, is known as the duty cycle.
1:44
Effectively, the duty cycle value, which can be anything from between 0 and 100, is being communicated over the PWM signal.
1:54
Now let’s look at some use cases for PWM.
1:58
PWM can be used for controlling the amount of power delivered to a heating element, for positioning a PWM controlled valve, for controlling the speed of a DC motor, for interfacing with variable frequency drives as an alternative to an analog speed reference, and much more.
2:19
However, PLC PWM outputs are low voltage, low power signals that usually cannot drive a device directly. Which Horner controllers support PWM signals?
2:34
All Horner controllers with high speed outputs support PWM outputs.
2:40
All Horner controllers with high-speed counters support PWM inputs.
2:45
PWM outputs are much more common in various applications in machine control.
2:51
But still, we will demonstrate both.
2:54
We will start by configuring a PWM output in a Horner controller.
2:59
First, in hardware configuration, select PWM for one or more of the high-speed outputs.
3:08
If desired, you can set a default duty cycle and frequency, or hold last state during idle in this menu.
3:17
Next, we’re going to map the duty cycle and frequency variables to the appropriate AQ registers from the high-speed IO table.
3:26
Then, in your program, simply set the frequency to a constant value of your choosing, and vary the duty cycle as required to control the actuator.
3:38
Now let’s take a look at the high-speed I.O. table.
3:43
The specific I.O.
3:44
table will vary by controller, however, for any Canvas or Prime controller you will be using this table.
3:52
Here, you can see that the duty cycle for the first PWM is mapped to the register AQ421, and the frequency for the first PWM is mapped to AQ423, and they are both unsigned double integers.
4:14
With these values, we can now complete the formula below.
4:18
First, for duty cycle, you need to set the value so that when you divide it by 32 ,000 and multiply it by 100, you will end up with the duty cycle percentage that you are looking for.
4:31
Next, it is much simpler when it comes to setting your frequency.
4:35
You can simply set the value of AQ423 to your desired frequency.
4:42
Remember, if you were not using a canvas or prime controller, the high-speed I-O table will look different, however, the formulas will stay the same.
4:53
This is the high-speed I-O table for the Micro OCS.
4:59
As you can see, the registers change, but the formulas remain constant.
5:03
And that is everything you need to know to configure a PWM output in a Horner controller.
5:11
Next, let’s look at how we configure a Horner controller to measure PWM inputs.
5:18
First, in Hardware Configuration, select type Pulse Width Measurement for one of the counters.
5:25
It does not matter whether it’s 2 counter mode or 4 counter mode, that just depends on your specific controller.
5:34
Now, set with height 1 microsecond count and select the appropriate external input.
5:42
Then, we are going to map a variable to the accumulator from the high speed I.O. table for your device.
5:50
After this, we are going to do a small calculation.
5:53
In your program, perform the maths to convert one microsecond count in the accumulator into the duty cycle percentage that you desire.
6:04
The formula for this will be shown in the next slide.
6:07
Now let’s take a look at the high-speed I-O table in Canvas and Prime.
6:13
Here we can see our double integer values for potentially our four PWM inputs.
6:20
Below this table are the formulas we will use to calculate the duty cycle.
6:27
First we must find our frequency divider.
6:31
This term refers to the known frequency of the incoming PWM signal.
6:37
Whenever you receive a PWM signal you have to be told what frequency it is coming in at.
6:44
This value can be anything from 100 Hz, all the way up to 10 ,000 Hz or more.
6:53
We then divide this value by 10 ,000, and this gives us the frequency divider.
7:00
Just as before, we also have a high-speed I-O table for the micro series.
7:07
And we can see that the registers change, but the formulas remain constant.
7:12
And that’s everything you need to know to configure a PWM input in a Horner controller.
7:19
Now we are going to get into the demonstrations portion of our webinar.
7:24
We are going to show you how to configure and do a little bit of programming for PWM inputs and outputs.
7:32
And we are going to use a canvas controller for our demonstration.
7:37
First, we will demonstrate how to configure PWM outputs.
7:42
We will begin in Cscape.
7:45
Start by navigating to Hardware Configuration at the top of the Cscape window.
7:50
For this demonstration, we are working with a canvas model.
7:54
Click on the Local IO tab at the top of this window, and then click on the Config button next to the IO.
8:01
In this menu, click on the module setup tab at the top and for PWM outputs we are going to click on digital out forward slash PWM.
8:14
In this demonstration, we are just using one PWM output and that is physically wired to Q1.
8:23
We have also chosen not to set any defaults for the PWM signal.
8:28
So we are going to let the frequency and duty cycle defaults just be 0.
8:35
Which means if the controller is in stop or idle mode it is not going to be putting out a signal at all.
8:43
Next we need to map a variable to duty cycle and frequency.
8:47
Navigate to program variables in the top left hand side of the window.
8:53
This will open a list of variables at the bottom of the window.
8:56
In this list, click on retain variables.
9:00
For this demonstration we have already set our duty cycle and frequency variables to the corresponding registers that we found on the high-speed I.O. table for this device.
9:13
Next we need to do a bit of logic.
9:17
Navigate to PWM underscore out file which will be under Control, Logic Modules, Main Loop Modules, in the menu on the left hand side.
9:30
So for instance we are going to be transmitting a duty cycle value over PWM which is from 0 to 100%.
9:38
Here we have got a double integer value which we connect to this equation, which divides by 32 ,000 and multiplies by 100, as shown earlier, to get a duty cycle percentage.
9:54
Here we have created a screen for PWM out for the demonstration purposes, which we’ll be able to manually plug in this value here and calculate what the resulting duty cycle is.
10:07
Then we can set the frequency at a fixed rate.
10:11
So, whether it’s 500, 1000, or even 10 ,000 Hz, we can set the constant value.
10:21
And then, our canvas controller is going to output a PWM signal on its output.
10:29
At the bottom, we have created a slider that we can use to set our PWM output from minimum to maximum, from 0 to 100.
10:39
This will demonstrate the changes in duty cycle output.
10:43
And that is all we need to do on our PC.
10:46
For the next part, we will be moving to the bench.
10:49
Here is the bench.
10:51
And here is the Canvas 7 that we just set up in Cscape.
10:57
Over here, we have also got an XL4′ that we have configured to read in the PWM signal.
11:05
We will talk about the programming for reading in PWM signals after this, but first let’s start by focusing on the Canvas 7.
11:17
So we have started off with a fixed frequency of 1000 Hz, but we could set that to whatever we want, and this frequency is being directly fed to AQ423.
11:31
And then by varying the value in AQ421, we end up with a duty cycle.
11:39
In this example, we can see the duty cycle is set to 16 ,000 divided by 32 ,000.
11:46
So we should end up with a duty cycle that is 50%.
11:51
And we can confirm that over here.
11:54
As we can see, we have a duty cycle value of 50%.
11:58
To test this further, using the slider we can change the duty cycle formula, and we observe the duty cycle percentage changing in response.
12:10
We have successfully configured our Canvas 7 for PWM outputs.
12:15
Next we are going to show you how we configured this Excel 4 prime for PWM inputs.
12:22
Once again we will start in Cscape.
12:25
Begin by navigating to Hardware Configuration at the top of the Cscape window.
12:30
In this demonstration, you can see we are working with the XL4 Prime.
12:35
Click on the Local IO tab at the top of the window and then click on the Config button next to the IO.
12:42
In this menu, click on the Module Setup tab at the top and this time for PWM inputs, we are going to click on DigitalIN forward slash HSC.
12:55
Regardless of whether you are in two-counter or four-counter mode, the process will be the same.
13:03
We will go down here to our counters, and for one of the counters that we want to use for measuring pulse width, we select from our pull-down list Pulse Width Measurement.
13:16
Now, we want to make sure that Width Height is what you are measuring.
13:20
This is important because Judy Cycle is the amount on time divided by total period.
13:28
So we need to know the time that the pulse is high. Next we are going to pick which input we have physically connected it to.
13:37
In this case it’s the first high-speed input.
13:41
The disable and the latch functions are available for pulse width measurement.
13:47
However in most cases you leave them as disabled. With this complete we will once again look at the logic.
13:57
Navigate to the PWM underscore in file which will be under control, logic modules, main loop modules, in the menu on the left hand side.
14:08
Here we are looking at our PWM routine and this is where we will do our calculation of the frequency divider.
14:15
We are going to be taking the value of 10 ,000 which is just a constant, and we are going to be dividing it by the frequency of which the PWM signal is writing. This will give us our frequency divider.
14:30
Then, for our duty cycle percentage, it is a matter of taking the number of pulses that are coming in through the high speed counter and dividing them by the frequency divider we just calculated.
14:43
This gives us our duty cycle Finally, we will look at mapping the PWM counts, or the pulse width counts, in one microsecond increments.
14:55
This is done in our program variable table.
14:59
In our demonstration, we have created it in our global variables table at the bottom of the window.
15:06
As we can see, we have the internal variable mapped to the appropriate number of the high IOTable, which for our demonstration is AI-401.
15:20
And that is everything we need to do to measure PWM inputs.
15:25
Now, from the standpoint of screen development, we have developed an example of a screen for monitoring PWM inputs.
15:34
We have a field for inputting the known frequency of the signal, And then, based on that and the number of counts it is getting back from our high-speed counter accumulator, it will accurately display the duty cycle of the incoming signal.
15:52
Despite not being a common application, we have just demonstrated how you can monitor a PWM signal on a Horner controller of virtually any kind.
16:02
And that concludes our webinar for today.
16:06
Thank you so much for listening and the Q &A session will begin shortly.
16:15
Okay, hope those have benefited you all now.
16:18
We will be back on next week again with a webinar comparing our new canvas graphics against the traditional graphics of our other units.
16:29
Don’t see any questions in on this one so I think we can leave it there for today.
16:35
Thank you all very much and we’ll see you next time.







