DC motor with PWM control
The function of a motor is to convert electrical energy into mechanical energy. In the previous example, we have built a simple model of DC motor but only use a resistor to change its voltage level. In this example, we will use the same configuration but add an ON/OFF switch to control the voltage level of the DC motor. The ON/OFF control method here we use is PWM (Pulse width modulation) control. As time goes by, the switch turns on or off to change to voltage level from maximum to minimum (normally zero). If the duration of switch ON is long, the voltage average will be close to the maximum. We will see how it works later.
Left-click Components/Circuit/Sources/V (step 1) and release the mouse. The DC voltage source follows the cursor and right-click to change its direction (step 2). Until its anode is upward, left-click to put it on the workscreen. Currently we have not set an electric ground so that CASPOC will give a suggested message to insert an electric ground automatically. Click yes to insert the ground (step 3). Make sure there is a ground label shown in the anode of the DC source after the auto-insertion (step 4).
Left-click Components/Library/ElectricalMachine/DC/pmdc (step 1) and release the mouse. The DC motor follows the cursor and right-click to change its direction if the angular velocity output (square dot) isn’t rightward (step 2). Left-click to put the DC motor on the workscreen (step 3).
Then give a diode protection across the DC motor. Left-click Components/Circuit/Semiconductors/D (step 1) and release the mouse. The diode follows the cursor and right-click to change its direction (step 2). Until the cathode of the diode is upward, left-click on the workscreen to put it across to the DC motor (step 3). Connect all the components with the following configuration (step 4).
We keep the cathode of the DC motor for an ON/OFF switch later.
The same as the previous example, we define the minimum mechanical load for the DC motor, namely the inertia of the rotor. Left-click Components/Circuit/Rotational/INERTIA (step 1) and release the mouse. The inertia follows the cursor and right-click to change its direction (step 2). Until the inertia is upward, left-click on the workscreen to put it in the right side of the DC motor. Right-click the inertia (step 3) to change its parameter. Change the value to 100u (step 4) and click OK to save the setting (step 5).
Similarly, left-click Components/Circuit/Rotational/BEARING (step 1) and release the mouse. The bearing follows the cursor and right-click to change its direction (step 2). Left-click on the workscreen to put the bearing in the right side of the inertia. Right-click on the bearing (step 3) to change its parameter. Change the value to 10m (step 4) and click OK to save the setting (step 5).
Click the scope icon in the experience bar (step 1) to put a scope in the right side of the bearing in order to observe the simulation result (step 2). Left-click the right-bottom corner of the scope and hold down the mouse to enlarge this scope (step 3). Connect the DC motor, inertia, the bearing and the scope together with the following configuration (step 4).
Now we put a MOSFET as an ON/OFF switch and its protection. Left-click Components/Circuit/Semiconductors/D (step 1) and release the mouse. Left-click on the workscreen to put the diode below the DC motor and connect to its cathode (step 2). Similarly, Left-click Components/Circuit/Semiconductors/MOSFET (step 1) and release the mouse. Left-click on the workscreen to put the diode across the diode (step 2). Connect the MOSFET, diode and the DC motor with the following configuration (step 3).
The main goal of this example is to implement a PWM control in the ON/OFF switch, that is, to generate a PWM signal to control the MOSFET as below.
To generate a PWM signal, we can use two components. One is a triangle wave generator, the other is a comparator. The triangle wave includes rising and falling parts, that is, the output value is either high or low as time goes by. In the comparator, we will set a fixed threshold. When the output value of the triangle wave generator is higher than the threshold, the comparator sends 1; otherwise, it sends 0. We can see how it works in the following picture. If the threshold is high, the pulse width will be small. It means that the switch is often OFF and results in a smaller voltage average. In the contrary, if the threshold is low, the pulse width will be big. It means that the switch is often ON and results in a higher voltage average. Hence, we can easily raise or drop the voltage to the DC motor by changing the threshold of the comparator.
Left-click Components/Library/Source/System/TriangleWave (step 1) and release the mouse. Left-click to put the triangle wave generator on the workscreen. Right-click the triangle wave generator (step 2) to change its parameters. In the pop-window, set the parameters as below (step 3):
- Amplitude = 0.5
- DC offset = 0.5
- Frequency = 1kHz
- Phase (0-360) = 0
- d(0..1) = 0.5
Click OK to save the setting (step 4).
To understand the parameters of triangle wave generator, refer to the following picture:
Hence, according to the parameters we set, we will get a triangle wave which rises from 0 to 1 and falls from 1 to 0 every 1 millisecond. It is shown as below:
Left-click Components/Blocks/NonLinear/COMP (step 1) and release the mouse. Left-click on the workscreen to put the comparator in the right side of the triangle wave generator. Right-click the comparator (step 2) to see its parameters in a pop-window. Here we can see that if i+ > i-, then y = p1 =1, else y = p2 = 0 (step 3). Click OK to close the pop-window (step 4).
Connect the triangle wave generator, the comparator and the MOSFET with the following configuration (step 1). Extend the input of i- to the comparator and right-click on the square dot (step 2). Change its label to 0.5 in the pop-window (step 3) and click OK to save the setting (step 4).
Click the scope icon in the experience bar (step 1) to put another scope in the right side of the comparator (step 2). Make sure that the first blue input connects to the output of the comparator so that the scope will show the PWM signal.
Click the short-cut of simulation parameter (step 1). In the pop-window, select Euler for the Numerical Integration Method (step 2), Tscreen = 100m, dt = 10u (step 3) and then click OK to save the setting (step 4).
Click the short-cut of start simulation (step 1). Right-click on the first scope (step 2) to see the details of the simulation result (step 3).
Change the threshold and see how the angular velocity changes. Right-click the input label of i- and change its value to 0.9.
Click the short-cut of start simulation (step 1). Right-click on the first scope (step 2) to see the details of the simulation result (step 3). Here we can see that observably the higher threshold causes a lower voltage average and then drop the angular velocity.