Elec 3204
Elec 3204
Elec 3204
1. Project Objective
The goal of this design project was to practically apply knowledge gained from lectures and
tutorials to design and build a DC drive system using a Picaxe microcontroller [1]. An H-bridge PCB
was provided to laboratory groups along with two 12 V 0.5 A DC motors [2]. The workload of this
project was broken down equally among group members, with each member leading a certain aspect
of the design. Leah managed hardware design, Tariq handled hardware assembly, and CJ handled
software design. Team members generally worked in parallel with one another to optimize
prototyping, while testing of the washing machine was completed together.
When the washing machine is switched on, the motor begins to rotate based on cycle setting
specified by the rotary switch. This, in turn, rotates a gear train and spins the cup. The washing
machine can be turned off at any time by the ON/OFF switch. When the load is varied, the washing
2
machine is able to maintain a constant speed using a negative feedback network. The shaft of the
control motor, which is connected to the gear train, is coupled with a second motor that acts as a
generator. When the control motor shaft rotates, a proportional voltage is produced by the sensing
motor. This voltage is then fed back to the Picaxe microcontroller, which reads the voltage level and
alters the output power to the control motor accordingly to maintain the current rotating speed.
3. Operational Requirements
There were two types of conditions under which the washing machine had to function, open
loop and closed loop. Open loop means that control signal is unaffected by the following outcome and
is held being at constant value. On the other hand, in the closed loop condition, there is an
introduction of error signal (e(t) = y(t) - r(t)) which is created by feeding the output of system into the
controller. The difference between them, e(t), is used to be amplified to the extent that it will control
the output to its desired value [1]. It was required that the washing machine machine mimic actual
washing, cleaning, and spinning cycles with varying motor speeds. Furthermore, the project
assignment stated that the motor should be able to rotate in either direction with different speeds,
which could be performed in the open loop condition. One closed loop, negative feedback condition
was required, in which the motor was to spin at the same speed despite variations in the washing
machine load [1]. This would simulate adding more clothes or water to the washing machine bucket.
Finally, students were encouraged to include further peripherals to their designs such as switches or
push buttons. For this washing machine implementation, an ON/OFF switch was added, along with a
rotary switch for choosing the desired cycle type. The rotary switch allows users to choose between
six different cycles, all of which are detailed in Figure 2 below.
Figure 2. Table of washing machine scenarios and the corresponding cycle types.
Switch Number Cycle Direction Duty Cycle Loop
4. Hardware Design
The hardware design for this implementation of a washing machine went through two
iterations, both beginning with the block diagram shown below in Figure 3. The input to the washing
machine input was chosen to be a switch on. The Picaxe microcontroller would then output a specified
PWM signal to the four quadrant power converter used to for motor control. In this case, this power
converter was the provided H-bridge. The H-bridge was powered by 12 V, whereas the Picaxe
microcontroller was powered by 5 V. The PWM from the Picaxe turned on a diagonal pair of
transistors in the H-bridge, the voltage output of which was connected to the control motor. A rubber
3
collar linked the shaft of the control motor to that of the sensing motor. Therefore, when the control
motor rotated, it turned the shaft of the sensing motor. The sensing motor then generated a voltage
which was fed back to the Picaxe. This created a system of negative feedback, where the voltage from
the sensing motor was read by the Picaxe and used to control the speed of the control motor. The shaft
of the control motor was also connected to a gear box. There was one small gear around the shaft of
the control motor, which was meshed with a larger gear used to turn the post on which the plastic cup,
emulating the washing machine bucket, was glued. The vertically aligned motors, as well as the
gearbox can be seen in Figure 5. This plastic cup could be filled or emptied as desired to alter the load
on the device. Furthermore, as can be seen in Figure 1, a rotary switch was also placed on the front of
the washing machine to enable users to select their speed and direction setting. To make the final
build of the washing machine more presentable and cleaner looking, the wire connections for the
switches, printed circuit board, and Picaxe were all neatly contained in a black box. This can also be
seen in Figure 1.
The initial design of the washing machine was slightly different than the final build of the
device. First, rather than switches, the input to the machine was chosen to be button presses. There
was to be one button for turning ON/OFF and another for selecting the cycle type. For example, two
consecutive presses of the cycle button would choose the cleaning option with a duty cycle of 90/10.
To avoid having to implement software debouncing for these buttons, switches were used in the final
implementation. Additionally, a gear belt was originally chosen to be used to turn the plastic cup.
However, the possibility of the belt slipping increased the chance of failure for the device, so a
gearbox was used despite being more costly. A pressure sensor was removed from the washing
machine design because the load which the plastic cup could hold was too light to be meaningfully
measured. Finally, the printed circuit board containing the H-bridge was not mounted to the side of
the washing machine to make it easier to isolate different parts of the machine for testing and
debugging. The initial design for the washing machine is illustrated below in Figure 4.
4
Figure 5. Feedback system and gear box for washing machine. Plastic cup was glued to red paddle
seen on top right, next to control motor.
5
The Picaxe was connected to the printed circuit board by the IN1 and IN2 terminals, both of
which supply a PWM output. The 5 V and GND terminals of the Picaxe were also connected to the
printed circuit board. The rotary switch is connected to the Picaxe by terminals OUT1 to OUT5 for
the open loop cycle options and to IN0 and ground for the closed loop condition. The IN0 and ground
connections must only be connected when feedback is required for the washing machine to function
properly. All of these connections can be seen in Figure 6. Furthermore, the LEDs that are present on
the Picaxe and the H-bridge indicate that the boards are properly powered. The H-bridge board also
has four banana plug connectors. As shown in Figure 6, the top two banana plugs are Vin = 12 V and
ground, used for powering the board. The bottom two banana plugs are Vout and ground, used to
power the control motor.
The final design for the washing machine, including a description of the rotary switch and the
corresponding cycles on each of its six switches is illustrated in Figure 7. This final design meets all
design requirements, specifically motor speed control under open loop conditions, the ability to rotate
both clockwise and anticlockwise, as well as constant speed control when varying loads under a
closed loop condition. The closed loop condition is the only one which utilizes feedback.
5. Software Design
The code structure
Code structure for this project is fairly simple, it contains two loops: main and closed loop. As the
project does not require overly sophisticated system, it was sufficient enough to use few if statements
on the main loop to change speeds. Main loop identifies the options(input) and implements the
open-loop output to the system while if the closed loop operation is chosen, the main loop jumps to
closed loop subroutine. Closed loop system will send the target speed to the system and read the
actual speed on the feedback motor. By comparing the value of feedback to the target speed, the
program will adjust the speed by the smallest amount possible (=1) for its smooth feedback transition
to reach the target speed rather than having a huge gain and overshooting due to that gain. The ADC
value from the feedback motor had to be checked by multimeter in order to compare with our
calculated value of ADC. From testing and gaining those values, we could set the right ADC value
that fits in the acceptable range and can be safely used in closed loop operation.
7
Please note that, while operating any modes, the machine can be shut down by its emergency
ON/OFF switch.
7. References
[1] ‘Project Note for ELEC3204/3904 - Power Electronics and Applications’ 20 May 2018
https://canvas.sydney.edu.au/courses/2530/pages/project-instruction-and-report-requirement?module_
item_id=125437
[2] ‘Motor Datasheet’ 20 May 2018
https://canvas.sydney.edu.au/courses/2530/pages/project-instruction-and-report-requirement?module_
item_id=125437
[3] ‘Introduction of Picaxe 14M2’ 10 April 2018
https://canvas.sydney.edu.au/courses/2530/pages/project-instruction-and-report-requirement?module_
item_id=125437
9
8. Appendix 1 - Code
;; Program : Washing Machine
;; Progamed by : GROUP W6
;; Date : 23/05/18
;; Purpose: Mimic the motion of washing machine
;; both in open loop and closed loop systems
;; Comment : pause might be needed between switching modes.
;;
setfreq M32
;;let dirsC = %11100110 ;; Port C pin 0,3,4 to inputs
;ymbol subroutine_closed_loop
main:
; hpwm 1,0,0,79,b4
; wash 80/20
IF wash = 1 AND clean = 0 AND spin = 0 AND opp_clean = 0 AND closed_loop =0 AND
opp_spin = 0 THEN
hpwm 1,0,0,79,256
b4= 256
goto main
; clean 90/10
ELSE IF wash = 0 AND clean = 1 AND spin = 0 AND opp_clean = 0 AND closed_loop= 0
AND opp_spin = 0 THEN
hpwm 1,0,0,79,288
b4= 288
goto main
10
; spin 100/0
ELSE IF wash = 0 AND clean = 0 AND spin = 1 AND opp_clean = 0 AND closed_loop= 0
AND opp_spin = 0 THEN
hpwm 1,0,0,79,320
b4= 320
goto main
; opp_spin 0/100
ELSE IF wash = 0 AND clean = 0 AND spin = 0 AND opp_clean = 0 AND closed_loop= 0
AND opp_spin = 1 THEN
hpwm 1,0,0,79,0
b4= 0
goto main
goto subroutine_closed_loop
ENDIF
goto main
subroutine_closed_loop:
;; wrong subroutine endpoint
11
hpwm 1,0,0,79, b0
readadc C.0, b1
debug
;; 60% DC
goto main