Professional Documents
Culture Documents
At Res Edesign 3
At Res Edesign 3
Z. Du Toit
17042844
Declaration
I, the undersigned, hereby declare that the work contained in this report is my own work
unless otherwise stated.
Signature:
Z. Du Toit
Date:
Summary
Table of Contents
Chapter 1: Introduction................................................................................................. 7
Chapter 2: System Description........................................................................................ 8
Chapter 3: Detailed Design.......................................................................................... 10
3.1 Power Supply................................................................................................... 10
3.2 Buzzer............................................................................................................ 10
3.2.1 Calculations/Design of the buzzer....................................................................10
3.3 Buttons (Including buttons used on remote)..............................................................11
3.3.1 LPF calculations for buttons...........................................................................11
3.4 LCD.............................................................................................................. 12
3.5 IR remote transmitter and receiver.........................................................................12
3.5.1 Calculations for IR transmitter driver circuit.......................................................13
3.6 Motor driver, Motor and Gate...............................................................................13
Chapter 4: Programs.................................................................................................. 14
4.1 Program functions............................................................................................. 14
4.2 Files in the main program.................................................................................... 16
4.3 Flow diagram of main program............................................................................. 16
Chapter 5: Measurements and results..............................................................................17
Chapter 6: Conclusion................................................................................................ 18
References.............................................................................................................. 20
Volts
Vpp
Peak-to-peak voltage
Vp
Peak voltage
Amperes
ADC
HPF
LPF
Ohm
Farad
Hz
Hertz
DC
Direct Current
PCB
IR
Infrared
fc
f osc
Oscillation frequency
USB
UART
COM
Communications Port
GUI
RC
Resistor-Capacitor
FET
JFET
NPN
Negative-Positive-Negative
PNP
Positive-Negative-Positive
4
BJT
Op-amp
Operational Amplifier
Second
Meter
pico
nano
micro
millie
centi
kilo
mega
Table of Figures
Figure
Figure
Figure
Figure
Figure
Figure
1:
2:
3:
4:
5:
6:
Chapter 1: Introduction
Power Supply
Buzzer
4 Push Buttons
16 x 1 LCD
DRV8801
Motor Driver
QJT38 6 V
DC
RL78G14 MicroController
TSOP 34838 IR
receiver
Motor
Gate
FT230XS
UART
Computer
program
RL78G12,
IR remote
transmitter
Figure 1: Block diagram
describing the system as a
controller waswhole
implemented by
LCD is a 16 by 1 display that uses parallel ports on the micro-controller to send and receive
data and commands. The LCD is used to display any necessary data to the end-user.
A QJT38 6 V DC motor (includes gearbox) is completely assembled by instructions given
upon receipt. A DRV8801 motor driver is used which contains a full H-bridge that is used to
drive the QJT38 6 V DC motor.
Lastly, TSOP34838 receiver is used to receive IR commands. This component operates at 38
kHz and includes in itself a BPF and demodulator, which solves all of the problems for
receiving a signal. A Renesas RL78G12 was modified and used as a remote to send the
signals. This micro-controller is similar to the main micro-controller that controls the whole
system, with a smaller form factor and less functions.
The complete circuit diagrams can be found in Appendix.
3.2 Buzzer
The circuit for the MT12G-2P (14M4713) buzzer is shown on the following page in Figure 3.
The buzzer can be operated in a range of frequencies; however, the micro-controller was only
able to supply an audible signal at 1 kHz and 2 kHz. Only the 1 kHz buzzer tone was used,
although the two tones in tandem could be used to create an alarm sound.
If IC = 10 mA, VBE(sat) min = 0.65 V, VCE(sat) = 0.2 V with hFE(min) = 100 and hFE(max) = 300:
R2
(51.50.2)
= 330 and R3 =
10 m
(50.65)
=
0.1 m
43.5 k
11
The average time a bounce in a press lasting 200 ms to 800 ms is around 1 ms to 5 ms. So
given that the frequency of the bounce is approximately 100 to 200 Hz, and RC network,
using a resistor = 330 k and a capacitor = 0.01F suffices to de-bounce the signal.
3.4 LCD
As explained before, the LCD was integrated into the system simply as a visual aid to the
end-user. However, it may be worth noting that the LCD contrast can be set by varying R2
(As in schematic) between 600 and 1 k. The higher the resistance, the lighter the contrast
and vice versa.
Following this, using a TSAL6200 IR emitting diode and a BS170 transistor was used. Figure
5 shows the complete driver circuit for the transmitter. As shown in Figure 5, R1 is a pull
down resistor and was simply chosen as 10 k.
12
The circuit for the receiver was given in the data sheet for the TSOP 34838 and therefore
required no calculations.
R2 = 42.5 ,
But 100 was chosen instead due to availability.
13
14
Chapter 4: Programs
This chapter describes the C-code that the micro-controller runs to implement the gate
controller. A brief description of the functions used, is given, as well as a structured layout
showing all the files in the final project. The code was written in the Renesas Electronics E2
Studios Environment. Calculations used in the program are included. A flow diagram
detailing the flow of the main project file is also given.
int whatIsIt(void);
This function further analyses the array that is stored by the function decodeRemote.
It accesses the command within the received data and returns and integer to clarify
one of 3 commands sent from the remote.
void remoteFoo(void);
This function simply reads the states in to determine when the gate is opening or
closing and displays this information onto the LCD.
void writeByteLcd(uint8_t reg, uint8_t value);
This function takes in a command or instruction and sends it to the LCD
void initLcd(void);
This function initialises the LCD.
void writeString(char *word,char length);
This functions uses writeByteLcd to write long strings to the LCD. This function
takes in a char pointer with its length and uses this information to write ASCII
characters onto the LCD.
void scroll(char lengthofa);
This function takes in a length (generally larger than 16, so that all the characters on
the LCD is displayed) and scrolls the shifts the addresses on the display from right to
left on the LCD.
void R_TAU0_Channel3_ChangeDuty_for_Servo(uint8_t servo_ratio);
This function safely changes the duty cycle of the PWM to any percentage it is called
with. This function saves time from having to use a peripheral code generator to
change the duty cycle of the PWM.
void r_intc1_interrupt(void) and void r_intc2_interrupt(void);
These functions are used to detect a logical low from two micro-switches to indicate
whether the gate has completely opened or closed. Both of these functions are
interrupts and it uses the R_TAU0_Channel3_ChangeDuty_for_Servo function to stop
the motor safely.
16
17
Table 1: Shows different currents and voltages during different commands for the main
system, including the remote
3.3 V
18
Chapter 6: Conclusion
Overall, most of the major specifications of the gate controller were met. The gate controller
accepted wireless remote commands to open and close, the gate could be operated manually
with buttons on the PCB, and finally the gate can be controlled via a program on a computer.
A small problem occurs when users attempt to read the current from the motor, the system
slows down or even restarts. This is due to a function in the program called sprintf, which
uses to too much memory and computing power when called. A possible solution to this is to
manually calculate the result of the current within the code and send the value to the
computer using a much more memory and computation efficient method. However, this was
not thoroughly explored and it is recommended that users following this report find a better
implementation to read the current from the motor. A data log could also easily have been
implemented into the system but this was not done in this report.
In summary, the system functions well without any problems and meets all the major
specifications, although it has not met all the minor design specifications. However, the
minor specifications such as being able to read motor current were not physical problems
with the circuit, but a programming error. This however leaves room for improvement in the
coding used for this system.
Below in Figures a, b, and c are the, motor, main PCB and remote, respectively:
19
References
Renesas Electronics, 2015, RL78/G14 Micro-controllers Hardware Manual
20
21