Over 10 years we help companies reach their financial and branding goals. Engitech is a values-driven technology agency dedicated.

Gallery

Contacts

411 University St, Seattle, USA

engitech@oceanthemes.net

+1 -800-456-478-23

Motor Driver Sensors and Modules TIMER Modules

HLW8012 AC Energy metering IC: Part 2

Table of Contents In the last blog of HLW8012 energy metering IC, we have got an overview and understanding of HLW8012 IC. So now in continuation to that blog, in this blog, we are going to develop the Application driver for HLW8012. But before preceding with the Application Driver, we will see the hardware setup. At first, we are going to set up the hardware and connections that has to be made for reading the AC readings. Hardware Setup and connections To be honest this is one of the challenging parts which I faced when dealing with energy metering ICs. As being mainly into Firmware and software part, I was not well aware of the electrical and electronics-related terms, concepts and instruments. Though I am from the EEE branch interest since my graduation was more aligned with Firmware. But I also want to learn and understand the electronics and electrical part, in continuation to my Firmware skills. Thus, I thought of using the Energy Metering IC and make the Energy Meter project, as by that have to learn and understand the Electronics/electrical concepts. Energy Metering IC\’s senses the AC voltage and Current, so input to these IC\’s are AC electrical signals. In comparison to other sensors/modules like temperature, Flash memory\’s, gyroscope sensors, display screens etc., in which input is either our environment or values given by us. But in Energy metering or current sensor ICs, for input we need AC load which will be powered by AC power supply. In addition to these we need multimeters, connecting wires and cables for electrical measurement and connections. Hardware Setup AC load Their are 3 types of AC load: Resistive load, Capacitive load, and Inductive load.  There are electrical programmable AC loads, which are actually used in industry for testing and development of Energy Meters. These programmable AC loads can be configured for any type of load. But those are very expensive, to be afforded. So, I started looking for cheap alternatives for all 3 types of AC load. We are going to use resistive load, which will be an AC bulb filament type. AC Source For powering the AC load, we need an AC power supply that will power it. Now while developing the Energy meter and driver for Energy metering IC, I need a variable AC power supply so that I can check the different readings of AC electrical parameters across my AC load. This is one of the first challenges that I faced, which electrical instrument to use, to have a regulated AC power supply. Because AC-regulated power supplies are also quite expensive in comparison to DC-regulated power supplies, which are not affordable to students.  Then I came to know about the Autotransformers that regulate AC power. One can take it analogous to potentiometers, on rotating the knob of them we get variable resistance. Same way in Autotransformers, there is a knob that maps from 0-270V. By rotating the knob, we can get variable AC voltage. Also, the AC signal from Autotransformer is quite stabilized and accurate, so these work great for such small and hobbyist projects. Multimeters  Multimeters are electrical instruments that are used to measure electrical/electronics parameters. Multimeters can measure both AC/DC readings. In this project multimeters would be used for measurement of AC voltage and AC current across our load. 2 multimeters would be used. One is the generic multimeter, which would be connected across the Autotransformer output pins to measure the voltage. Another is the Clamp meter, which would be connected across one of the wires of our AC load to measure the AC Current. The readings which we will get from here would be used to cross verify and check the readings that would be decoded from HLW8012. HOST MCU In our case, I have used the STM32f103-Bluepill as HOST MCU. Logic Analyzer I will also be using the Logic analyzer, for debugging and seeing the PWM digital signals, that would be outputted by HLW8012. STLINKV2 Debugger STLINKV2 will be used as a debugger to program and flash the firmware into our HOST MCU. Hardware Connections Now coming to the connection parts, we can divide HLW8012 into 2 parts, one is the electronics connection that has to be connected with the HOST MCU. Another is an electrical connection that has to be made with AC load and AC supply. At first, we will interface HLW8012 with our host MCU( which in this case is STM32F103-Blue pill). Viewers can refer to this part to understand how HLW8012 and host MCU communicate with each other. HLW8012 has mainly 3 pins CF(Blue), CF1(Green), and SEL(Yellow) pins that have to be connected with HOST MCU. These pins can be connected to any GPIO pins, just have to make sure that those GPIO pins can be configured in TIMER INPUT CAPTURED MODE. The pins at which CF &CF1 pins will be connected are configured as INPUT and the pins at which the SEL pin would be connected are configured as OUTPUT. In my case I have connected : CF1 pin of hLW8012 –> PA8 CF pin of HLW8012 –> PB6 SEL pin of HLW8012 –> PB12 VCC pin of HLW8012 –> +5V pin of MCU GND pin of HLW8012 –> GND pin of MCU I have also connected the Logic analyzer for seeing the PWM signals digitally and the debugger STLINKv2 for flashing and debugging the code with my HOST MCU. Coming to the electrical connection part, the HLW8012 module has 2 couple of green connectors on it. One couple of connectors is connected to Power Supply, in our case power supply is coming from Autotransformer. So it will be connected to the Output terminals of Autotransformer. Generic Multimeter would be. Another couple of connector is connected to the AC load, in our case, the AC load is AC bulb Filament type. Clamp multimeter would be connected across one of the wire of this connection to measure AC current. That is all connection that has to be made and

Current/Power Sensors Sensors and Modules TIMER Modules

HLW8012 AC Energy metering IC: Part 1

Table of Contents So hello guys, welcome back to Gettobyte Once again. Todays blog is going to be on interfacing the Energy metering IC : HLW8012 which is manufactured by HLW Technology.On previous blogs we have developed the application driver   for W25Q SPI based flash memory’s, is time we are going to develop the Application driver for HLW8012. So first question that must come in your mind is that what is Energy Metering IC. Lets first Understand this term. What are Energy Metering Integrated Chips ? Before Understanding Energy metering IC’s their is one term that i would like to get familiar my viewers that is ASIC’s. ASIC’s are Application Specific Integrated Chips i.e. chips which are designed, developed and fabricated for particular applications.  Energy Metering IC’s are one of the ASIC’s. In this case the specific application is that of Electrical Energy Measurement. By the use and emergence of Energy Metering IC’s we can calculate the Electrical Energy parameters like RMS/Instantaneous Voltage, RMS/Instantaneous Current, Reactive/Active/Apparent Power, Energy Consumed, Power loss/dissipation, Power factor, Frequency digitally. Using this electrical Energy Measurements only our monthly electrical energy bill is calculated. These electrical energy parameters play very important role for monitoring and analyzing of Power consumption in our homes, offices, factories, city’s and all such infrastructures where their is use of electricity. These Ic’s are widely used in Energy Meters, Multifunction Meters, Smart Energy meters, Solar Energy control panels, Factory Automation Panels and etc. Energy metering IC’s are designed using the knowledge of ADC, Opamps, Low pass/High pass filters, use of Analog Electronics with Power Electronics, DSP(Digital Signal processing), Signal Conditioning circuits. All these circuits are designed inside the Energy Metering IC’s using VLSI/VHDL. That is where the concept of Application Specific comes in. So when reading the datasheet of Energy Metering IC’s some overview about these terms and terminologies would be beneficial for understanding the functioning of these IC’s. Voltage and current drive the world in every sense. Using these 2 parameters we can calculate all other electrical energy parameters be it reactive power, active power, energy, frequency, power factor and etc. Energy Metering IC’s primarily measures/senses only Voltage and Current by the use of Signal conditioning circuits, ADC, Opamps, Analog Electronics. Further these IC’s calculates all other Electrical energy parameters using DSP, Low pass/High pass filters and etc. All of these things are designed inside the Energy metering IC’s. Input voltage and current to these IC’s are fed depending upon the principal which we are using for sensing Voltage and current. After feeding the Input to these IC’s via one of the above principals, comes the role of above mentioned circuits/units which are designed inside the chips for their efficient functioning and digital accurate readings. Energy metering IC’s which are widely used are of The above listed metering IC’s and their development boards are very expensive, so for my use case i have found out some cheap/alternative Energy Metering IC’s, but their manufacturer are Chinese companies: STMicroelectronics Metering ICSTMP32/33/34 seriesClick HereTexas Instruments Metering ICsClick HereAnalog DevicesADE seriesClick HereNXP semiconductorsClick Here Previous Next HLW8012( the one we are using this blog) HLW8032 BLO937 PZEM-004T module  CS5460 bi-directional energy meter module This is the First string, Second string, Third string of the sentence. General Description of HLW8012 Energy Metering IC HLW8012 is a single phase energy metering IC, which is based on shunt resistor based principal. The HLW8012 module has on board 1 milli-ohm copper-manganese shunt resistor, which acts as a shunt resistor and used to sense the voltage and current. One of the biggest problem with IC, is its datasheet. The datasheet of this IC is in Chinese language, so likely it would be difficult to understand from it. The IC can measure the RMS Voltage, RMS Current, Active power and Outputs these reading digitally in the form of PWM signals. HLW8012 is a good choice for making small and hobbyist kind of projects which requires the measurement of AC electrical parameters. One such project/product that I found, is made on HLW8012. HLW8012 is inexpensive and good alternative to be used in comparison to  other expensive metering IC’s. The module of HLW8012 is very handy and easy to use. It has 4 input terminals: 2 terminals are connected with AC Load and other 2 terminals are connected with AC Power supply. HLW8012 Outputs the Readings of Voltage, Current and power via PWM signals of 50 percent duty cycle, Their are two pins in HLW8012 CF and CF1 which outputs the voltage, current and power readings in a digital PWM square signal, which host MCU can capture using Timer Input Capture mode. The readings are directly proportional to the Frequency of the PWM signal. Every modern MCU has Timer peripheral, which we can configure in Timer Input capture mode. In this mode Host MCU can capture the PWM signals from external world (here our external world is HLW8012). That’s how HLW8012 will communicate with the Host MCU. Features of HLW8012 Energy Metering IC Based on shunt resistor based principal. Can measure current upto 20Amps and Voltage upto 300 Volts Easy interface to Host MCU sends voltage, current and power readings digitally via PWM square signals. Needs +5 volt to operate the IC. Block Diagram of HLW8012 Metering IC PINOUT of the HLW8012 Energy metering IC Pin Number 1 Pin number 1 is VCC (Chip Select), which is used to operate the power the HLW8012 IC. Connect this pin to +5 Volts of the host MCU. Pin Number 2 & 3 Pin number 2 &3 are V1P/V1N, which are Current differential input pins. These pins are connected in parallel to the shunt resistor(See the application circuit below). This connection is already made on the Module of HLW8012. The maximum voltage that can be input to these pins are 43.75mV. Pin Number 4 Pin number 4 is V2P, which is Voltage differential input pin, this pin is connected to  input AC voltage via resistor network of 47k ohms Pin Number 5 Pin

Stay Updated With Us

Error: Contact form not found.