
PIC ile akım ölçümü ve watt hour meter uygulaması. Bu devre, PIC16C923 mikrodenetleyici ve CS5460 güç ölçüm entegresi kullanılarak hazırlanmış, yalnızca akım değil aynı zamanda gerilim, gerçek güç, görünür güç, güç faktörü ve toplam enerji tüketimini de izleyebilen gelişmiş bir watt hour meter tasarımıdır. Yapı olarak klasik bir ampermetreden daha fazlasını sunar ve özellikle AC hat üzerindeki yük davranışını daha ayrıntılı görmek isteyenler için dikkat çekici bir uygulamadır.
Devrede akım algılama için akım trafosu, gerilim algılama için ayrı bir örnekleme yapısı, ölçüm sonuçlarını işlemek için CS5460 ve tüm sistemi yönetmek için PIC16C923 kullanılmıştır.
Ölçüm tarafında donanım yükü CS5460 üstlenirken, PIC tarafı daha çok kontrol, görüntüleme, kullanıcı arayüzü ve hafıza yönetimi görevini yürütür.
Akım algılama yapısını genel mantığıyla incelemek isteyenler için akım ve gerilim sensörleri konusu da faydalı olur.
Devrenin çalışma mantığı
İçerik
CS5460, hat gerilimini ve hat akımını doğrudan işleyen özel bir ölçüm entegresidir.
Bu uygulamada akım bilgisi T1 akım trafosu ve R21 yük direnci üzerinden, gerilim bilgisi ise T2 trafo ve direnç bölücü ağı üzerinden alınır.
Böylece şebeke hattı doğrudan mikrodenetleyiciye verilmeden, daha güvenli ve işlenebilir seviyelerde ölçüm yapılır.
Ölçülen analog değerler CS5460 içinde işlenerek VRMS, IRMS, anlık güç ve birikmiş enerji değerlerine dönüştürülür.
PIC16C923 ise bu sonuçları SPI hattı üzerinden okur, LCD’ye taşır ve toplam enerji bilgisini 24C01 EEPROM içine belirli aralıklarla kaydeder.
Bu yaklaşım, enerjinin kesilmesi durumunda watt-hour bilgisinin tamamen kaybolmamasını sağlar.
Şemadaki ana bölümler
| Bölüm | Öne çıkan elemanlar | Görev |
|---|---|---|
| Akım algılama | T1 akım trafosu, R21 56 ohm / 0.5W | Hat akımını güvenli seviyede ölçüm sinyaline dönüştürür. |
| Gerilim algılama | T2 trafo, D1-D2 doğrultma, R10-R12-R20-R22-R23-R25 ağı | Hat gerilimini izole edip CS5460 girişine uygun seviyeye indirir. |
| Ölçüm çekirdeği | U2 CS5460 | VRMS, IRMS, güç ve enerji hesabını yapar. |
| Kontrol ve görüntüleme | U1 PIC16C923, LCD panel | CS5460 ile haberleşir, sonuçları gösterir, tuşları okur. |
| Kalibrasyon ve kayıt | U3 24C01 EEPROM | Kalibrasyon sabitlerini ve toplam enerji bilgisini saklar. |
| Besleme | U4 78L05, C12-C13, T2 | Tüm dijital ve ölçüm bölümü için 5V besleme üretir. |
PIC16C923 ve CS5460 arasındaki görev paylaşımı
Bu tasarımın en güçlü tarafı, ölçüm işinin doğrudan mikrodenetleyiciye yüklenmemesidir.
PIC16C923 tüm AC hesapları kendi ADC’si ile yapmaya çalışmıyor.
Bunun yerine U2 CS5460, enerji ölçümüne özel olarak tasarlandığı için örnekleme, RMS hesapları ve enerji darbe üretimini kendi içinde gerçekleştiriyor.
PIC tarafı ise bu hazır verileri okuyup anlamlı hale getiriyor.
Bu yapı hem yazılımı sadeleştirir hem de doğruluğu artırır.
PIC16C923 bir yandan LCD paneli sürerken bir yandan da 24C01 ile haberleşip toplam enerji bilgisini hafızada tutabiliyor.
Mikrodenetleyici tarafında benzer temel mantıkları geliştirmek isteyenler için mikrodenetleyiciler ders notları da iyi bir tamamlayıcı olabilir.
Gösterilen ölçüm değerleri
Bu watt hour meter yalnızca anlık akımı göstermekle sınırlı değildir.
Ekranda saat bilgisi, RMS gerilim, RMS akım, görünür güç, gerçek güç, güç faktörü ve toplam watt-hour değeri arasında geçiş yapılır.
Böylece yükün sadece ne kadar akım çektiği değil, bu akımın ne kadar verimli kullanıldığı da görülebilir.
Özellikle güç faktörü bilgisi, motorlu veya anahtarlamalı yüklerde önemli hale gelir.
Çünkü aynı akımı çeken iki farklı yük aynı gerçek gücü tüketmeyebilir.
Bu yüzden bu proje, basit akım ölçümünden daha ileri bir enerji izleme örneği olarak değerlendirilebilir.
EOUT, EDIR ve enerji hesabı
CS5460, tüketilen enerji belirli bir seviyeye ulaştığında EOUT pininde darbe üretir.
Bu darbeler PIC16C923 tarafından sayılarak toplam enerji hesabında kullanılır.
EDIR pini ise enerji akış yönünü bildirir.
Böylece reaktif karakterli yüklerde enerjinin yön bilgisi de izlenebilir.
Uygulama notunda sistem, her 10 watt-saniye enerji geçişinde darbe üretecek şekilde ayarlanmıştır.
Bu yöntem sayesinde PIC tarafında ağır matematik yapmak yerine darbe sayımı ile daha pratik ve kararlı bir gerçek güç ve enerji hesabı elde edilir.
Kalibrasyon bölümü neden önemlidir?
Bu devrenin sağlıklı çalışması için yalnızca şemayı kurmak yeterli değildir. Akım ve gerilim örnekleme yapıları, kullanılan trafo oranları ve direnç değerleri nedeniyle kalibrasyon şarttır.
Sistem içinde gerilim ofseti, akım ofseti, gerilim kazancı, akım kazancı ve darbe oranı için ayrı ayar mantığı bulunur.
Kalibrasyon sabitleri 24C01 EEPROM içinde saklanır ve açılışta PIC16C923 tarafından okunup CS5460’a yüklenir.
Bu yapı, cihaz her açıldığında yeniden ayar yapma ihtiyacını azaltır. Assembly tabanlı bu tarz uygulamalara yakın duran çalışmalarla ilgilenenler için açıklamalı asm örnekleri de yararlı olabilir.
Kurulum ve uygulama sırasında dikkat edilmesi gerekenler
- Bu devre doğrudan şebeke ile ilişkili olduğu için izolasyon ve güvenlik ön planda tutulmalıdır.
- T1 akım trafosu ve T2 gerilim örnekleme trafosu doğru oran ve doğru bağlantıyla kullanılmalıdır.
- R21 gibi akım algılama tarafındaki dirençler güç değerine uygun seçilmelidir.
- Kalibrasyon yapılmadan ölçüm sonuçlarının tam doğru olması beklenmemelidir.
- EEPROM saklama mantığı sayesinde enerji verisi korunur, ancak yazılım akışı değiştirilirse bu bölüm ayrıca test edilmelidir.
- LCD sürme, SPI ve yazılımsal I2C birlikte çalıştığı için port yönleri ve zamanlamalar dikkatle kontrol edilmelidir.
PIC16C923 ve CS5460 ile hazırlanan bu tasarım, sadece akım ölçen bir devreden çok daha fazlasını sunar.
Gerilim, akım, görünür güç, gerçek güç, güç faktörü ve toplam enerji takibi aynı sistem içinde bir araya getirilmiştir.
Bu yönüyle hem enerji ölçüm entegrelerinin nasıl kullanıldığını görmek isteyenler hem de PIC tabanlı gerçek bir uygulama incelemek isteyenler için oldukça öğretici bir projedir.
Özellikle akım trafosu ile izolasyonlu ölçüm yapılması, EEPROM ile kalibrasyon verilerinin saklanması ve CS5460’ın yükü hafifleten hazır ölçüm altyapısı, bu projeyi klasik hobi devrelerinden bir adım öne çıkarır.
watt_mtr.asm yazılım içeriği
list st=off ; suppress list file symbol table
list n=0 ; suppress list file page breaks
;*******************************************************************
; Configuration switches. These control what code is assembled.
; Select the desired operating voltage by commenting out all but
; the desired voltage range
#define VOLT120 ; 120V nominal full scale range
; #define VOLT220 ; 220V nominal full scale range
; Selects the real time clock frequency source,
; #define TMR1OSC ; defined if using 32kHz T1OSC, comment out if another RTC source
;************************************************************
; Software License Agreement
;
; The software supplied herewith by Microchip Technology Incorporated (the
; "Company") for its PICmicro® Microcontroller is intended and supplied to
; you, the Company's customer, for use solely and exclusively on Microchip
; PICmicro Microcontroller products.
;
; The software is owned by the Company and/or its supplier, and is protected
; under applicable copyright laws. All rights are reserved. Any use in
; violation of the foregoing restrictions may subject the user to criminal
; sanctions under applicable laws, as well as to civil liability for the
; breach of the terms and conditions of this license.
;
; THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES, WHETHER
; EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY
; TO THIS SOFTWARE. THE COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE
; FOR SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
;************************************************************
; Author: Stephen Humberd, Brett Duane
; Company: Microchip Technology Inc.
; Revision: 1.1
; Date: 5-15-2000
; Assembled using MPLAB 4.99.07, MPASM 2.30.11
;************************************************************
; Include Files: CAL.INC calibration constants
; PR3.INC LCD segment definitions
; P16C924.INC Standard Microchip include file for PIC16C923/924
;************************************************************
; This program controls and reads data from The Crystal CS4560
; Single Phase Bi-Directional Power/Energy IC
; and displays it on a eight digit LCD using the LCD drive
; function of a PIC16C923.
; The CS5460 measures line voltage and current transfered between
; the line (source) and the load. The instantanious voltage and current
; measurements are used to compute (within the CS5460) instantanious power,
; RMS voltage, RMS current, and accumulated energy. All of these
; measurements and calculation results are avalible to the PIC16C923 via SPI.
;
; The RMS voltage and RMS current are displayed and used to calculate aparent
; power.
;
; A pulse output (EOUT) on the CS5460 indicates when a programable amout of
; energy has been transferred between the line and the load. Another output
; (EDIR) indicates the direction of that transfer (if a load is highly
; reactive, enegry flows from the load to the line). These pulses are counted
; by the PIC16C923 to measure and display total energy transferred in WattHours
;
; True power is measured by counting pulses for 1 second. The CS5460 has been
; programmed to generate a pulse for each 10WattSeconds of energy tranferred.
; The pulse count is multiplied by 10 to calculate true power.
;
; Aparent power and true power are displayed, and are used to calculate the
; power factor of the load.
;
; The CS4560 outputs a 4.096MHz clock for use by the PIC16C923 as the system
; clock. This code offers the option of using this source as the real time clock
; source with CCP1 in compare/interrupt only/special event mode, or using the Timer1
; oscillator with a 32.768KHz crystal. The hardware provided on the demo units
; supports both options.
;
; Every 8 minutes, the current accumulated energy (WHr) is written to the 24C01
; serial EEPROM. This saves the total energy during times when the AC power is removed.
;
; Calibration constants are also stored in the 24C01. These are read from the 24C01
; and written back to the CS5460 when power is reapplied, and when the total enegy is
; cleared from the 24C01. The code to read the constants from cal.inc and write them to
; the 24C01 has been included, but has been commented out.
;
; On reset, the PIC16C923 checks the 4 control buttons for 3 specific states. One state
; allows the user to set the time of the real time clock. Another state clears the
; total WHr for the 24C01 and rewrites the calibration constants to the CS5460. A
; third state allows the user to adjust the calibration constants in the CS5460.
;
; Written by Stephen Humberd, Microchip Technology 10/08/1999
;************************************************************
; Optional Real Time Clock sources (T1OSC or CS5460 CPUCLK output)
; Monitor CS5460 !EDIR output.
; Change Pulse Rate from 128 pulses/KWHr (1 pulse/28,125Wsec)
; to 1 pulse/10Wsec (100W load generates 10 pulses per second)
; Use 16-bits of CS5460 data rather than 24-bits
; (CS5460 settings are still 24-bits long)
; Added Apparent Power, True Power, and Power Factor Functions.
; Moved Pulse Rate register value to EEPROM.
; Modified Calibrate routine to include Pulse Rate "Gain" function.
; General code size reduction. (Fits in PIC16C923.)
;
; If the CPUCLK output of the CS5460 is 4.096MHz, the CCP1 module
; can be used (as is) for the real time clock reference instead of the
; Timer1 Oscillator. If the CPUCLK output is some other frequency,
; CCPR1H:CCPR1L will need to be adjusted to make CCP1 generate an interrupt
; every 0.5 second.
;
; If the Timer1 oscillator is to be used as the Real Time Clock base,
; uncomment line 46 ("#define TMR1OSC"). This causes CCP1 code to
; be disabled and T1OSC code to be enabled.
;
; Modified by Brett Duane, Microchip Technology 5/25/2000
;************************************************************
OVERVIEW: This application note shows how to use a PIC16C923 microcontroller to control operation of the CS5460 power measurement integrated circuit from Cirrus Logic®/Crystal Power Measurement, to drive a liquid crystal panel (“glass”), and to store and retrieve data using the 24C01 Serial EEPROM.
Energy transferred between the line and load is measured by the CS5460. The PIC16C923 initializes the CS5460 with calibration data stored in the 24C01 Serial EEPROM, records the total energy measured in the 24C01, and displays results on the LCD panel.
INTRODUCTION: Most forms of AC power measurement have already been patented by various companies, so measuring AC power in a product intended for sale often involves
paying licensing fees to another company. The CS5460 offers an integrated solution that provides a power and energy measurement sub-system, requiring only voltage and current sense inputs. In addition, calibration is accurate for any current waveform or power factor that may be encountered. By using the CS5460, a PIC16C923 microcontroller, a 24C01 Serial EEPROM, and an LCD panel, a simple and compact device is constructed that displays RMS voltage, RMS current, and the energy consumed by a load. These features are extended by including computation and display of apparent power, true power,
and power factor.
The PIC16C923 LCD controller can drive an LCD panel with up to 4 common planes and up to 32 segments. 4K words of program memory, and 176 bytes of RAM are provided. A Synchronous Serial Peripheral (SSP) provides SPITM communications with the CS5460. Inter-Integrated CircuitTM (I2C) communications with the 24C01 Serial EEPROM are provided by firmware. The CS5460 power/energy measurement IC measures instantaneous voltage and current four thousand times a second and uses these measurements to compute VRMS, IRMS, instantaneous power, and accumulated energy results for read out. In addition, a pulse is generated whenever a user specified amount of energy transfers between the line and the load.
Not: Projeye ait; cal.inc, FXM66.A16, P16C924.INC, pr3a.inc, watt_mtr.asm, WATT_MTR.LST, Watt_mtr.pcb, watt_mtr.pjt, Watt_mtr.SCH Dosyaları var çizimler P-CAD 2006 Programı ile açılabilir.

