HT45F6530 AVR – AC Voltage Regulator …HT45F6530 AVR – AC Voltage Regulator Application Note...
Transcript of HT45F6530 AVR – AC Voltage Regulator …HT45F6530 AVR – AC Voltage Regulator Application Note...
HT45F6530 AVR – AC Voltage Regulator Application Note
AN0498E 1 / 10 October 8, 2018
HT45F6530 AVR – AC Voltage Regulator Application Note
D/N:AN0498E
Introduction AC Voltage Regulators, or AVRs for short, are required in some countries where and
regions where the voltage supply is not stable. Instable electrical supplies can cause the
failure or shorten the life of electrical appliances. Installing an AVR can provide a stable
supply voltage for more sensitive appliances. The HT45F6530 is a dedicated MCU
developed by Holtek for relay-type AVRs. This application note will introduce the working
principles of AC voltage regulators and explain the various functional control processes to
offer users a deeper understanding of how to use this dedicated Holtek AVR MCU.
Functional Description
AVR AC Voltage Regulator Functional Description
By using different transformers, a wide range of voltage inputs and fixed voltage output
voltage can be achieved. This application note will use an input voltage of AC110V ~
230V/50Hz and an output voltage of AC230V ±6%/Hz relay type AVR scheme.
At the AVR core is a multi-tap self-coupled transformer and control board. Multi-tap
transformers can make the input voltage experience a multi-stage increase/decrease
conversion. The control board measures the input voltage and controls the relay switching
according to the input voltage level, so that the output voltage remains close to AC230V.
This Holtek AVR device solution can measure the relay's pull-in and release delay time,
detect the relay switching zero-point, reduce relay switch arcing thus increasing the relay
service life. The AVR has other functions such as input/output voltage display, indicators,
undervoltage/overvoltage/overtemperature/overload protection as well as power-on output
delay control.
HT45F6530 AVR – AC Voltage Regulator Application Note
AN0498E 2 / 10 October 8, 2018
Hardware Block Diagram
AVR- AC Voltage Regulator Hardware Block Diagram
1. After power is applied, the multi-tap self-coupled transformer is used to implement an
increase or decrease conversion to provide a multi-stage voltage for the output. The
transformer also provides a 12V AC supply for the control board power.
2. The 12V AC supply provides 12V DC and 5V DC for the relay and MCU after
rectification and step-down.
3. The AC input terminal and the AC output terminals pass through resistor circuits and
which together with an internal OCP circuit, are converted into a 2.5V center sine wave
for the internal voltage, period, zero point, relay delay and other measurements.
4. Control the relay switching according to the input voltage, so that the output remains
close to AC230V.
5. Use an NTC to measure the transformer temperature for protection.
6. Use touch switches or regular switches for switching.
7. Display input voltage, output voltage and indicator light through LED Driver.
HT45F6530 AVR – AC Voltage Regulator Application Note
AN0498E 3 / 10 October 8, 2018
Circuit Diagram
AVR- AC Voltage Regulator Circuit Diagram
No. AC Input Voltage
Operating Relay
Transformer Input Pin
Transformer Output Pin
AC Output Voltage
Error @AC230V
1 110~123V RL5 122 240 216~241V -6%~+5% 2 124~138V RL2, RL5 122 215 218~243V -6%~+6% 3 139~155V ─ 153 240 218~243V -5%~+6% 4 156~173V RL2 153 215 219~243V -5%~+6% 5 174~195V RL4 192 240 216~242V -6%~+5% 6 196~217V RL2, RL4 192 215 218~241V -6%~+5% 7 218~242V RL2, RL3 Bypass Bypass 218~242V -6%~+5% 8 243~270V RL3 240 215 217~241V -6%~+5%
AVR- AC Voltage Regulator Input/Output Conversion
MCU Operating Environment VDD=5V
Oscillators:8MHz
Software Used Peripheral Description ROM:4K×16 (uses 1147×16 Percentage:56%)
RAM:128×8 ( uses 50×8 Percentage:39%)
ADC:uses high 8-bits, used for input voltage, output voltage and temperature
measurement
HT45F6530 AVR – AC Voltage Regulator Application Note
AN0498E 4 / 10 October 8, 2018
DAC0:Output 2.5V reference voltage for OPA conversion and zero detection
DAC1:Output reference for relay delay detection
OPA0:Used for input voltage conversion
OPA1:Used for output voltage conversion
CMP0:Used for zero detection
CMP1:Used for relay delay detection
Timer:Uses CTM0 as a Timer Counter measurement, depending upon the function
set as 0.1ms and 0.25ms interrupt
The following shows how the Timer is used:
0.1ms interrupt is used to measure the input voltage cycle time and relay delay time
0.25ms interrupt is used to sample the ADC input voltage and to obtain the input
voltage peak-to-peak value
Software Flow Description
Start
Initialisation
4 AC_IN periods
AC_IN period measurement
Relay delay time measurement
AC_IN voltage measurement
AC_IN period
AC_IN voltage measurement
AC_OUT voltage measurement
Relay condition setup
Temperature measurement
Display and key status
Y
N
Y
N
AVR Main Program Flow Diagram
HT45F6530 AVR – AC Voltage Regulator Application Note
AN0498E 5 / 10 October 8, 2018
1. Initialisation: System settings, pin initialisation, OCP correction, RAM clear.
2. Use OCVP to count 4 AC_IN zero crossing interrupts and wait for the system to
stabilise.
3. At the next AC_IN zero point interrupt, set the CTM0 0.1ms interrupt once, count
AC_IN one cycle time.
4. Switch RL1 at the next zero point and set CTM0 0.1ms to interrupt once. Determine
the time when _CMP1O changes from 0 to 1, which is the RELAY pull-in delay time.
Release the RELAY at the next zero point when judge _CMP1O changes from 0 to 1
and then change from 1 to 0, which is the delay time for the relay to release.
5. Use the ADC to measure AC_IN once every 0.25ms, measure the peak-to-peak
value in one cycle, and evaluate the voltage level.
6. Wait for 10 AC_IN zero crossings to be interrupted.
7. Use the ADC to measure AC_IN once every 0.25ms, measure the peak-to-peak
value in one cycle, and evaluate the voltage level.
8. Use AC to measure AC_OUT once every 0.25ms, measure the peak-to-peak value
in one cycle, and evaluate the voltage level.
9. Set the relay status and wait for the timer zero output. There are 10 relay status
conditions (including overvoltage and undervoltage) with 9 levels. In order to avoid
continuous relay switching at the critical point, each gear will have ±1 ADC and 3 AC
cycle buffering.
10. Temperature measurement
11. Screen display
12. Return to the 6th loop
HT45F6530 AVR – AC Voltage Regulator Application Note
AN0498E 6 / 10 October 8, 2018
OCP_ISR
General Mode
AC_IN period reset
AC_IN voltage measurement
AC_OUT period measurement
AC_OUT voltage measurement
Relay delay time measurement
AC_IN zero crossing count +1
Return
• CTM0 setup as 0.1ms and restart• CTM0 timer clear
• Renew AC_IN voltage• CTM0 setup as 0.1ms and restart• Set next mode = General Mode
AC_IN period measurement
AC_IN voltage reset
AC_OUT period reset
AC_OUT voltage reset
• AC_IN voltage reset• CTM0 setup as 0.25ms and restart• Set next mode = AC_IN voltage
measurement mode
• Renew AC_IN period• CTM0 setup as 0.1ms and restart• Set next mode = General Mode
• AC_IN period reset• CTM0 timer clear• Set next mode = AC_IN period
measurement mode
• Renew AC_OUT voltage• CTM0 setup as 0.1ms and restart• Set next mode = General Mode
• AC_OUT voltage reset• CTM0 setup as 0.25ms and restart• Set next mode = AC_OUT voltage
measurement mode
• Renew AC_OUT period• CTM0 setup as 0.1ms and restart• Set next mode = General Mode
• AC_OUT period reset• CTM0 timer clear• Set next mode = AC_IN period
measurement mode
• RL1 ONDAC1=2.524V(814H)
• CTM0=0.1ms and restart• Step counter +1
Step counter
• CTM0=0.1ms• Set next mode = General
Mode
0 or 4
8
Rising edge triggerY
N
Y
Y
Y
Y
Y
Y
Y
Y
Y
Y
N
N
N
N
N
N
N
N
N
N
AVR Software OCP Interrupt Program Flow
OCP_ISR is the AC_IN zero point interrupt program. The program is only executed when
the rising edge is triggered. It is divided into three modes:
Relay delay measurement: the time from the MCU drive signal to the actual relay
pull-in/release.
Voltage/cycle measurement: divided into 4 measurement types, which will be reset
before each measurement.
Measure the maximum/minimum value of AC_IN, execute every 0.25ms and
measure the peak-to-peak value of one cycle.
HT45F6530 AVR – AC Voltage Regulator Application Note
AN0498E 7 / 10 October 8, 2018
Measure the period of AC_IN, count every 0.1ms and count the time of one cycle.
Measure the maximum/minimum value of AC_OUT, execute every 0.25ms and
measure the peak-to-peak value of one cycle.
Measure the period of AC_OUT, count every 0.1ms and count the time of one
cycle.
General mode: Clear CTM0 count value and reset CTM0 to ensure there is no
cumulative error.
CTM0_ISR
AC_IN voltage measurement
General Mode
CTM0 timer value +1
Return
RL1 OFF and CTM0 timer value clearDAC1 set as 2.578V
Relay delay measurement
CTM0 timer value is RL1 ON delay timeStep counter +1
ADC measure AC_IN voltageStore smallest and largest values
ADC measure AC_OUT voltageStore smallest and largest values
YAC_OUT voltage
measurement
Step counter +1Corresponding RLY ON
Corresponding RLY OFF
RLY ON Delay
RLY OFF Delay
Step counter
CTM0 timer value is RL1 OFF delay timeStep counter +1
CMP1=1
CTM0 greaterthan 7/8 period
CMP1=1 & RL1 OFF
CMP1=0
N
Y
Y
Y Y
Y
Y
Y
Y
Y
N
N
NN
N
N
N
N
N
1 or 5
2 or 6
3 or7
AVR Software CTM0 Interrupt Subroutine Flow Chart
1. CTM0 is the only timer used by the system. It is set to execute the 0.25ms and 0.1ms
interrupt depending on the function.
0.1ms interval is used to measure AC_IN/OUT AC power cycle and relay ON/OFF
delay timing
0.25ms interval is used for AC_IN/OUT voltage measurement
(tADCK=1μs, the ADC is converted six times per measurement, discard the first and
last ones, the remaining 4 times average, which takes 0.16ms)
2. Voltage measurement: Each time the interrupt is used to measure the voltage of the
corresponding port and to save the maximum and minimum values.
3. Relay delay measurement: According to different step counter values, determine the
state of CMP1 to measure the delay time of RLY ON/OFF.
4. General mode: Counting starts from each zero point. When the counting time is equal
to the delay time of the AC power cycle minus RLY ON, the RLY state is determined
and then set to ON. When the count time is equal to the delay time of the AC power
cycle minus RLY OFF, the RLY state is determined and then set to OFF.
HT45F6530 AVR – AC Voltage Regulator Application Note
AN0498E 8 / 10 October 8, 2018
Relay Delay Detection Timing Diagram
OPA1O
RL1
CMP1ORLY ON
Delay TimeRLY OFF
Delay Time
7/8 AC Period 7/8 AC Period
RLY ON Delay Time
RLY OFF Delay Time
OPA0O
OCP0 IRQ &Rising Edge
OCP0 IRQ &Rising Edge
OCP0 IRQ &Rising Edge
OCP0 IRQ &Rising Edge
11 22 33 55 11 22 33 5544 44
AVR Relay Delay Detection Timing Diagram
1. After entering the relay delay measurement mode, at the first OCP rising edge
interrupt, RELAY ON, reset CTM0 and set to the 0.1ms interrupt. The CMP1 trigger
level is set to 2.524V.
2. When RLY is actually turned ON, the OPA1 potential rises above 2.524V and CMP1O
outputs a “1”. The RLY ON time is saved in the CTM0 interrupt. CTM0 continues to
count.
3. When the CTM0 count is greater than 7/8 of the AC cycle, RLY OFF, reset CTM0 and
return to zero. The CMP1 trigger level is set to 2.588V waiting for CMP1O=1.
4. Continue counting and wait for CMP1O=0.
5. After RLY is actually turned OFF, the OPA1 potential drops below 2.578V and
CMP1O outputs a “0”, and the RLY OFF time is saved in the CTM0 interrupt, after
which the measurement ends. Next time when the OCP rising edge interrupt occurs,
execute from step 1 again.
* The first time power is applied, due to different loads the waveform response will be
slow therefore the first measurement data cannot be used.
Voltage Measurement Timing Diagram ADC
128
255
0 TIME
MAX
MIN
20ms
0.25ms
AVR Voltage Measurement Timing Diagram
HT45F6530 AVR – AC Voltage Regulator Application Note
AN0498E 9 / 10 October 8, 2018
1. When measuring the AC IN/OUT voltage, CTM0 is set to be interrupted every 0.25ms.
2. Perform ADC measurements and update MAX and MIN for each interrupt. Taking 50
Hz as an example, 80 voltage measurements are performed within a 20 ms cycle.
3. After the measurement is completed, subtract MIN from MAX to get the AC IN/OUT
peak-to-peak voltage value.
(tADCK=1μs, the ADC is converted six times per measurement, discard the first and last
ones, the remaining 4 times average, which takes 0.16ms)
Relay Control Timing Diagram
RLY ON Delay Time
RLY OFF Delay Time
Zero cross & CTM0 Counter=0
Zero cross & CTM0 Counter=0
AC POWER Period
CTM0 Counter=Period ct–OFF Delay ct CTM0 Counter=Period ct–OFF Delay ct
RL1~N OFF ->ON
RL1~N ON ->OFF
OPA0
AVR Relay Control Timing Diagram
1. At each AC zero crossing the rising edge on CTM0 will return to zero.
2. When the CTM0 count is equal to the AC cycle minus the value of RLY ON, determine
whether relay 1~N should be set to 1.
3. When the CTM0 count is equal to the AC cycle minus the value of RLY OFF,
determine whether relay 1~N should be set to 0.
Software Example
HT45F6530_Demo_V1_20180627.zip
Conclusion
This application note has described how to use the HT45F6530 to develop an AVR. It has
explained the AVR input and output voltage measurements and the operating principles
behind the relay delay time measurement and the software control flow steps. With the
device’s fully integrated OPA, CMP and DAC functions, together with the provided
sample programs, users are able to save on external components, reduce the PCB board
area as well as decrease the required development time.
HT45F6530 AVR – AC Voltage Regulator Application Note
AN0498E 10 / 10 October 8, 2018
Versions and Modification Information Date Author Issue Release and Modification
2018.06.25 陳振隆 (Chenlung) First Version
References
HT45F6530 Datasheet.
For more information refer to the Holtek’s official website www.holtek.com.
Disclaimer All information, trademarks, logos, graphics, videos, audio clips, links and other items
appearing on this website ('Information') are for reference only and is subject to change at
any time without prior notice and at the discretion of Holtek Semiconductor Inc.
(hereinafter 'Holtek', 'the company', 'us', 'we' or 'our'). Whilst Holtek endeavors to ensure
the accuracy of the Information on this website, no express or implied warranty is given
by Holtek to the accuracy of the Information. Holtek shall bear no responsibility for any
incorrectness or leakage.
Holtek shall not be liable for any damages (including but not limited to computer virus,
system problems or data loss) whatsoever arising in using or in connection with the use of
this website by any party. There may be links in this area, which allow you to visit the
websites of other companies. These websites are not controlled by Holtek. Holtek will
bear no responsibility and no guarantee to whatsoever Information displayed at such sites.
Hyperlinks to other websites are at your own risk.
Limitation of Liability
In any case, the Company has no need to take responsibility for any loss or damage
caused when anyone visits the website directly or indirectly and uses the contents,
information or service on the website.
Governing Law This disclaimer is subjected to the laws of the Republic of China and under the jurisdiction
of the Court of the Republic of China.
Update of Disclaimer Holtek reserves the right to update the Disclaimer at any time with or without prior notice,
all changes are effective immediately upon posting to the website.