Home
UNIVERSITI TEKNOLOGI MALAYSIA
Contents
1. Function void USBCBErrorHandler void void USBCBErrorHandler void FE TR k ale sk sie ae le ale ak ak ak ae ale 2 sk ak ae ak ale ak sk ae oie ale 2 ale oie oe le ale ak ai ae ale 2 2 SF oe ale ale ale oie ae le ale 2 ake akk akk ak ak ak ak ak ake e ake akk akk ak R R R Function void USBCBCheckOtherReq void void USBCBCheckOtherReq void USBCheckHIDRequest y Function void USBCBStdSetDscHandler void void USBCBStdSetDscHandler void 1 j Function void USBCBlnitEP void voi
2. void USBCBSuspend void ifdefined C30 _IPL 1 USBSleepOnSuspend endif Function void USBIInterrupt void if 0 void attribute _ interrupt USB1Interrupt void if defined self powered if ULOTGIRbits ACTVIF IEC5bits USBIIE 0 UIOTGIEbits ACTVIE 0 IFS5bits USBIIF 0 USBClearInterruptFlag USBActivityIFReg USBA ctivityIFBitNum USBClearInterruptFlag USBIdleIFReg USBIdleIFBitNum USBSuspendControl 0 endif endif 88 Function void USBCBWakeFromSuspend void void USBCBWakeFromSuspend void Function void USBCB SOF Handler void void USBCB SOF Handler void
3. PORTS Depending on the device selected and features enabled there are up to five ports available Some pins of the I O ports are multiplexed with an alternate function from the perpheral features on the device In general when a peripheral is enabled that pin may not be used as a general purpose UO pin Each port has three registers for its operation These registers are TRIS register data direction register PORT register reads the levels on the pins of the device LAT register output latch The Data Latch register LATA is useful for read modify write operations on the value driven by the I O pins A simplified model of a generic VO port without the interfaces to other peripherals is shown in Figure 10 1 FIGURE 10 1 GENERIC WO PORT OPERATION Note 1 VO pins have diode protection to and Vss 10 4 PORTA TRISA and LATA Registers PORTA is an 8 bit wide bidirectional port The corme sponding Data Direction register is TRISA Setting a TRISA bit 1 will make the corresponding PORTA an input i e put the corresponding output driver in a high impedance mode Clearing a TRISA bit 2 will make the corresponding PORTA pin an output i e put the contents of the output latch on the selected pin Reading the PORTA register reads the status of the pins writing to it will write to the port latch The Data Latch register LATA is also memory mapped Read modify write opera
4. power cord siygle phase supply power socket Voltage Transducer V current Figure 3 2 Schematic of the hardware design 19 3 2 1 Voltage Transducer Figure 3 3 Voltage Transducer LV 25 P R1 o HT R2 HT gt Figure 3 4 Connection of LV 25 P A voltage transducer is a special type of transformer where they convert the primary voltage to secondary voltage almost the same phase with the primary voltage The ratio of the primary voltage to secondary voltage is a known constant which changes very little with load Therefore it is suitable to be use in measuring and monitoring the voltage on a system without having to interrupt the system The low voltage output at secondary also enables us to operate measuring equipments and tools at low voltage 6 The model of voltage transducer that is used in this project is LV 25 P which is a closed loop Hall Effect transducer Hall Effect transducer uses the changes in magnetic field to control the output voltage of the transducer The general advantages of this voltage transducer including high bandwidth low thermal drift good linearity high accuracy immunity to external interference is high and disturbance in common mode is low The primary nominal rms current is 10 mA while the primary nominal 20 rms voltage is in the range of 10 to 500 V The secondary nominal rms current is 25 mA with a conversion ratio of 2500 1000 In order to op
5. FE Tk sk ale le sk sie ae oF ale ak ak ole ae eoi sk ak oe le ale ak ak oe oie ale ae ok oe oe ak ale ak ok o ale ae ok oie oe ale ale sk 3 fe ie ale 2 ake akk akk ak ak ak ae fe ake ke ake akk akk ak R R R Kk K k k 2K k e K kO R Function void Userlnit void void Userlnit void Initialize the push buttons mInitAllSwitches USBOutHandle 0 USBInHandle 0 Function void ProcessIO void void ProcessIO void while button 0 if USBDeviceState lt CONFIGURED_STATE USBSuspendControl 1 return 85 if HIDRxHandleBusy USBOutHandle switch ReceivedDataBuffer 0 1 case 0x37 Read POT command Uses ADC to measure an analog voltage on one of the ANxx I O pins and returns the result to the host WORD VAL w if HIDTxHandleBusy USBInHandle 1 1 2 1 mInitPOT1 w ReadPOT ToSendDataBuffer 0 0x37 Echo back to the host the command we are fulfilling in the first byte In this case the Read POT analog voltage command ToSendDataBuffer 1 w v 0 Measured analog voltage LSB ToSendDataBuffer 2 w v 1 Measured analog voltage MSB USBInHandle HIDTxPacket HID EP BYTE
6. Output pin definitions Zdefine INPUT PIN 1 define OUTPUT PIN 0 endif HARDWARE PROFILE PICDEM FSUSB H Main c ifndef MAIN C define MAIN C include USB usb h include HardwareProfile h include USB usb function hid h CONFIGURATION if defined PICDEM FS USB pragma config BORV 3 pragma config VREGEN ON pragma config OFF pragma config WDTPS 32768 pragma config MCLRE ON pragma config LPTIOSC OFF pragma config PBADEN OFF pragma config CCP2MX ON pragma config STVREN ON pragma config OFF Zpragma config PLLDIV 5 pragma config CPUDIV OSCI PLL2 pragma config USBDIV 2 pragma config FOSC HSPLL HS pragma config FCMEN OFF pragma config IESO OFF pragma config PWRT OFF pragma config ON ffipragma config ICPRT OFF pragma config XINST OFF pragma config pragma configCPl OFF config CP2 OFF ffpragmaconfig CP3 OFF pragma config CPB OFF fipragmaconfig CPD OFF pragma config WRTO OFF pragma config OFF fipragma config WRT2 OFF ffpragmaconfig WRT3 OFF pragma config WRTB OFF pragma config WRTC OFF config WRTD OFF pragma config EBTRO OFF pragma config OFF fpragmaconfig EBTR2 OFF pragma config EBTR3 OFF pragma config EBTRB OFF else error No hardware board
7. Some special hardware features have been included to improve performance Dual port memory in the device s data memory space USB RAM has been supplied to share direct memory access between the microcontroller core and the SIE Buffer descriptors are also provided allowing users to freely program end point memory usage within the USB RAM space A Streaming Parallel Port has been provided to support the uninterrupted transfer of large volumes of data such as isochronous data to external memory buffers Figure 17 1 presents a general overview of the USB peripheral and its features Note 1 This signal is only avallable If the Intemal transcelver Is disabled UTRDIS 1 2 The intemal pull up resistors should be disabled UPUEN o If external pull up resistors are used 3 Do notenabie the Internal regulator when using an extemal 3 3V supply 2009 Microchip Technology Inc DS39632E page 165 65 PIC18F2455 2550 4455 4550 21 0 10 BIT ANALOG TO DIGITAL The register M on controls operation e module The CONVERTER MODULE ADCON1 register shown in Register 21 2 configures The Analog to Digital A D converter module has the functions of the port pins The ADCON2 register 10 inputs for the 28 pin devices and 13 for the shown in Register 21 3 configures the A D clock 40 44 pin devices This module allows conversion of an source programmed acquisition time and justification analog input signal to a
8. SK40C ENHANCED 40 PINS PIC START UP KIT User s Manual V1 2 Dec 2010 Information ccominsd thi poblixnom regarding device sppicincn and the bike s mended through sungeisen only and may be szpaneded by updates is your responsibility to approval by Cyn eim dogs No licenze are com eyed implicitiy or otherwise under intellectaal property rights 76 Cytron ROBOT HEAD to Product User s Manual SK40C 3 BOARDLAYOUT uo IE 2 means b wwwwwwww s un ze e ox as 4 l P aman J a ME en B ess Cytron gt sxaoc QO b Side view Created by Cytron Technologies Sdn Bhd All Rights Reserved Cytron 5 ROBOT HEAD to TOE Techn Product User s Manual SK40C c Bottom view Dis Fac DC power adaptor socket Programmable Push Button USB Connector Reset button Toggle Switch for power supply LCD contrast Power indicator LED JP8 for LCD Backlight Connector for UICOOA JP9 for USB Programmer LED Indicator 40 pin IC socket for PIC MCU Header p n and tum p n Eg Tum pin for crystal P por A DC power adaptor socket for user to plug in DC adaptor The input voltage should be ranged from 7 to 15V B USB connector for communication between devices and a host controller usually personal computers This function is only valid for certain model of PIC microcontr
9. erei vers D sess eer Por Legend R Readable bit W Writable bit U Unimplemented bit read as 0 n Value at POR T Bit is set 0 Bit is cleared x Bit is unknown bit 7 6 Unimplemented Read as 2 bit 5 VCFG1 Voltage Reference Configuration bit Vrer source 1 Vaer AN2 0 Vss bit 4 VCFG0 Voltage Reference Configuration bit VRer source 1 Vrer AN3 0 Voo bit 3 0 PCFG3 PCFG0 A D Port Configuration Control bits ooo A A oco JA JA 0010 ome eed 902310 AJ AJA AJAJAJAJAJ AJAJAJA ooo OTATATATATATATATATATATA 0101 D D D JAJAJAJAJA AJALJA A A ui OT OTOTOTATATALTATATATATATA oi D D 2000 0 p 0 2001 p p 0 2 22 2021 p p F HK GE SE a Y 210 Ga PIP RE pedes es S ERES A rum input D Digital UO EEE ptr Note 1 The POR value of the PCFG bits depends on the value of the PBADEN Configuration bit When PBADEN 1 PCFG 3 0 2020 when PBADEN 0 PCFG lt 3 0 gt 0111 2 ANS through AN7 are available only on 40 44 pin devices DS39632E page 266 2009 Microch
10. Degree of Bachelor of Engineering Electrical DISDIRIFE ucl oppo Name of Supervisor En Alias Bin Mohd Yusof Date 15 MAY 2011 POWER MEASUREMENT AND PROFILE USING PC LIM ZI JIE This thesis is submitted in partial fulfillment of the requirements for the awarding of Degree in Bachelor of Electrical Engineering Faculty of Electrical Engineering Universiti Teknologi Malaysia MAY 2011 ii Tt is hereby declared that all the materials in this thesis are the effort of my own work and idea except for works that have been cited clearly in the references The thesis has not been accepted for any degree and is not concurrently submitted in candidature of any degree Signature Name of Author LIM ZI JIE Date 15 MAY 2011 iii Dedicated in huge gratitude to my beloved father mother sisters and lover for their care understanding and encouragement ACKNOWLEDGEMENT In this section of the thesis I would like to express my most sincere gratitude to my supervisor Mr Alias bin Mohd Yusof for his continuous guidance Due to his constructive ideas and unrelentless support I had been able to complete this project with certain degree of quality Without his support I would not finish it on time Besides that I would also like to say thanks to the Power Electronics Laboratory and Advance Power Laboratory for allowing me to use their equipments in the process of completi
11. End If End While End If Return False Catch ex As Exception Return False End Try End Function FUNCTION FormUpdateTimer Tick Private Sub FormUpdateTimer Tick ByVal sender As System Object ByVal e As System EventArgs Handles FormUpdateTimer Tick 102 If AttachedState True Then StatusBox txtbx Text Device Found AttachedState TRUE End If If AttachedState False Or AttachedButBroken True Then StatusBox txtbx Text Device Not Detected Verify Connection Correct Firmware ADCValue 0 End If If ispause 0 Then voltagetxtbox Text ADCValue End If End Sub FUNCTION ReadWriteThread DoWork Private Sub ReadWriteThread DoWork ByVal sender As System Object ByVal e As System ComponentModel DoWorkEventArgs Handles ReadWriteThread DoWork Dim OUTBuffer 65 As Dim INBuffer 65 As Dim BytesWritten As Ulnteger 0 Dim BytesRead As UlInteger 0 Dim ErrorStatus As UInteger While True Try If AttachedState True Then 103 OUTBuffer 0 0 The first byte is the Report ID and does not get sent over the USB bus unless the HID report descriptor uses Report IDs Assume the HID report descriptor does not then always set this byte to 0 OUTBuffer 1 amp H37 READ POT command see the firmware source code gets 10 bit ADC Value nitialize the rest of the 64 byte packet to OxFF Binary 1 bits do not use as much power and do not cause as much EMI when they move across
12. REO AN 12 NT FLTD 2DUSDA voo vss RCT RX DT 2DO RCETX CK RCSIDe vP RCAD M RBIANTOTNTI SCK SCL REDANIDINTOFLTOSDVSDA lt von RDEISPPEIFIC RDSISPPSFIB RD4 SPP4 RCTIRXIDTISOO RC amp TX CK RCSIDe VP RCAD VM RDIYSPF3 02 9 2 2008 Microchip Technology Inc 63 PIC18F2455 2550 4455 4550 TABLE 1 2 PIC18F2455 2550 PINOUT VO DESCRIPTIONS CONTINUED PORTA is a bidirectional I O port Digital 1 0 Analog input 0 Digital WO Analog input 1 Digital I O Analog input 2 A D reference voltage low input Analog comparator reference output Digital 1 0 AN3 Analog input 3 A D reference voltage high input RAA TOCKI C tOUT RCV RAS Digital WO TOCKI Timer externa clock input C1OUT Comparator 1 output External USB transceiver RCV input Digital VO Analog input 4 SPI slave select input High Low Voltage Detect input Comparator 2 output See the OSC2 CLKO RAG pin Legend TTL TTL compatible input CMOS CMOS compatible input or output ST Schmitt Trigger input with CMOS levels 1 Input Output P Power Note 1 Alternate assignment for CCP2 when CCP2MX Configuration bit is cleared 2 Default assignment for CCP2 when CCP2MX Configuration bit is set 2009 Microchip Technology Inc DS39632E page 13 64 PIC18F2455 2550 4455 4550 10 0
13. Tcorr 025 Temp 25 C 0 02 us C 85 25 0 02 us C 12us Temperature coefficient is only required for temperatures gt 25 C Below 25 Tcorr 0 us CuourpyXRic Rss Rs In 1 2048 us 25 pF 1 ka 2k 2 5 kn In 0 0004883 us 105 us O2us 105u5 12us 245 us DS39632E page 270 2009 Microchip Technology Inc 69 70 APPENDIX B LV 25 P Voltage Transducer Datasheet Voltage Transducer LV 25 P L 10mA For the electronic measurement of voltages DC AC pulsed with galvanic isolation between primary circuit high voltage ui 10 500V and the secondary circuit electronic circuit Electrical data 7 a Features bu I y i m Closed loop compensated voltage Py ered meg raspa kie mA ton did R Measuring resistance Ru Rum e Insulated plastic case recognized with 12V 10 uu 30 190 n according to UL 94 V0 Q 14 30 100 with 15 V 10 100 350 inci 14 100 190 Principle of use L Secondary nominal current rms 25 mA For voltage measurements a current K Conversion ratio 2500 1000 ie aa V Supply voltage 5 12 15 v must be passed through an external 1 Current consumption 100 15 1 mA resistor R which is selected by the user and installed in senes with the Accuracy Dynamic performance data primary circuit of the transducer X Overall Accuracy L T 25 C 12 15V 00 Advantag
14. ms CH1 Z 125mV Figure 4 2 Output from oscilloscope 1 electric toaster The result from the tests is shown in the table below Table 4 1 Result of first test ELECTRICAL RMS VOLTAGE RMS VOLTAGE POWER AVERAGE APPLIANCES VOTAGE CURRENT FACTOR POWER Electric Kettle 2 96 V 2 64 V 1 0 2026 02 W Electric Toaster 2 88 V 0 85 V 1 0 636 48 W 4 3 Output from Transducer through Bridge Rectifier After the value of voltage and current were reduced into a acceptable range the outputs from the previous test are passed through the bridge rectifier to filter out the negative values 44 4 3 1 Procedures 1 The circuit was connected as shown in Figure 3 2 2 The power supply for the transducers that is 15 V is being supplied 3 The outputs from both the transducers were connected to the oscilloscope 4 The electric kettle is then connected to the power socket and the power cord which is connected to the power outlet was switched on 5 The results from the oscilloscope were saved and recorded 6 The test was then repeated with the electric toaster 4 3 2 Result e Stop M Pos 0 0005 SAVE REC AA AAN Format JPEG About Saving JUS Save 004 JPG CH1 200v 200v 1 0ms CH2 2 1 761 Current Folder is 4 4 Figure 4 3 Output from oscilloscope 2 electric kettle 45 Tek alle e Stop Pos 0 0005 SAVE REC f A gt x 8 About Saving Imag
15. within the interface of the machine only Although in some machines the data can be exported through external disk this process will take time and is not efficient as we had to continuously copy data from the machine and read it in our own computers Otherwise some devices provides direct linking through traditional port such as parallel and serial port which is rarely available in a more portable computer that is a laptop We do not want to carry our huge home desktop computer wherever we wanted to work Hence a more portable and flexible data acquisition system must be produced To make the operations autonomous and efficient a microcontroller can be used in the system A microcontroller is flexible electrical equipment that provides lots of function according to what we tell the microcontroller to do It can control from small electrical circuit to a robot or a large system depending on our applications 14 In the year 2004 M Popa an IEEE member M Marcu and A S Popa had proposed a data acquisition system using microcontroller Furthermore the system uses USB as the interfacing device They selected the P89C51RD2 microcontroller as the core of the system The microcontroller will control the USB interface device to receive and send data by using the interrupt from the microcontroller The USB interface ISP1181 is using USB 1 1 specifications and is connected directly to the microcontroller Two TLC0820 ADCs are solely controlled by sof
16. 1 delay count Twhile delay count USBResumeControl 0 Finished driving resume signalling 90 USBUnmaskInterrupts j j j Function BOOL USER USB CALLBACK EVENT HANDLER USB EVENT event void pdata WORD size BOOL USER USB CALLBACK EVENT HANDLER USB EVENT event void pdata WORD size switch event 1 case EVENT TRANSFER Add application specific callback task or callback function here if desired break case EVENT SOF USBCB SOF Handler break case EVENT SUSPEND USBCBSuspend break case EVENT RESUME USBCBWakeFromSuspend break case EVENT CONFIGURED USBCBInitEP break case EVENT SET DESCRIPTOR USBCBStdSetDscHandler break case EVENT REQUEST USBCBCheckOtherReq break case EVENT BUS ERROR USBCBErrorHandler break case EVENT TRANSFER TERMINATED break default break return TRUE void delay unsigned long data for data gt 0 data main c endif 91 92 APPENDIX F Coding of Software Interface Form1 Imports Microsoft Win32 SafeHandles Imports Sy
17. 1 1 voltageValue currtextbox Text If voltageValue gt highestcurrent Then highestcurrent voltageValue highestcurrentTime MyMiliseconds2 End If highestCurrenttxt Text highestcurrent currentTimetext Text highestcurrentTime currentValue CurrentArrindex voltageValue currentMiliSecond1 CurrentArrindex MyMiliseconds normal time currentMiliSecond2 CurrentArrindex MyMiliseconds2 graph time CurrentArrindex CurrentArrindex 1 End If powerarrValue powerArrindex powerValue powerarrMilisecondl powerArrindex MyMiliseconds powerarrMilisecond2 powerArrindex MyMiliseconds2 powerArrindex powerArrindex 1 timetext Text MyMiliseconds End Sub 107 Private Sub Button2_Click ByVal sender As System Object ByVal e As System EventArgs Handles Button2 Click idcounter Me Databasel DataSet voltageProfile Count idcounterCurr Me Databasel DataSet currentProfile Count idcounterPow Me Databasel DataSet powerProfile Count voltage delete For intloopIndex As Integer 0 To idcounter Me VoltageProfileTableAdapter Delete intloopIndex Next intloopIndex current delete For intloop As Integer 0 To idcounterCurr Me CurrentProfileTableAdapter Delete intloop Next intloop For intloopPower As Integer 0 To idcounterPow Me PowerProfileTableAdapter Delete intloopPower Next intloopPower fill the data to data grid view Me VoltageProfileTableAdapter Fill Me DatabaselDataSet voltageProfi
18. 15 V to activate the electronics circuit inside the transducer They are connected to the and pin of the transducer 22 A resistor R3 is connected to the M pin of the transducer and the voltage across R3 will be measured as the output voltage This output voltage will then be calculate and revert back to obtain the actual input current by using the proportionality relationship of voltage and current 3 2 3 Bridge Rectifier 2 bridge rectifiers which the model name is KBP402 is connected to the output of from both the voltage and current transducer to filter out the negative signal of the sinusoidal waveform PIC18F4550 that we used in the project can only receive positive voltage signal and hence the rectifiers plays a vital role in the conversion process The outputs voltage from current and voltage transducer is feed into the AC pins of the bridge rectifier while the output after rectified from pin and pin is connected to the input port of the PIC and ground respectively Figure 3 7 Bridge rectifier 23 3 2 4 Power Cord and Socket Figure 3 8 Power cord and socket A power cord is used to provide the single phase supply from the main socket to the whole circuit system as well as to the equipment to be measured The power socket provides a stand to the electrical equipment to draw the power supply required to operate In this project domestic load is used and hence a regular 3 pins 13 A power cord and sock
19. Low Speed Full Speed and High Speed depending on the applications In the design an interface circuit and a function circuit was combined to form the whole circuit system The interface circuit is used to link the computer and the function circuit together while the function circuit collect the signals from the equipment and send it to the interface circuit The EZ USB chip was used to communicate with the ADC of the system When the system operates the external analog signal will be sent to the sample holding circuit The signal will be process by the ADC chip MAX197 and after the conversion process is completed the data will be transferred to the USB interface chip and then to the PC application software The equipment was used to detect an industrial control system and the project gave high stability and precision 15 In the paper published by Dmytro Titkov Volodymyr Shvaichenkoa and Olena Shvaichenko the use of microcontroller with USB interface was again proved the significant advantage in data acquisition and controlling system USB protocol was used as small computer models such as laptop does not support RS232 or 16 parallel port In order to allow communication with the PC PIC with USB support is still the best way to implement the required system It is many times much cost effective than using method other than mentioned above 16 CHAPTER 3 METHODOLOGY 3 1 Introduction This project is divided into two phas
20. MatchFound DeviceIDFromRegistry Contains DeviceIDToFind If MatchFound Then DetailedInterfaceDataStructure cbSize Marshal SizeOf DetailedInterfaceDataStructure SetupDiGetDevicelnterfaceDetail DevicelnfoTable InterfaceDataStructure IntPtr Zero 0 StructureSize IntPtr Zero Dim pUnmanagedDetailedInterfaceDataStructure As IntPtr IntPtr Zero pUnmanagedDetailedInterfaceDataStructure Marshal AllocHGlobal CType StructureSize IntPtr DetailedInterfaceDataStructure cbSize Marshal StructureToPtr DetailedInterfaceDataStructure pUnmanagedDetailedInterfaceDataStructure False 101 If SetupDiGetDevicelInterfaceDetail DeviceInfoTable InterfaceDataStructure pUnmanagedDetailedInterfaceDataStructure StructureSize IntPtr Zero IntPtr Zero Then Dim pToDevicePath As IntPtr pToDevicePath pUnmanagedDetailedInterfaceDataStructure Tolnt32 DevicePath Marshal PtrToStringUni pToDevicePath SetupDiDestroyDeviceInfoList DeviceInfoTable Marshal FreeHGlobal pUnmanagedDetailedInterfaceDataStructure Return True Else Dim ErrorCode As UInteger Marshal GetLastWin32Error SetupDiDestroyDeviceInfoList DeviceInfoTable Marshal FreeHGlobal pUnmanagedDetailedInterfaceDataStructure Return False End If End If InterfaceIndex InterfaceIndex 1 LoopCounter LoopCounter 1 If LoopCounter 10000000 Return False End If Else ErrorStatus Marshal GetLastWin32Error SetupDiDestroyDeviceInfoList DeviceInfoTable Return False
21. a button in C we need to use coding to specified the width length texts in the buttons and is very troublesome if we want the software to have a lot of buttons and textboxes Other than buttons and textboxes Visual Basic gives the user a lot of functions that is required in most GUI based development such as checkbox graphical plot background editing drop boxes and so on All these objects can be add into the software by just a single click and then add some command for the objects to function or respond to events Hence Visual Basic provides the user to create an user friendly interface software with greater ease 10 1 Visual Basic Based Interface Software After all the hardware and data transferring system had been developed there must be someone to control all these processes and handle the data transferred Software based on Visual Basic will be the one who will collect these data 38 transferred from the hardware as well as indirectly give command to the hardware to start or stop working Visual Basic is chosen as the programming language because it is easier to understand and write This software will detect whether the device is connected or not then send a signal to start receiving data after the push button on the SK40C board had been pressed The software will start receiving data from the PIC and then calculations will be done in the software to get the values of voltage current power factor and power of the e
22. conversion From the datasheet the minimum required acquisition time is 2 45 us This time shows that the ADC requires some time to make sure that the whole conversion process is completed before follow up with another conversion For a 10 bit device the minimum step size of the converter is 1 1023 29 1 1 Step size 210 1 1023 To configure the port pins of the PIC to receive analog signal and convert it into digital form the registers need to be set in the firmware Below shows a part of the coding in order to use port AO and port Al as the analog input port with ADC on define DEMO BOARD PICDEM FS USB define PICDEM FS USB define CLOCK FREQ 48000000 SWITCH Wh i d define mInitAllSwitches TRISBbits TRISB0 1 define button PORTBbits RBO POT define mInitPOT1 TRISA 0b00000001 ADCON0 0b00000001 ADCON1 0x00 ADCON2 0b10010100 define mInitPOTZ TRISA 0b00000010 ADCON0 0b00000101 ADCON1 0x00 ADCON2 0b10010100 Figure 3 14 Part of the firmware 30 3 3 1 3 SK40C Development Board PIC18F4550 USB V voltage RAO V current RA1 GND D mt Crystal AN D Oscillator 20MHz N O RESET SW1 Figure 3 16 Schematic of the connection of SK40C board The SK40C is a device made by Cytron Technologies to provide the users to speed up the development of a PIC related projects This board only con
23. corresponding 10 bit digital number The module has five registers A D Result High Register ADRESH A D Result Low Register ADRESL A D Control Register 0 ADCOND A D Control Register 1 ADCON1 A D Control Register 2 ADCON2 REGISTER 21 1 ADCONO A D CONTROL REGISTER 0 U Unimplemented bit read as 0 0 Bit is cleared x Bit is unknown bit 7 8 Unimplemented Read as 0 t 1 2110 Channel 6 ANG 2111 Channel 7 1020 Channel 8 AN8 1002 Channel 2 AN9 1010 Channel 10 AN10 1012 Channel 11 AN11 1100 Channel 12 AN12 1121 Unimplemented 1110 Unimplemented 1111 Unimplemented bit 1 GO DONE A D Conversion Status bit When ADON 1 1 A D conversion in progress 2 A D Idle bit 0 ADON A D On bit 1 converter module is enabled 2 7 A D converter module is disabled Note 1 These channels are not implemented on 28 pn devices 2 Performing a conversion on unimplemented channels will return a floating input measurement R IMI I I I I I I I lt II I I I III lt IIIWIQOA KW KWNWQIII WO IIIQQIZIWXY YI I I IF I I IW II II WKMKIIII IIIKIG lt lt I gt I I H IzIILIOsII IIII IIZIIIA IIIIWIIISW HIIILI I IISIIQ lt I IIL BMT 2009 Mkrochip Technology Inc DS39632E page 265 PIC18F2455 2550 4455 4550 REGISTER 21 2 ADCON1 A D CONTROL REGISTER 1 RIW 0 Rot RW Raw Ren
24. defined see HardwareProfile h _ FILE endif VARIABLES udata if defined __18F14K50 defined 18F13K50 defined 18LF14K50 defined 18LF13K50 pragma udata usbram2 Zehfdefined 18F2455 defined 18F2550 defined 18F4455 defined 18F4550 defined 18F2458 defined 18F2453 defined 18F4558 defined 18F4553 udata USB VARIABLES 0x500 else pragma udata endif unsigned char ReceivedDataBuffer 64 unsigned char ToSendDataBuffer 64 pragma udata USB HANDLE USBOutHandle 0 USB HANDLE USBInHandle 0 BOOL blinkStatus Valid TRUE 81 PRIVATE PROTOTYPES void BlinkUSBStatus void BOOL Switch2IsPressed void BOOL Switch3IsPressed void static void InitializeSystem void void ProcessIO void void Userlnit void void YourHighPriorityISRCode void YourLowPriorityISRCode void USBCBSendResume void WORD VAL ReadPOT void void delay unsigned long data int 171 VECTOR REMAPPING if defined __18CXX PROGRAMMABLE WITH USB LEGACY CUSTOM CLASS BOOTLOADER if definedPROGRAMMABLE WITH USB HID BOOTLOADER define REMAPPED RESET VECTOR ADDRESS 0x1000 define REMAPPED HIGH INTERRUPT VECTOR ADDRESS 0x1008 define REMAPPED LOW INTERRUPT VECTOR ADDRESS 0x1018 elif definedPROGRAMMABLE WITH USB MCHPUSB BOOTLOADER define REMAPPED RESET VECTOR ADDRESS 0x800 define REMAPPED HI
25. loop compensated multi range current transducer using the Hall effect Insulated plastic case recognized according to UL 04 0 Advantages AC variable speed drives and servo motor drives Static converters for DC motor drives Battery supplied applications Uninterruptible Power Supplies UPS Switched Mode Power Supplies SMPS Power supplies for welding applications 06032743 fep 42 Dimensions LA 25 NP n mm 1 mm 0 0394 inch B Bottom view Right view Top view Connection Back view Number Primary current Nominal primary nominal maxmum output current connections EH Al Fai 5432 IN 1 1000 our 8783510 5432 IN 9 0 08 LN our erasw 54321 IN ou sr89 W KEN our SAN iaces Mechanical characteristics Remarks General tolerance 02mm e 1 is positive when I flows from terminals 1 2 3 4 5 to e Fastening amp connection of primary 10 pins 0 7 x 0 8 mm terminals 10 9 8 7 6 e Fastening amp connection of secondary 3 pins 1 mm Ths is a standard model For different versions supply Recommended PCB hole 1 2 mm voltages turns ratios unidirectional measurements please contact us 060327 13 LEM reserves tre carry cut modica sona zr rs Im mprowe then wthcut previo a nctos Page 22 www lem com 74 75 APPENDIX D SK40C Development Board User Manual yt iron
26. medium is very important E J 4 12 1 Type 33 4 1 Type Mini A A Figure 3 20 Types of USB port USB comes in many device classes such as Audio Communication Printer Mass Storage Human Interface Device HID and so on In this project HID classes had been implemented because HID is much easier to be programmed without having to worried about drivers the required drivers had been made inside Windows and we just have to specify the device classes by addressing the appropriate Product ID PID and Vendor ID VID in the firmware PID and VID is a 16 bit number which PC used to identify and provide the driver for the USB device USB comes in various design including Standard Mini and Micro USB connector USB only need 5 V in order to function and hence the power consumption is very small There are 4 pins in a standard USB while 5 pins in mini and micro types The data of the pins are shown in table below Table 3 2 USB Standard Pinout PIN NAME DESCRIPTION 1 Vbus 5 V 2 D Data 3 D Data 4 GND Ground 34 Table 3 3 USB Mini Micro Pinouts PIN NAME DESCRIPTION 1 Vbus 5 V 2 D Data 3 D Data 4 ID Allow the computer to differenciate between A plug and B plug 5 GND Ground 3 3 2 Software Part 3 3 2 1 Personal Computer A computer is a powerful calcu
27. pembandingan juga dijalankan dengan menggunakan meter kuasa yang ada dalam pasaran untuk mengukur kuasa sebenar alatan yang diuji Keputusan yang didapati terdapat sedikit kekurangan disebabkan kelajuan sistem adalah terhad CHAPTER TABLE OF CONTENTS TITLE THESIS STATUS CONFIRMATION FORM SUPERVISOR CONFIRMATION TITLE COVER DECLARATION DEDICATION ACKNOWLEDGEMENT ABSTRACT ABSTRAK TABLE OF CONTENTS LIST OF TABLES LIST OF FIGURES LIST OF SYMBOLS LIST OF ABBREVATION LIST OF APPENDICES INTRODUCTION 1 1 Background 1 2 Problem Statement 1 3 Objectives 1 4 Scope 1 5 Methodology and Approach 1 6 Gantt Chart of FYP 1 1 7 Gantt Chart of FYP 2 PAGE ii iii iv vi vii xi xiii xiv XV BW QU N LITERATURE REVIEW 8 2 1 Introduction 8 2 2 Power Measurement Theory 8 2 3 Conventional Power Measurement Equipment 10 2 3 1 D Arsonval Galvanometer 10 2 3 2 Electrodynamic Meter 11 2 3 3 Electrodynamometer 11 2 3 4 Electronic Wattmeter 12 2 4 Reviews from Journals 13 2 4 1 Data Acquisition System 13 METHODOLOGY 17 3 1 Introduction 17 3 2 Hardware Design 18 3 2 1 Voltage Transducer 19 3 2 2 Current Transducer 20 3 2 3 Bridge Rectifier 22 3 2 4 Power Cord and Socket 23 3 3 Interface Design 24 3 3 1 Hardware Part 24 3 3 2 3 3 1 1 Peripheral Interface Controller PIC 24 Microcontroller 3 3 1 2 Analog to Digital Converter ADC 28 in PIC18F4550 3 3 1 3 SK40C Developmen
28. s Guide Microchip Technology Inc 13 14 15 16 60 M Popa IEEE member M Marcu A S Popa 2004 A Mirocontroller based Data Acquisition System with USB Interface Electrical Electronics and Computer Engineering 2004 5 7 September Cairo Egypt IEEE 206 209 Yanpeng Wang and Mingming Fu 2010 A Portable USB Data Acquisition System 2010 WASE International Conference on Information Engineering 14 15 August Beidaihe Hebei IEEE 169 172 Bi Bo Sun Shuying and Wang Chunping 2007 Design of Data Acquisition Equipment Based on USB The Eighth International Conference on Electronic Measurement and Instruments 16 August 18 July Xian China IEEE 1 866 Dmytro Titkov Volodymyr Shvaichenko and Olena Shvaichenko Features of Interface of Microcontroller and Computer through USB 2070 TCSET Conference 23 27 February Lviv Polytechnic National University Ukraine IEEE 247 APPENDIX A PIC18F4550 Datasheet MicrRocHip PIC18F2455 2550 4455 4550 28 40 44 Pin High Performance Enhanced Flash USB Microcontrollers with nanoWatt Technology Universal Serial Bus Features USB V2 0 Compliant Low Speed 1 5 Mb s and Ful Speed 12 Mb s Supports Control Interrupt Isochronous and Bulk Transfers Supports up to 32 Endpoints 16 bidirectional 1Kbyte Dual Access RAM for USB On Chip USB Transceiver with On Chip Voltage Regulator Interface for Off Chip USB Transceiver Streami
29. slowly adapt in domestic houses One will be able to know how much the total power consumed daily and can plan their use of each electrical appliance As for the research group they can store the data collected with ease and read them anytime they want Analysis on the power profile can be made easily using the user friendly software interface The industry can also use the power measurement tools to identify the machine that consume the most reactive power and probably can increase the power factor of the machine or factory by changing or installing capacitors By using basic components such as transducers and microcontroller the data acquisition system can be easily developed and used in the measurement of power and profile of the electrical equipment The voltage current and power factor can be measured easily and stored in any computer with the software installed in it Whether it is a home desktop PC or laptop to a netbook each and every computer now have at least 2 USB ports This means that the portability of this device is very high and can be used almost everywhere without constrain from computer hardware In most power meter or wattmeter although it is can be handheld and portable but they lack data storing ability of this device developed Some of the available power meters are able to plot graph on the LCD screen however to save it 57 remains a problem for them This device solves all the weakness of the currently availab
30. suggested and information had been gathered in producing the required steps to achieve the objective of the project The project is been divided into two parts which consist of Interface and Hardware design Interface Design can be further divided into Hardware Part and Software Part Below are the steps that must be taken to complete the project 1 Choose title identify objective scope and problem statement of the project 2 Analyses the project and search for the information and materials needed 3 Learn and implement the use of PIC to interface with the PC through USB 4 Obtain results from testing with batteries and LEDs as well as switches 5 If the PIC works proceed to implement it in hardware part if the system does not work start from step 3 again Figure 1 1 Hardware Part Interface 1 Design the interface of the software 2 Write the software to initiate the data transfering from PIC to USB 3 Write software to calculate the parameters that obtained from the USB 4 Create database to store data collected from USB 5 Draw graph from the data collected and verify allthe results if not satisfy start from 2 again Figure 1 2 Software Part Interface Figure Design the circuit system in PCB Interfacing the hardware with personal computer using ports e Use the written program to collect and calculate data and parameters needed Display the results in a user frien
31. the USB cable USB traffic is NRZI encoded where 1 bits do not cause the D D signals to toggle states This initialization is not strictly necessary however For i As Integer 2 To 65 OUTBuffer 1 amp HFF Next To get the ADCValue first we send a packet with our READ POT command in it If WriteFile WriteHandleToUSBDevice OUTBuffer 65 BytesWritten IntPtr Zero Then INBuffer 0 0 Now get the response packet from the firmware If ReadFileManagedBuffer ReadHandleToUSBDevice INBuffer 65 BytesRead IntPtr Zero Then INBuffer 0 is the report ID which we don t care about INBuffer 1 is an echo back of the command see microcontroller firmware INBuffer 2 and INBuffer 3 contains the ADC value see microcontroller firmware If INBuffer 1 amp H37 Then ADCValue CType INBuffer 3 UInteger lt lt 8 INBuffer 2 Need to reformat the data from two unsigned chars into one unsigned int End If End If Else ErrorStatus Marshal GetLastWin32Error End If End If Catch ex As Exception Exceptions can occur during the read or write operations For example exceptions may occur if for instance the USB device is physically unplugged from the host while the above read write functions are executing need to do anything special in this case The application will automatically 104 re establish communications based on the global AttachedState boolean variable used i
32. to trace the bugs in it PICkit2 is used to burn the firmware into the microchip Combined with MPLAB IDE they can complete the whole microchip programming function in a quick manner 36 START INITIALIZATION 1 Initialize ports 2 Initialize button nitialize and set AD NO NO Write firmware into PIC Figure 3 21 Algorithm for programming the firmware of PIC 3 3 2 3 Visual Basic 2008 Microsoft a Visual Studio 2008 Figure 3 22 Visual Studio 2008 Logo 37 Visual Basic 2008 is a programming language in Visual Studio 2008 that allows user to design and create software of his own Visual basic is a rather easy understandable programming language and operates in Windows Visual Basic has the advantages in the development of graphical user interface GUI comparing to the traditional language such as C FORTRAN and As the world slowly adopting GUI Visual Basic is becoming more and more popular among programmers and software developers GUI provides users an easy to learn and understand interface Just by looking at the description on a button the user knows that it can be pressed and will be able to expect what to get when the button is pressed With Visual Basic a nice GUI can be made without needing to write thousands of coding A simple button can be added to the system by dragging or inserting a button control in Visual Basic interface toolbox but if we wanted to have
33. voltage rms current power factor and average power of the electrical equipment tested were obtained and shown in the interface software Lastly a power meter is used to verify the experimental results with the actual values Analysis is done later on to compare the results and comment on the effectiveness of the system 4 2 Output from Transducers Tests had been conducted to make sure that the signal that will flow in the PIC is well under 5 V This is important as the rated input of the PIC must be less than 5 V or the PIC will burn 42 4 2 1 Procedures 1 The circuit was connected as shown in Figure 3 2 2 The power supply for the transducers that is 15 V is being supplied 3 The outputs from both the transducers were connected to the oscilloscope 4 The electric kettle is then connected to the power socket and the power cord which is connected to the power outlet was switched on 5 The results from the oscilloscope were saved and recorded 6 The test was then repeated with the electric toaster 4 2 2 Result Tek Stop Pos 0 0005 SAVE REC 1 Saving Images Select 2 Folder i i Save TEEO000 JPG CH1 5 00 CH2 2 00 M 10 0rns CH1 125m Current Folder is Figure 4 1 Output from oscilloscope 1 electric kettle 43 Pos 0 0005 SAVE REC Tek Alle About Saving Images Select Folder SSSI CH1 5 00 CH2 2 00 Current Folder is 4 4 Save TEKOO01 JPG M 1
34. 0 190 100 185 Ll Secondary nominal r m s current 25 mA K Conversion ratio 1 2 3 4 5 1000 V Supply voltage 5 15 1 Current consumption 10 1 mA L R m s voltage for AC isolation test 50 Hz 1 mn 25 kV V R m s rated voltage safe separation 600 basic isolation 1700 L Accuracy Dynamic performance data x Typical accuracy LT 25 C 05 Linearity error 02 Typ Max L Offset current L 0 T 25 0 05 0 15 L Residual current 1 0 after an overload of 3 0 05 0 15 mA lo Thermal drift of OC 25 C 0 06 025 mA 25 C 70 C z0 10 0 35 mA 25 C 85 C 05 mA 4 85 12 t Response time lt 90 of Ly 1 us didt dildt accurately followed gt 50 Alus f Frequency bandwidth 1 dB DC 150 kHz General data T Ambient operating temperature 40 85 C T Ambient storage temperature 45 90 R Primary resistance per tum T 25 C 125 ma R Secondary coil resistance 70 110 n T 85 C 115 n R Isolation resistance 500 V T 25 1500 Ma m Mass 22 g Standards EN 50178 1007 Notes Pollution class 2 2 Measurement carried out after 15 mn functioning 2 The result of the coercive field of the magnetic circuit With a didt of 100 Alps LEM ese vea the ptt to carry ost rrodificatensce ta tanmcucena in oret her wrhcutpr ewzue acce 1 5 6 8 12 25 A Features Closed
35. B_INTERRUPT USBDeviceTasks endif 83 pragma interruptlow YourLowPriorityISRCode void YourLowPriorityISR Code endif DECLARATIONS pragma code Function void main void if defined __18CXX void main void else int main void endif InitializeSystem if defined USB_INTERRUPT USBDeviceAttach endif while 1 if defined USB_POLLING USBDeviceTasks endif ProcessIO j Function static void InitializeSystem void ak ak ak ak ae ale ale sk oie oF ak ale ak sk oe oe ale oi sk akk oe ak ale ak ok ole oe ale ale sk SF oe le ale ak ok ae oe ale ae ok akk oe akk oe ae sk oce eoe ake akk akk akk ale ak 3k fe ake ale 2 ake R ak static void InitializeSystem void Hif defined 18CXX amp defined PIC18F87J50 PIM 84 ADCONI 0xOF Default all pins to digital endif if definedUSE USB BUS SENSE IO tris usb bus sense INPUT PIN endif if defined USE_SELF_ POWER SENSE 10 tris self power INPUT PIN endif Userlnit USBDevicelnit
36. GH INTERRUPT VECTOR ADDRESS 0x808 define REMAPPED LOW INTERRUPT VECTOR ADDRESS 0x818 else define REMAPPED RESET VECTOR ADDRESS 0x00 define REMAPPED HIGH INTERRUPT VECTOR ADDRESS 0x08 define REMAPPED LOW INTERRUPT VECTOR ADDRESS 0x18 endif if defined PROGRAMMABLE WITH USB HID BOOTLOADER defined PROG RAMMABLE WITH USB MCHPUSB BOOTLOADER extern void _ startup void pragma code REMAPPED RESET VECTOR REMAPPED RESET VECTOR ADDRESS 82 void reset void 1 _asm goto startup endasm endif pragma code REMAPPED HIGH INTERRUPT VECTOR REMAPPED HIGH INTERRUPT VECTOR ADDRESS void Remapped High ISR void 1 asm goto YourHighPriorityISRCode endasm pragma code REMAPPED LOW INTERRUPT VECTOR REMAPPED LOW INTERRUPT VECTOR ADDRESS void Remapped Low ISR void t asm goto YourLowPriorityISRCode endasm j if definedBPROGRAMMABLE WITH USB HID BOOTLOADER defined PROG RAMMABLE WITH USB MCHPUSB BOOTLOADER pragma code HIGH INTERRUPT VECTOR 0x08 void High ISR void asm goto REMAPPED HIGH INTERRUPT VECTOR ADDRESS endasm pragma code LOW_INTERRUPT_VECTOR 0x18 void Low_ISR void asm goto REMAPPED LOW INTERRUPT VECTOR ADDRESS endasm endif end of if defined PROGRAMMABLE WITH USB HID BOOTLOADER defined PROG RAMMABLE WITH USB LEGACY CUSTOM CLASS BOOTLOADER pragma code pragma interrupt YourHighPriorityISRCode void YourHighPriorityIS RCode if defined US
37. NFO DATA Dim cbSize As Ulnteger Dim ClassGuid As Guid Dim DevInst As Ulnteger Dim Reserved As IntPtr End Structure Structure DEV BROADCAST DEVICEINTERFACE Dim dbcc size As Ulnteger Dim dbcc devicetype As Ulnteger Dim dbcc reserved As Ulnteger Dim classguid As Guid Dim dbcc name As Char End Structure DllImport setupapi dll CharSet CharSet Unicode SetLastError True gt _ Public Shared Function SetupDiGetClassDevs ByRef ClassGuid As Guid ByVal Enumerator As IntPtr ByVal hwndParent As IntPtr ByVal Flags As Ulnteger As IntPtr End Function DllImport setupapi dll CharSet CharSet Unicode SetLastError True gt _ Public Shared Function SetupDiEnumDevicelnterfaces ByVal DeviceInfoSet As IntPtr ByVal DeviceInfoData As IntPtr ByRef InterfaceClassGuid As Guid ByVal MemberIndex As Ulnteger ByRef DeviceInterfaceData As SP_DEVICE_INTERFACE DATA As Boolean End Function DllImport setupapi dll CharSet CharSet Unicode SetLastError True gt _ Public Shared Function SetupDiDestroyDevicelnfoList ByVal DeviceInfoSet As IntPtr As Boolean End Function DllImport setupapi dll CharSet CharSet Unicode SetLastError True gt _ Public Shared Function SetupDiEnumDeviceInfo ByVal DevicelnfoSet As IntPtr ByVal MemberlIndex As UlInteger ByRef DevicelnterfaceData As SP DEVINFO DATA As Boolean End Function DllImport setupapi dll CharSet CharSet Unicode SetLastError True gt _ Public Shared Funct
38. NOTES PSZ 19 16 Pind 1 07 UNIVERSITI TEKNOLOGI MALAYSIA DECLARATION OF THESIS UNDERGRADUATE PROJECT PAPER AND COPYRIGHT Author s full name LIM ZI JIE Date of birth 26 01 1987 Title POWER MEASUREMENT AND PROFILE USING PC Academic Session _ 2010 2011 declare that this thesis is classified as CONFIDENTIAL Contains confidential information under the Official Secret Act 1972 RESTRICTED Contains restricted information as specified by the organisation where research was done OPEN ACCESS agree that my thesis to be published as online open access full text acknowledged that Universiti Teknologi Malaysia reserves the right as follows The thesis is the property of Universiti Teknologi Malaysia The Library of Universiti Teknologi Malaysia has the right to make copies for the purpose of research only The Library has the right to make copies of the thesis for academic exchange Certified by SIGNATURE SIGNATURE OF SUPERVISOR 870126 08 5783 EN ALIAS BIN MOHD YUSOF NEW IC NO PASSPORT NO NAME OF SUPERVISOR Date 15 MAY 2011 Date 15 MAY 2011 If the thesis is CONFIDENTAL or RESTRICTED please attach with the letter from the organization with period and reasons for confidentiality or restriction I hereby declare that I have read this thesis and in my opinion this thesis is sufficient in terms of scope and quality for the award of the
39. P Connection of LA 25 NP Bridge rectifier Power cord and socket Schematic of the interface design PIC Microcontroller Microprocessor PIC18F4550 Pinouts of PIC18F4550 Part of the firmware SK40C development board Schematic of the connection of SK40C board Parallel port Serial port USB port xi PAGE 5 6 6 7 10 12 18 18 19 19 20 21 22 23 24 24 25 26 27 29 30 30 31 31 31 3 20 3 21 3 22 3 23 3 24 41 42 4 3 44 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 Types of USB port Algorithm for programming the firmware of PIC Visual Studio 2008 Logo The interface of the software Algorithm of software Output from oscilloscope 1 electric kettle Output from oscilloscope 1 electric toaster Output from oscilloscope 2 electric kettle Output from oscilloscope 2 electric toaster The whole system The result from the software electric kettle The result from the software electric toaster Voltage profile electric kettle Current profile electric kettle Power profile electric kettle Voltage profile electric toaster Voltage profile electric toaster Power profile electric toaster Connection of power meter Power meter kettle Power meter toaster Calculation of power factor 33 36 36 38 40 42 43 44 45 46 47 48 48 49 49 49 50 50 51 51 52 54 xii xiii LIST OF SYMBOLS Power Power Factor Volt Watt Ampere Hertz rate of change of powe
40. PEN EXISTING 0 IntPtr Zero ErrorStatusWrite Marshal GetLastWin32Error ReadHandleToUSBDevice CreateFile DevicePath GENERIC READ FILE SHARE READ Or FILE SHARE WRITE IntPtr Zero OPEN EXISTING 0 IntPtr Zero ErrorStatusRead Marshal GetLastWin32Error If ErrorStatusWrite ERROR SUCCESS And ErrorStatusRead ERROR SUCCESS Then AttachedState AttachedButBroken False StatusBox txtbx Text Device Found AttachedState TRUE Else AttachedState False AttachedButBroken True If ErrorStatus Write ERROR SUCCESS Then WriteHandleToUSBDevice Close End If 99 If ErrorStatusRead ERROR SUCCESS Then ReadHandleToUSBDevice Close End If End If End If Else If AttachedState True Then AttachedState False WriteHandleToUSBDevice Close ReadHandleToUSBDevice Close End If AttachedState False AttachedButBroken False End If End If End If MyBase WndProc m End Sub FUNCTION CheckIfPresentAndGetUSBDevicePath Private Function CheckIfPresentAndGetUSBDevicePath As Boolean Try Dim DevicelnfoTable As IntPtr IntPtr Zero Dim InterfaceDataStructure As New SP DEVICE INTERFACE DATA Dim DetailedInterfaceDataStructure As New SP DEVICE INTERFACE DETAIL DATA Dim DevInfoData As New SP DEVINFO DATA Dim InterfaceIndex As UlInteger 0 Dim dwRegType As Ulnteger 0 Dim dwRegSize As UlInteger 0 Dim dwRegSize2 As Ulnteger 0 Dim StructureSize As UInteger 0 Dim PropertyValueBuffer As In
41. a Also another PIC which contains a higher bit of ADC can be used to improve the step size to reduce error in the system Two PIC or PIC with two ADC can also improve the speed of the system This is because in this project only one ADC is available in the PIC and there are 2 parameters that is needed to collect at a time Therefore the ADC had to switch from one parameter to another to be converted into digital signal and this had wasted 50 of the time if 2 ADCs were available 59 REFERENCES 1 Sadiku and Alexander 2007 Fundamental of Electric Circuit 3 Edition New York McGraw Hill 2 http en wikipedia org wiki Jacques Ars C3 A8ne_d Arsonval 3 http en wikipedia org wiki Galvanometer 4 http en wikipedia org wiki Wattmeter 5 http physics kenyon edu EarlyApparatus Electrical Measurements Electrody namometer Electrodynamometer html 6 Wildi Theodore 2006 Electrical Machine Drives and Power Systems International Sixth Edition US Pearson Prentice Hall 7 Ibrahim Dogan 2008 Advanced PIC Microcontroller Projects in C From USB to RTOS with the PICISF Series Elsevier Ltd United States of America 8 http en wikipedia org wiki Serial port 9 Smith George 2000 Computer Interfacing Newnes Oxford 10 Bradley Julia Case 2005 Programming in Visual Basic NET McGraw Hill Irwin New York 11 MPLAB IDE Help Microchip Technology Inc 12 P Ckit2 Programmer Debugger User
42. age Chart1 DataSource Me Database1 DataSet voltageProfile End Sub 112 Private Sub VoltageProfileBindingNavigatorSaveltem Click ByVal sender As System Object ByVal e As System EventArgs Handles VoltageProfileBindingNavigatorSaveltem Click Me Validate Me VoltageProfileBindingSource EndEdit Me TableAdapterManager UpdateAll Me Database1 DataSet End Sub End Class Form 3 Imports System Data Imports System Data SqlClient Imports System Windows Forms DataVisualization Charting Public Class Form3 Private Sub CurrentProfileBindingNavigatorSaveltem_Click ByVal sender As System Object ByVal e As System EventArgs Handles CurrentProfileBindingNavigatorSaveltem Click Me Validate Me CurrentProfileBindingSource EndEdit Me TableAdapterManager UpdateAll Me Database1 DataSet End Sub Private Sub Form3_Load ByVal sender As System Object ByVal e As System EventArgs Handles MyBase Load TODO This line of code loads data into the DatabaselDataSet currentProfile table You can move or remove it as needed Me CurrentProfileTableA dapter Fill Me Database1 DataSet currentProfile Dim random As New Random Dim ChartAreal As ChartArea New ChartArea Dim Legendl As Legend New Legend Dim Seriesl As Series New Series Dim Chart New Chart Me Controls Add Chart1 ChartAreal Name ChartAreal Chart1 ChartAreas A dd ChartAreal 113 Legend1 Name Legend1 Chart1 Legends Add Legend1 Chartl Lo
43. allel port also known as printer port and it uses IEEE 1284 standard 9 USB port is a newer version of the standard port used in a computer USB ports are smaller and are able to transfer data way much faster than parallel and serial port could It is also able to supply the required power to the USB devices without needing external supply 10 i USB In today s computers and laptops USB can be found at any corners of the powerful calculator Compared to 10 years ago which uses Serial and Parallel ports as the interfacing medium for the external devices USB is way much faster and smaller With the continuous development of the USB by many leading companies in computer and electronics more and more advanced version of USB specification had been released From the original USB 1 0 specification which carries transfer rate of 1 5 Mbit s to transfer rate up to 5 Gbit s in USB 3 0 the speed of the USB is faster day by day Compared to serial port that has data transfer rate of maximum 115200 bit s and parallel port of 16Mbit s USB is obviously many times faster than these conventional ports Besides USB is also smaller and lighter compared to its predecessor and can fit more ports in a single PC Due to the various reasons above USB had replaced serial and parallel ports in this modern days where speed and size matters Therefore to make sure that this device made can fit all the computers that might be used by the users USB as the interfacing
44. amp ToSendDataBuffer 0 64 delay 1 j else if i 2 1 mInitPOT2 w ReadPOT ToSendDataBuffer 0 0x37 ToSendDataBuffer 1 w v 0 Measured analog voltage LSB ToSendDataBuffer 2 w v 1 Measured analog voltage MSB USBInHandle HIDTxPacket HID EP BYTE amp ToSendDataBuffer 0 64 86 delay 1 break USBOutHandle HIDRxPacket HID EP BYTE amp ReceivedDataBuffer 64 end ProcessIO FE Tk sk ale ale ale ak ae oF ale ak oi sk ak oe ak ale ak sk ak oe le ale sk SF oe ak ak 3k 3 ak ae e ale akk SR ak ale 2 9k aK Ke ae Function WORD VAL ReadPOT void akak ak ake ak ak ak ak ak ak ake e ake akk akk akk ak ake ake ake akk ak K WORD VAL ReadPOT void WORD VAL w ifdefined 18CXX if 1 2 1 mInitPOT1 ADCONDObits GO 1 Start AD conversion while ADCONoObits NOT DONE Wait for conversion w v 0 ADRESL w v 1 ADRESH i delay 1 else if i 2 1 mInitPOT2 ADCONDObits GO 1 Start AD conversion while ADCONObits NOT_DONE Wait for conversion w v 0 ADRESL w v 1 ADRESH 4 87 delay 1 i endif return w FE Tk sk ale i sk ak ae le oR ak ak ak ae ale oie sk ak oe ak ale ak sk oe oie ole oie sk oie oe le ale sk ok o ie ale ae sk oe oe ale ak sk oie oe ie ale 9k oko fe SR ak ak 3k a fe ake ak R R R R Function void USBCBSuspend void
45. ary current with negligible phase change normally less than one degree In this case we can use it to monitor and measure the current in a line isolated from the primary circuit 6 A current transducer is used to measure and convert the input current from single phase supply so that PIC will be able to read the values LA 25 NP is the model of the current transducer used in this project It is like the twin brother of LV 25 P which carries almost identical features and advantages with it It is also a Hall Effect transducer with galvanic isolation between the primary circuit and secondary circuit The primary nominal rms current is 25 A while the secondary nominal rms current is 25 mA with conversion ratio of 1 2 3 4 5 1000 Depending on the conversion ratio the primary nominal rms current ranges from 5 to 25 A suit different needs of the users Because to obtain accurate results from the current transducer the input current must first be determined first so that the conversion ratio and hence the primary input current will be in the range of the primary nominal current To choose different setting for the conversion ratio the connections of the IN and OUT pins of the transducer must follow the recommended connections in the datasheet provided IN pins which consist of pin 1 to 5 is connected to the primary circuit while the OUT pins from pin 6 to 10 is connected to the equipment to be measured Just like its twin brother LA 25 NP also requires
46. ast as a microprocessor but it contains all the components needed to be able to function on its own The microcontroller have build in RAM ROM a number of I O ports Timer USB ports Serial ports depending on the type and model Microcontroller can be found everywhere in our electronics devices such as washing machine video games DVD player refrigerators and in most of the more intelligent machines This is because the size of the microcontroller itself and the flexibility to program it to do the job we wanted In a microcontroller there are many types of memories ROM is one of the basic memories in a microcontroller Read only memory as its name suggest can only be read and the data inside the memory is fixed The memory is being programmed during manufactured and cannot be deleted even power is removed from the ROM Therefore the users can only use the sole function provided by the manufacturer 26 Random Access Memory RAM is a volatile memory that allows data to be read and write continuously A volatile memory does not retain its data when power supply is removed from it RAM comes in different size Electrical Erasable Programmable Read Only Memory EEPROM is yet another type of memory in a microcontroller It is a non volatile memory and the data can be erased and reprogram using external programming devices EEPROM is slow memory and only used to save basic configuration information and programming functions in i
47. ation sector need to know the power produced by their generators while for transmission and distribution sector they need to know how much electrical power is needed to install suitable transformer to give constant and uninterrupted electricity Until today many kinds of power measuring method and equipment had been invented From the conventional analog wattmeter using D arsonval meter and electrodynamometer to advanced digital wattmeter power measurement technique is improving day by day The improvement of the power measurement is scaled by the increasing ability of giving accurate result in a short time Availability and handling difficulties also give impacts to the quality of the power measuring device As the technology in science and industry is flourishing more advance and fast power measurement equipment is needed in the industry and research area In many kinds of applications data need to be collected and stored for further uses such as research and analysis Common method of storing data is not efficient and involved a lot of handwriting which waste a lot of time and resources 1 2 Problem Statement Although there was a lot of advanced power measurement equipment available in the market however the trade off of these sensitive and powerful tools is the cost To build sensitive and powerful equipment it needs better components and they are more expensive hence increasing the total cost of power measuring Besides that so
48. bject ByVal e As System EventArgs Handles VoltageProfileBindingNavigatorSaveltem Click Me Validate Me VoltageProfileBindingSource EndEdit Me TableAdapterManager UpdateAll Me Database1 DataSet End Sub Private Sub Timerl_Tick ByVal sender As System Object ByVal e As System EventArgs Handles Timer1 Tick Dim span As TimeSpan DateTime Now Subtract startTime Labell Text span Minutes ToString amp amp _ span Seconds ToString amp amp span Milliseconds Mytime span TotalMilliseconds MyMiliseconds Mytime 1000 End Sub Private Sub voltagetxtbox TextChanged ByVal sender As System Object ByVal e As System EventArgs Handles voltagetxtbox TextChanged powerID powerID 1 If voltagetxtbox Text 1024 Then voltageID voltageID 1 volttextbox Text voltagetxtbox Text 1024 5 200 2 5 39000 System Math Sqrt 2 1 1 voltageValue volttextbox Text If voltageValue gt highestvoltage Then highestvoltage voltageValue 106 highestvoltageTime MyMiliseconds2 End If voltagetime Text highestvoltageTime highestVoltageTxt Text highestvoltage voltagearrValue voltageArrindex voltageValue voltagearrMilisecondl voltageArrindex MyMiliseconds voltagearrMilisecond2 voltageArrindex MyMiliseconds2 voltageArrindex voltageArrindex 1 Else currentID currentID 1 currtextbox Text voltagetxtbox Text 1024 1024 5 150 500 System Math Sqrt 2
49. cation New System Drawing Point 13 13 Chart1 Name Chart Series1l ChartArea ChartAreal Seriesl Legend Legend1 Seriesl Name Series1 Series1 ChartType SeriesChartType Spline Chart1 Series Add Series1 Chart1 Size New System Drawing Size 1000 800 Chart1 TabIndex 0 Chartl Text Chart1 Chart1 Series Series1 X ValueMember timeGraph Chart1 Series Series1 Y ValueMembers current Chart1 DataSource Me Databasel DataSet currentProfile End Sub End Class Form 4 Imports System Data Imports System Data SqlClient Imports System Windows Forms DataVisualization Charting Public Class Form4 Private Sub Form4_Load ByVal sender As System Object ByVal e As System EventArgs Handles MyBase Load TODO This line of code loads data into the DatabaselDataSet powerProfile table You can move or remove it as needed Me PowerProfileTableAdapter Fill Me DatabaselDataSet powerProfile Dim ChartAreal As ChartArea New ChartArea Dim Legendl As Legend New Legend Dim Seriesl As Series New Series Dim Chart New Chart Me Controls Add Chart1 ChartAreal Name ChartAreal Chart1 ChartAreas A dd ChartAreal Legendl Name Legend1 114 Chart1 Legends Add Legend1 Chartl Location New System Drawing Point 13 13 Chart1 Name Chart1 1 ChartAreal Seriesl Legend Legend1 Series Name Series1 Series1 ChartType SeriesChartType S
50. ct ByVal e As System EventArgs Handles CurrentTextBox TextChanged End Sub Private Sub VoltageTextBox TextChanged ByVal sender As System Object ByVal e As System EventArgs Handles VoltageTextBox TextChanged 109 End Sub Private Sub Stopwatch Load ByVal sender As System Object ByVal e As System EventArgs Handles MyBase Load startTime DateTime Now startTime2 DateTime Now Timer1 Start Timer2 Start End Sub Private Sub highestVoltageTxt TextChanged ByVal sender As System Object ByVal e As System EventArgs Handles highestVoltageTxt TextChanged Dim radian As Double radian highestcurrentTime highestvoltageTime 0 02 360 Math PI 180 powerFactor System Math Cos radian powerFactortxt text powerFactor End Sub Private Sub highestCurrenttxt TextChanged ByVal sender As System Object ByVal e As System EventArgs Handles highestCurrenttxt TextChanged Dim radian As Double radian highestcurrentTime highestvoltageTime 0 02 360 Math PI 180 powerFactor System Math Cos radian powerFactortxt Text powerFactor End Sub Private Sub powerFactortxt TextChanged ByVal sender As System Object ByVal e As System EventArgs Handles powerFactortxt TextChanged powerValue highestvoltage highestcurrent powerFactor powerText Text powerValue End Sub Private Sub Timer2 Tick ByVal sender As System Object ByVal e As System EventArgs Handles Timer2 Tick Dim span2 As TimeSpan Dat
51. d USBCBlnitEP void 89 USBEnableEndpoint HID EP USB IN ENABLED USB OUT ENABLED USB _ HANDSHAKE ENABLED USB DISALLOW SETUP USBOutHandle HIDRxPacket HID EP BYTE amp ReceivedDataBuffer 64 j Function void USBCBSendResume void void USBCBSendResume void static WORD delay count if USBGetRemoteWakeupStatus TRUE Verify that the USB bus is in fact suspended before we send remote wakeup signalling if USBIsBusSuspended TRUE USBMaskInterrupts Clock switch to settings consistent with normal USB operation USBCBWakeFromSuspend USBSuspendControl 0 USBBuslsSuspended FALSE So we don t execute this code again until a new suspend condition is detected Section 7 1 7 7 of the USB 2 0 specifications indicates a USB device must continuously see 5ms of idle on the bus before it sends remote wakeup signalling One way to be certain that this parameter gets met is to add a 2ms blocking delay here 2ms plus at least 3ms from bus idle to USBIsBusSuspended TRUE yeilds Sms total delay since start of idle delay_count 3600U do delay_count while delay_count Now drive the resume K state signalling onto the USB bus USBResumeControl 1 Start RESUME signaling delay count 1800U Set RESUME line for 1 13 ms do
52. dly program interface elf the result shown does not satisfy the objectives redo the steps according to whichever part that is defected 1 3 Hardware Design 1 6 Gantt Chart of FYP 1 Decide title of project Define objective Define scope Searching for information Drafting methodology Analysis of components Analysis of equipment tu ga pu LILL PIG Learning popu 7 programming software Preparing for presentation Preparing FYP1 report Figure 1 4 Gantt Chart FYP 1 1 7 Gantt Chart of FYP 2 Learn and PIC Develop Mur ZILI L IZILI software for interfacing and power calculation Preparing A components for hardware implementation Design the EIE hardware circuit in protoboard and test to get the result Build the circuit system Obtain a few 12 sample result and finalized Complete the 7 Figure 1 5 Gantt Chart FYP 2 CHAPTER 2 LITERATURE REVIEW 2 1 Introduction This chapter discusses about the theory and concept of power measurement different power measurement equipment and techniques developed throughout the history and core components of ADC The work related to this project will also be discuss in the further part of this chapter to give a brief idea how the whole system will work and an early preview of the expected result 2 2 Power Mea
53. e Dim MyMiliseconds2 As Double Dim index As Integer Dim voltageValue As Double Dim num As Integer Dim voltageID As Integer Dim currentID As Integer Dim powerID As integer Dim idcounter As Integer Dim idcounterCurr As Integer Dim idcounterPow As Integer Dim randomTime As Double Dim randomValue As Double Dim ispause As Integer Dim MyMilisecondsA As Double Dim MyMilisecondsB As Double Dim intloop As Integer current array 96 Dim currentValue 10000000 As Double Dim currentMiliSecond1 10000000 As Double Dim currentMiliSecond2 10000000 As Double Dim CurrentArrindex As Integer voltage array Dim voltagearrValue 10000000 As Double Dim voltagearrMilisecond1 10000000 As Double Dim voltagearrMilisecond2 10000000 As Double Dim voltageArrindex As Integer power array Dim powerarrValue 10000000 As Double Dim powerarrMilisecond1 10000000 As Double Dim powerarrMilisecond2 10000000 As Double Dim powerArrindex As Integer Dim voltarrayIndex As Integer Dim currarrayIndex As Integer Dim highestvoltage As Double Dim highestvoltageTime As Double Dim highestcurrentTime As Double Dim highestcurrent As Double Dim startTime As DateTime Dim startTime2 As DateTime Dim powerFactor As Double Dim radian As Double Dim powerValue As Double Dim isTimerReset As Integer FUNCTION Forml Load Private Sub Form1 Load ByVal sender As Object ByVal e As System EventArgs Handles Me Load Me PowerProfileTableAdapter Fi
54. e SPI all 4 modes and PC Master and Slave modes 10 Bit Up to 13 Channel Analog to Digital Converter A D module with Programmable Acquisition Time Dual Analog Comparators with Input Multiplexing Special Microcontroller Features C Compiler Optimized Architecture with Optional Extended Instruction Set 100 000 Erase Write Cycle Enhanced Flash Program Memory Typical 1 000 000 Erase Write Cycle Data EEPROM Memory Typical Flash Data EEPROM Retention gt 40 Years Self Programmable under Software Control Priority Levels for Interrupts 8x8 Single Cycle Hardware Multiplier Extended Watchdog Timer WDT Programmable period from 41 ms to 131s Programmable Code Protection Single Supply 5V In Circuit Serial Programming ICSP via Two Pins In Circuit Debug ICD via Two Pins Optional Dedicated ICD ICSP Port 44 pin TOFP package only Wide Operating Voltage Range 2 0V to 5 5V 2009 Microchip Technology Inc 61 62 PIC18F2455 2550 4455 4550 Pin Diagrams OSC2 CLKO RAS 10 RcaToao t ack Rc miosuccralNgde 12 1 2 3 4 5 6 7 8 s 1 12 13 4 in RC1 TIOGUCCe2l ll oE ROZCCPUPIA Vus RDOSPPO RDUSPPI Boa ta Note 1 RB3isthe altemate pin for CCP2 mu amp piexing 0539632 2 LRU RN ERS SER we RETMBIZPGO RE amp RKBIZ PGC REZSXBIUPGM REA4 ANTUKBIO RB3YANSCCPZI VEO REZ ANB NT2 VMO RBI ANTO NTI SCK SCL
55. e programmed in C languages before it contains any functions C language is a common programming language learnt in Electrical Engineering courses After being programmed the ports 28 that are already activated will be able to receive input and provide the output required The pins that are involved in this project are shown in the table below Table 3 1 Pins used in project Pin Name Pin No Description MCLR 1 Reset when high RAO 2 Analog input of V voltage RAI 3 Analog input of V current OSCI 13 Connect to oscillator OSC2 14 Connect to oscillator GND 31 Ground of the whole system RBO SWI 33 The PIC will operate when button is pressed D 24 USB data D 23 USB data 3 3 1 2 Analog to Digital Converter ADC in PIC18F4550 The integrated ADC in the PIC is 10 bit in size and has a total of 13 channels There are 5 registers in the ADC which is A D Control Register 0 ADCONO A D Control Register I ADCONI A D Control Register 2 ADCON2 A D Result High Register ADRESH and A D Result Low Register ADRESL The first control register ADCONO is used to control the operation of the A D module while ADCONI works to set the functions of the port pins ADCON is the register that configures the acquisition time and A D clock source These registers are extremely important and must be configures properly or the ADC will not work as needed Both the ADRESH and ADRESL store the result of the
56. e that is interface design and hardware design Interface design phase focus on designing a workable circuit to connect the hardware part to the interface part and then create a software as the interface for the whole circuit system Therefore the Interface Design can be split up into two parts which is Hardware Part and Software Part Hardware Part of the Interface Design is responsible for designing a circuit using PIC and Bridge Rectifier to collect data from the Hardware Design and to convert the analog signal to digital signal so that the computer can read the data transferred It also filters out the negative phase of the sinusoidal signal which the PIC cannot receive The Software Part is to create an interface using Visual Basic to do all the calculations of parameter after received from the PIC and then display and save the data and results collected Hardware Design phase is to create a circuit system using voltage and current transducer as their main components in to convert the high voltage and current into the range where the PIC could handle Below is the block diagram of the whole circuit system 18 Low T High a i analog Digital analog input output input input f Voltage and seis Current 9 Bridge Rectifier gt PIC m USB PC ge Transducer phase supply Figure 3 1 Block diagram of the whole circuit system 32 Hardware Design
57. eTime Now Subtract startTime2 Label2 Text span2 Minutes ToString amp amp _ span2 Seconds ToString amp amp span2 Milliseconds Mytime2 span2 TotalMilliseconds MyMiliseconds2 Mytime2 1000 110 End Sub Private Sub PictureBox3 Click ByVal sender As System Object ByVal e As System EventArgs Handles PictureBox3 Click Form4 Show End Sub Private Sub Buttonl_Click ByVal sender As System Object ByVal e As System EventArgs Handles Button1 Click ispause 1 VHHHHHHHHBHBHHHHHHHHHHHBHBE voltage insert value IBRUBRHERHIHHHRHBHRHBRHER HH HHBHBRHER EEE TE PETE TET A EEE RE HH RH RHHH E For intloopInsertvolt As Integer 0 To voltageArrindex 1 If voltagearrMilisecond2 intloopInsertvolt gt 0 Then Me VoltageProfileTableAdapter Insert intloopInsertvolt voltagearrMilisecondl intloopInsertvolt voltagearrValue intloopInsertvolt voltagearrMilisecond2 intloopInsertvolt End If If powerarrMilisecond2 intloopInsertvolt gt 0 Then Me PowerProfileTableAdapter Insert intloopInsertvolt powerarrMilisecondl intloopInsertvolt powerarrValue intloopInsertvolt End If If currentMiliSecond2 intloopInsertvolt gt 0 Then Me CurrentProfileTableA dapter Insert intloopInsertvolt currentMiliSecondl intloopInsertvolt currentValue intloopInsertvolt currentMiliSecond2 intloopInsertvolt End If Next intloopInsertvolt fill the data to data grid view Me VoltagePro
58. eo RD7 SPP7 P1D Vss O RD6 SPP6 P1C OSC1 CLKI 7 a 4 RDS SPPS P1B OSC2 ICLKO RA6 lt RD4 SPP4 RC0 T1OSO T13CKI 0 RCTIRXIDT SDO RC1 T1OSU CCP2U UOE D 25 RC6 TX CK RC2 CCP1 P1A 24 J RCS D VP VusB 9 7 23 RC4 D VM RDO SPPO L 22 J RD3 SPP3 RD1 SPP1 0 21 RD2 SPP2 Figure 3 13 Pinouts of PIC18F4550 PIC18F4550 is the core of the interfacing design or perhaps the whole project The microcontroller act like the brain of the whole system receiving all the data from the hardware circuit and then process the data before sending it to the computer The reason why PIC18F4550 is chosen is because of several reasons a USB support which means that we no longer need to use a RS 232 converter if we wanted to connect it to the PC b Being able to delete and rewrite the firmware easily lasted for up to one million time c Bootloader can be use to allow programming of the PIC need not have to constantly removing it to the programming socket and put the PIC back to the circuit system after programmed d There is also a build in 10 bit 13 channel analog to digital converter ADC 1n the PIC so that the users do not need to have an external ADC to convert the analog signal to digital signal e Multiple input and output ports in a single microchip Unlike regular microchip a PIC microcontroller must first b
59. erate the voltage transducer it needs a supply voltage of 12 to 15 V connected to the and pins The voltage transducer carries the responsibility to convert the high voltage from the supply which will be around 230 V rms and to a lower value of voltage according to our needs In this case the range of voltage that is needed is within 0 to 5 V peak to peak In order to measure a voltage a current that is proportional to the measured voltage must be passed through an external resistor R1 which must be selected to fit the range of voltage that we need The resistor is then connected in series with the primary circuit of the transducer Then a secondary resistor R2 must be connected in series with the secondary circuit through pin M of the voltage transducer to obtain the converted voltage The output voltage will be the voltage across the resistor R2 due to the linear relationship between voltage and current at constant resistance In order to acquire best accuracy from the voltage transducer the voltage to be measured must first be identified This is because the nearer the primary input current to the primary nominal current which is 10 mA the higher the accuracy 3 2 2 Current Transducer Figure 3 5 Current Transducer LA 25 NP 2 IN 1 5 OUT gt 6 10 Figure 3 6 Connection of LA 25 NP Current transformer transducer is a transformer that converts the primary current proportionally to second
60. es 15V z5 08 Linearity error lt 02 Excelent accuracy Typ Maxi Very good linearity L Offset current L 0 T 25 015 mA e Low thermal drift L Temperature variation of 0 C 25 C 0 06 025 mA e Low response time 25 C 70 C 0 10 0 35 mA e High bandwidth t Response to 90 of step 40 us rennen Low disturbance in common mode General data I Applications E Ambient operating temperature 0 70 C T Ambient storage temperature 25 85 C 3 R Primary coil resistance T 70 C 250 a ren R Secondary resistance T 70 C 110 N Static converters for DC motor drives m Mass 22 9 Battery supplied applications Standards EN 50178 1987 Uninterruptible Power Supplies UPS Power supplies for welding applications P W x J 7 Application domain Note 25 kn UR constant produced by the resistance and inductance of the primary circuit e Industrial DENE ais ii LE im LEM enm venthe rigttic cacy cadorna cn ifa rand caos norde ic merve mem notos www lem com Voltage Transducer LV 25 P Isolation characteristics V Rms voltage for AC isolation test 50 Hz 1 min 252 kV Q Impulse withstand voltage 12 50 us 18 kV Min dCp Creepage distance 18 5 mm dCl Clearance distance 18 5 mm CTI Comparative Tracking Index Group 175 Note Between primary and secondary Application examples Accordi
61. es Select Wu No Neo N 22 Nes Folder Save TEK0002 IPG CH1 5 00 CH2 2 00 M 10 0ms CH1 Z 125mVv Current Folder is 4 4 Figure 4 4 Output from oscilloscope 2 electric toaster The results are almost identical to the test shown in the previous test as shown below Table 4 2 Result of second test ELECTRICAL RMS RMS POWER AVERAGE APPLIANCES VOLTAGE VOLTAGE FACTOR POWER VOTAGE CURRENT Electric Kettle 2 93 V 2 61 V 1 0 1988 3 W Electric Toaster 2 85 V 0 88 V 1 0 652 08 W 4 4 Output of the Whole Circuit System When all the outputs were tested to be able to fit into microcontroller the entire circuit system is connected by combining the Hardware Design and Interface Design together 46 Figure 4 5 The whole system 4 4 1 Procedure 1 2 3 4 5 6 7 8 9 The circuit was connected as shown in Figure 3 2 and Figure 3 9 The power supply for the transducers that is 15 V is being supplied by batteries The outputs from bridge rectifier were plugged into port and A1 of PIC18F4550 mounted on SK40C board The USB cable that is connecting the SK40C board was then plugged in into the PC The electric kettle was also plugged into the power socket and the power plug was switch on after every connection was completed After the power had been switched on the interface software was run and the push button on the SK40C board was pushed to start transfer
62. et is used The life wire will be connected to the input of the voltage and current transducer while the neutral wire is connected with only the voltage transducer This will form a parallel connection to the voltage transducer so that the voltage of the load can be measured The output of the current transducer will connect to the power socket to form series connection with the life wire to obtain the current flows in the load 24 3 3 Interface Design SW1 SW PUSHBUTTON ae RAO GND V voltage bridge PIC18F4550 rectifier T RAL Crystal Oscillator V current C oscl USB PE 4 L 2 i o bridge rectifier Figure 3 9 Schematic of the interface design 3 3 1 Hardware Part 3 3 1 1 Peripheral Interface Controller PIC Microcontroller Figure 3 10 PIC Microcontroller 25 Figure 3 11 Microprocessor PIC microcontroller can be considered as a category of the microprocessor Microprocessor such as Pentium 4 Core 2 Duo and now i7 is very high in performance with extremely fast processing speed Microprocessor is a standalone microchip and it cannot do anything on its own It requires additional peripheral such as Random Access Memory RAM Input and Output Ports I O ports Read Only Memory ROM and others to function as a system Unlike the microprocessor although a microcontroller is not as f
63. fileTableA dapter Fill Me Database1 DataSet voltageProfile Me CurrentProfileTableA dapter Fill Me Database1 DataSet currentProfile Me PowerProfileTableAdapter Fill Me DatabaselDataSet powerProfile MessageBox Show Insert finish End Sub End Class 111 Form2 Imports System Data Imports System Data SqlClient Imports System Windows Forms DataVisualization Charting Public Class Form2 Private Sub Form2_Load ByVal sender As System Object ByVal e As System EventArgs Handles MyBase Load TODO This line of code loads data into the Databasel DataSet voltageProfile table You can move or remove it as needed Me VoltageProfileTableA dapter Fill Me Database1 DataSet voltageProfile Dim random As New Random Dim ChartAreal As ChartArea New ChartArea Dim Legend As Legend New Legend Dim Series As Series New Series Dim Chart New Chart Me Controls Add Chart1 ChartAreal Name ChartAreal Chart1 ChartAreas Add ChartArea1 Legend1 Name Legend Chart1 Legends Add Legend1 Chartl Location New System Drawing Point 13 13 Chart1 Name Chart Seriesl ChartArea ChartAreal Seriesl Legend Legend Seriesl Name Series Series1 ChartType SeriesChartType Spline Chartl Series Add Series1 Chartl Size New System Drawing Size 1000 800 Chart1 TabIndex 0 Chart1 Text Chart1 Chart1 Series Series1 X ValueMember timeGraph Chart1 Series Series 1 Y ValueMembers volt
64. hole 1 2 mm Instructions for use of the voltage transducer model LV 25 P Primary resistor R the transducers optimum accuracy Is obtained at the nominal primary current As far as possible R should be calculated so that he nominal voltage 30 be measured corresponds to a primary of 10 mA Example Voltage to be measured V 250 V aR 25k0 25 W L 10mA Accuracy 0 8 of V T 25 D R SORN 125W L SMA Accuracy 16 of Va T 25 C Operating range recommended taking Into account me resistance of primary windings which must remain low compared to R In order to keeo thermal deviation as low as and Isolation ts transducer Is sultabie for measuring nominal voltages from 10 500 V m EIS A LEM eaa venttu rigttis cary cutmodificationa ite Taradsces n order tz improve fem wi astzrncr notos www lem com APPENDIX C 73 LA 25 NP Current Transducer Datasheet Current Transducer LA 25 NP For the electronic measurement of currents DC AC pulsed mixed with a galvanic isolation between the primary circuit high power and the secondary circuit electronic circuit a YEARB et Electrical data Lu Primary nominal r m s current 25 At L Primary current measuring range 0 2 At R Measuring resistance T 70 C T 85 C R R R R with 15 V 25 pa 100 320 100 315 n 36 aa 10
65. icode SetLastError True gt Public Shared Function CreateFile _ ByVal FileName As String _ ByVal dwDesiredAccess As Ulnteger _ ByVal dwShareMode As Ulnteger _ ByVal IpSecurityAttributes As IntPtr _ ByVal dwCreationDisposition As UInteger _ ByVal dwFlagsAndAttributes As UInteger _ ByVal hTemplateFile As IntPtr As SafeFileHandle End Function Dilimport kernel32 dll CharSet CharSet Unicode SetLastError True gt Public Shared Function WriteFile _ ByVal hFile As SafeFileHandle _ ByVal Buffer As Byte _ ByVal nNumberOfBytesToWrite As UInteger _ ByRef IpNumberOfBytesWritten As UInteger _ 95 ByVal IpOverlapped As IntPtr As Boolean End Function Dilimport kernel32 dll CharSet CharSet Unicode SetLastError True gt Public Shared Function ReadFile ByVal hFile As SafeFileHandle _ ByVal IpBuffer As IntPtr _ ByVal nNumberOfBytesToWrite As UInteger _ ByRef IpNumberOfBytesRead As Ulnteger _ ByVal IpOverlapped As IntPtr As Boolean End Function Dim InterfaceClassGuid As New Guid 4D1E55B2 F16F 11CF 88CB 001111000030 Dim AttachedState As Boolean Dim AttachedButBroken As Boolean False Dim DetailedInterfaceDataStructure As New SP DEVICE INTERFACE DETAIL DATA Dim ReadHandleToUSBDevice As SafeFileHandle Dim WriteHandleToUSBDevice As SafeFileHandle Dim DevicePath As String Dim ADCValue As Integer 0 Dim Mytime As Double Dim MyMiliseconds As Double Dim Mytime2 As Doubl
66. ion SetupDiGetDeviceRegistryProperty _ ByVal DeviceInfoSet As IntPtr _ ByRef DeviceInfoData As SP DEVINFO DATA ByVal dwProperty As Ulnteger _ 94 ByRef PropertyRegDataType As Ulnteger _ ByVal PropertyBuffer As IntPtr _ ByVal PropertyBufferSize As Ulnteger _ ByRef RequiredSize As Ulnteger As Boolean End Function DllImport setupapi dll CharSet CharSet Unicode SetLastError True gt _ Public Shared Function SetupDiGetDevicelnterfaceDetail _ ByVal DevicelnfoSet As IntPtr _ ByRef DevicelnterfaceData As SP DEVICE INTERFACE DATA _ ByVal DevicelnterfaceDetailData As IntPtr _ ByVal DevicelnterfaceDetailDataSize As Ulnteger _ ByRef RequiredSize As Ulnteger _ ByVal DevicelnfoData As IntPtr As Boolean End Function DllImport setupapi dll CharSet CharSet Unicode SetLastError True gt _ Public Shared Function SetupDiGetDevicelnterfaceDetail _ ByVal DeviceInfoSet As IntPtr _ ByRef DevicelnterfaceData As SP DEVICE INTERFACE DATA _ ByVal DevicelnterfaceDetailData As IntPtr _ ByVal DevicelnterfaceDetailDataSize As Ulnteger _ ByVal RequiredSize As IntPtr _ ByVal DevicelnfoData As IntPtr As Boolean End Function lt DIlImport user32 dll CharSet CharSet Unicode SetLastError True gt _ Public Shared Function RegisterDeviceNotification _ ByVal hRecipient As IntPtr _ ByVal NotificationFilter As IntPtr _ ByVal Flags As Ulnteger As IntPtr End Function DilImport kernel32 dll CharSet CharSet Un
67. ip Technology Inc 67 PIC18F2455 2550 4455 4550 REGISTER 21 3 ADCON2 A D CONTROL REGISTER 2 U R IW 0 R W 0 R W 0 R W D R W D R W D ADM 2 acar acam ADCS2 ADCS ADCSO bit 7 bit 0 R Readable bit W Writable bit U Unimplemented bit read as 0 n Value at POR 1 Bit is set 0 Bit is cleared x Bit is unknown bit 7 ADFM A D Result Format Select bit 1 Right justified 2 Left justified bit 6 Unimplemented Read as 0 bit 5 3 ACQT2 ACQTO A D Acquisition Time Select bits 111 20 Tao 110 16 Tao 101 12 0 8 Tao 011 Tao 0 4 Tao 1 2 202 0 bit 2 0 ADCS2 ADCS0 A D Conversion Clock Select bits 111 Fre clock derived from A D RC oscillator 110 64 101 16 100 211 Fre clock derived from A D RC oscillator 2 32 Note 1 Ifthe A D Fre clock source is selected delay of one Tcv instruction cycle 5 added before the A D clock starts This allows the 3L EEE instruction to be executed before starting a conversion 2009 Microchip Technology Inc DS39632E page 257 68 PIC18F2455 2550 4455 4550 21 1 A D Acquisition Requirements For the A D converter to meet its specified accuracy the charge holding capacitor Choto must be allowed to fully charge to the input channel voltage level The analog input model is shown in Figure 21 3 The source impedance Rs and the interna
68. is higher than the one captured before it will be logged into area 5 and 6 The time logged that is area 7 and 8 will be the time obtained when the system gets the highest voltage and current logged in the area 5 and 6 The power factor of the system at area 3 is calculated using the time logged in 5 and 6 The average power at area 4 will then be calculated by the system by using all the parameters above 40 The working algorithm of the software is shown below C Stan p Software starts and SW1 is pressed NO Collect data Done Press Restart button Press Insert Data Is a message box popup said insert complete Wait for message box popup gt Analyse Data lt YES NO Press delete to clear database Figure 3 24 Algorithm of software CHAPTER 4 RESULT AND DISCUSSION 4 1 Introduction In this project a few tests had been done to verify and obtain the results from the system developed An electric kettle and an electric toaster had been used to test the effectiveness of the device Firstly the output voltage and current from the transducers with the electrical appliances connected will be measured and captured by the oscilloscope along with its waveforms Then the outputs will be run through the bridge rectifier and the results were saved again Later the whole circuit system will be implemented and the rms
69. ists However nowadays we use alternating supply in domestic as well as most transmission and distribution sector Therefore in terms of AC power the instantaneous power at anytime varies and average power is used to measure the power through a load Average power can be express as the average of the instantaneous power over one period of time The mathematical expression of T average power AR p t dt Vl cos 0 0j where T is the period of a cycle V is the maximum voltage Im is the maximum current and 0 0j is the phase difference of voltage and current The cosine of phase difference can also be stated as the power factor of the system 1 6 10 2 3 Conventional Power Measurement Equipment 2 3 1 D Arsonval Galvanometer Figure 2 1 D Arsonval meter at the University of Toronto D Arsonval Galvanometer was invented by two Frenchmen in the early 1880s who were Jacques D Arsonval 1851 1940 and Marcel Deprez 1843 1918 Jacques was born in La Porcherie worked as a professor of experimental medicine as well as the director of a biological physics laboratory Marcel on the other hand was born in Aillant sur Milleron and he was an electrical engineer Both of them had developed the galvanometer with permanent magnet and moving coils which is suspended by flat ribbon of wires At the lower end of the coil the connection is supplied by a light and helical spring This spring is used to give the restoring
70. l sampling Switch Rss impedance directly affect the required to charge the capacitor CHoLo The sampling switch Rss impedance varies over the device voltage Voo The source impedance affects the offset voltage at the analog input due to pin leakage current The maximum recommended impedance for analog sources is 2 5 kn After the analog input channel is selected changed the channel must be sampled for at least the minimum acquisition time before starting conversion Note When the conversion is started the holding capacitor is disconnected from the EQUATION 21 1 ACQUISITION TIME Amplifier Settling Time Holding Capacitor Charging Time Temperature Coefficient Tame Tc Toorr EQUATION 21 2 A D MINIMUM CHARGING TIME To calculate the minimum acquisition time Equaton 21 1 may be used This equation assumes that 1 2 LSb error is used 1024 steps for the A D The 1 2 LSb error is the maximum error allowed for the A D to meet its specified resolution Example 21 3 shows the calculation of the minimum required acquisibon tme Taca This calculation based the following application system assumptions 25pF Rs 25kn Conversion Error lt 1 2LSb 5V Rs2 2kn Temperature 85 system max VHoLD VrEr Vrer 2048 1 el Tc Cnouoifuc Rss Rs or Tc Cuutp Ric Rss Rs 01172048 EQUATION 21 3 CALCULATING THE MINIMUM REQUIRED ACQUISITION TIME Tame Tc
71. lator with the ability to process data in a short interval Nowadays computer is very important equipment to not only working people but also students Computer in 21 century has a lot of functions and helps not only in processing data with ease and speed but also support a lot of software Computer had become a part of our life and developing a device that can communicate with it is a relief to all the users 3 3 2 2 MPLAB IDE and PICkit2 MPLAB IDE is called an Integrated Development Environment IDE as it allows users to develop code for microcontroller in a single software environment It contains a compiler software and hardware debugger editor project manager linker and execution engines This software is developed by Microchip Technology and is used for the programming of the microcontroller 11 35 PICkit2 programmer application is also produced by Microchip Technology It is used for writing the firmware written in MPLAB IDE into the EEPROM and Flash microcontroller 12 With both the software it is sufficient to activate most of the microcontroller devices available in the market MPLAB IDE uses C language and it is a very fundamental language in programming By having this PIC programming software everything the users need in all in one packet Users can check the memory requirement stability of the firmware and direct compilation after finished programmed If there is any error MPLAB IDE also provides a debugger
72. le Me CurrentProfileTableA dapter Fill Me Database1 DataSet currentProfile Me PowerProfileTableA dapter Fill Me Database1 DataSet powerProfile reset id voltageID 0 currentID 0 powerID 0 highestcurrent 0 highestvoltage 0 Array Clear voltagearrValue 0 voltageArrindex Array Clear voltagearrMilisecondl 0 voltageArrindex Array Clear voltagearrMilisecond2 0 voltageArrindex Array Clear currentValue 0 CurrentArrindex Array Clear currentMiliSecond1 0 CurrentArrindex Array Clear currentMiliSecond2 0 CurrentArrindex Array Clear powerarrValue 0 powerArrindex Array Clear powerarrMilisecond2 0 powerArrindex voltageArrindex 0 108 powerArrindex 0 CurrentArrindex 0 End Sub Private Sub PictureBox1 Click ByVal sender As System Object ByVal e As System EventArgs Handles PictureBox1 Click Form2 Show End Sub Private Sub PictureBox2_Click ByVal sender As System Object ByVal e As System EventArgs Handles PictureBox2 Click Form3 Show End Sub Private Sub Button3 Click ByVal sender As System Object ByVal e As System EventArgs Handles Button3 Click If Timer2 Enabled Then Button3 Text Restart ispause 1 Timerl Stop Timer2 Stop Else startTime DateTime Now startTime2 DateTime Now Me Text Click to Stop Button3 Text Stop ispause 0 Timerl Start Timer2 Start End If End Sub Private Sub CurrentTextBox TextChanged ByVal sender As System Obje
73. le power measurement devices and contains almost as strong measuring power as them The software developed used to calculate and store data using GUI from Visual Basic Language is very easy to be used Everything they can see on the interface is clearly shown and can be use directly Long manual books or training is not required when using the software and the device Hence it is user friendly and acceptable even to someone with little knowledge about electronics and electric they need is just to know how to read and understand the description on the interface In overall most of the objectives had been successfully achieved The accuracy and the speed of the system to obtain data is the only concern in this project This might be due to the programming software used 15 slower and affect the ability of the data acquisition process 5 2 Recommendation In this project the speed of the system is an important criterion in the system The accuracy of the system to measure the power and power factor depend heavily on the speed of the data logged in the software This is because to obtain power in the system the calculations of peak voltage and current are needed and these parameters have to be as close to actual peak values as possible This means that the system needs to get more data in a cycle so that the peak current and voltage can be obtained more easily and increase the efficiency and accuracy of the system Regarding the power fact
74. ll Me DatabaselDataSet powerProfile Me CurrentProfileTableAdapter Fill Me Databasel DataSet currentProfile Me VoltageProfileTableA dapter Fill Me Database1 DataSet voltageProfile idcounter Me Databasel DataSet voltageProfile Count idcounterCurr Me Databasel DataSet currentProfile Count idcounterPow Me Databasel DataSet powerProfile Count highestvoltage 0 voltageID idcounter currentID idcounterCurr powerID idcounterPow 97 Dim DeviceBroadcastHeader As New DEV BROADCAST DEVICEINTERFACE DeviceBroadcastHeader dbcc devicetype DBT DEVTYP DEVICEINTERFACE DeviceBroadcastHeader dbcc size Marshal SizeOf DeviceBroadcastHeader DeviceBroadcastHeader dbcc reserved 0 Reserved says not to use DeviceBroadcastHeader dbcc classguid InterfaceClassGuid Dim pDeviceBroadcastHeader As IntPtr IntPtr Zero pDeviceBroadcastHeader Marshal AllocHGlobal Marshal SizeOf DeviceBroadcastHeader Marshal StructureToPtr DeviceBroadcastHeader pDeviceBroadcastHeader False RegisterDeviceNotification Me Handle pDeviceBroadcastHeader DEVICE NOTIFY WINDOW HANDLE Marshal FreeHGlobal pDeviceBroadcastHeader If CheckIfPresentAndGetUSBDevicePath Then Dim ErrorStatusWrite As UInteger Dim ErrorStatusRead As UlInteger WriteHandleToUSBDevice CreateFile DevicePath GENERIC_WRITE FILE SHARE READ Or FILE SHARE WRITE IntPtr Zero OPEN EXISTING 0 IntPtr Zero ErrorStatusWrite Marshal GetLastWin32Error ReadHandleToUSBDe
75. me of the equipment needs a complicated connection or a lot wires and cable connect to the load in order to measure the power and shows the results A more complex procedure and careful steps as well as tests and precaution need to be made to ensure that the system is well designed This had brought inconvenience to the user in his her power measuring process In most of the time we need not only to acquire the values for the power measured but also to store the result and data from time to time Data storing is very important for further references and analysis for further usage Conventional method requires us to copy data one by one using handwriting and this process are slow and not efficient Besides it also limits us in terms of the interval that we can acquire data which means that we are unable to store the data fast enough and affect our work In any way data storing using conventional methods are troublesome and sometimes frustrating Other than that for constant reading and to check the condition of a load the profile of the load needs to be monitored in a clear diagram and must be able to do it in short time Except some sophisticated machines there are rarely cheaper and reliable equipment for doing so 1 3 Objectives The main objective of this project is to design and create a device to measure the power through a load by using personal computer PC as measurement tool and to monitor the power profile The objectives of
76. n conjunction with the WM DEVICECHANGE messages to dyanmically respond to Plug and Play V USB connection events End Try End While End Sub FUNCTION ReadFileManagedBuffer Private Function ReadFileManagedBuffer ByVal hFile As SafeFileHandle ByRef INBuffer As Byte ByVal nNumberOfBytesToRead As Ulnteger ByRef IpNumberOfBytesRead As Ulnteger ByVal IpOverlapped As IntPtr As Boolean Dim pINBuffer As IntPtr IntPtr Zero Try pINBuffer Marshal AllocHGlobal CType nNumberOfBytesToRead Integer Allocate some unmanged RAM for the receive data buffer If ReadFile hFile pINBuffer nNumberOfBytesToRead IpNumberOfB ytesRead IpOverlapped Then Marshal Copy pINBuffer INBuffer 0 IpNumberOfBytesRead Copy over the data from unmanged memory into the managed byte INBuffer Marshal FreeHGlobal pINBuffer Return True Else Marshal FreeHGlobal pINBuffer Return False End If Catch ex As Exception If pINBuffer lt gt IntPtr Zero Then Marshal FreeHGlobal pINBuffer Return False End If End Try End Function 105 Private Sub progressBarl Click ByVal sender As System Object ByVal e As System EventArgs End Sub Private Sub Labell_Click ByVal sender As System Object ByVal e As System EventArgs End Sub Private Sub StatusBox Ibl Click ByVal sender As System Object ByVal e As System EventArgs Handles StatusBox lbl Click End Sub Private Sub VoltageProfileBindingNavigatorSaveltem Click ByVal sender As System O
77. nerate electromagnetic field around the coil when current flows through it and the strength of the magnetic field is proportional to the line current and in phase with it Because of such an arrangement the deflection of the needle is proportional to the both the current and voltage leading to the equation P VI in a DC circuit Whereas in an AC circuit the deflection of the needle is proportional to the average instantaneous product of voltage and current and hence the real power that we needed is measured 4 2 3 3 Electrodynamometer Electrodynamometer was invented by Werner von Siemens 1816 1892 in the early 1880s Siemens was an electrical businessman as well as an inventor Siemens had used the principal that was published by Wilhelm Weber 1804 1891 which states that when the same current passes through two concentric coils placed at 12 right angles to each other the resulting torque depends on the square of the current in his paper in 1848 In Siemens invention there were stationary coils which made of a few turns of heavy wires and a rotating coil which made of many turns of fine wires The stationary coil is connected in series with the circuit while the rotating coil is connected across the load A multiplier resistance is connected in series with the load to allow measurement of voltage to be done Therefore the power on a load is measured by taking the current passing through the coils times with the voltage drop in the l
78. ng Paralle Port SPP for USB streaming transfers 40 44 pin devices only Power Managed Modes Run CPU on Peripherals on Idle CPU off Peripherals on Sleep CPU off Peripherals off Idle mode Currents Down to 5 8 A Typical Sleep mode Currents Down to 0 1 uA Typical Timer Oscillator 1 1 uA Typical 32 kHz 2V Watchdog Timer 2 1 A Typical Two Speed Oscillator Start up Flexible Oscillator Structure Four Crystal modes including High Precision PLL for USB Two External Clock modes Up to 48 MHz Internal Oscillator Block Buser selectable frequencies from 31 kHz to 8 MHz User tunable to compensate for frequency drift Secondary Oscillator using Timer 32 kHz Dual Oscilator Options allow Microcontroller and USB module to Run at Different Clock Speeds Fai Safe Clock Monitor Allows for safe shutdown any clock stops Peripheral Highlights High Current Sink Source 25 mA 25 mA Three External Interrupts Four Timer modules Timer to Timer3 Up to 2 Capture Compare PWM CCP modules Capture is 16 bit max resolution 5 2 ns Tcv 16 Compare is 16 bit max resolution 83 3 ns Tcv PWM output PWM resolution is 1 to 10 bit Enhanced Capture Compare PWM ECCP module Multiple output modes Selectable polarity Programmable dead time Auto shutdown and auto restart Enhanced USART module LIN bus support Master Synchronous Serial Port MSSP module Supporting 3 Wir
79. ng this project I am also grateful to have the support from my family and friends Their encouragement and constructive comments had always gives me strength to continue to improve the system of my project and fix the weaknesses of the system by all means My deepest appreciation goes to Miss Bong Mei Fern for her help in certain part of the system development She always supports me and stand by my side when I faced fatal problem in the middle of the development Without her help I would not gone this far Lastly I felt grateful to have you all with me thanks again for all the help and support that I needed ABSTRACT Power measurement is no longer an unfamiliar phrase among people and industries No matter they are researchers electric companies factories or common people they are doing power measurement at all time Researchers need to do some analysis on the field of electrical power electrical companies need to optimize their generators and calculate the tariff factories need to monitor their power usage and power factor and common people need power measurement to know how many power that had been used throughout the year This project aims to create a device to measure the power of equipment and to monitor the power profile for a long time This power measurement device created is based on the data acquisition concept using PIC microcontroller and USB interface Software is developed to control the device and to show the resul
80. ng to EN 50178 and IEC 61010 1 standards and following conditions one sion mov mv Safety This transducer must be used in electric electronsc equipment with respect to applicable standards and safety requrements in accordance with the manufacturer s operating instructions AN Caution risk of electrical shock When operating the transducer certain parts of the module can hazardous voltage eg primary busbar power supply Ignoring this warning can lead to injury and or cause serious damage This transducer is a built in device whose conducting parts must be inaccessible after installation A protective housing or additional shield could be used Main supply must be able to be disconnected 070427 16 LEN reserves the rightto carry ost rod fica tona fa treneducers in order to improve ther wihzut p o notice www Jem com 72 Dimensions LV 25 in mm 1 mm 0 0394 inch ce Bottom view Right view Top view 4403 m Q swiss mads ea Cd 3 Connection R1 HT Ve M Is ov vc Back view Mechanical characteristics Remarks General tolerance 02 mm is positive when V applied on terminal HT Fastening amp connection of primary 2 pns This is a standard model For different versions supply 0 835 x 0 835 mm voltages turns ratos unidirectional measurements Fastening amp connection of secondary 3 pins 2 1 mm please contact us Recommended PCB
81. oad 5 2 3 4 Electronic Wattmeter e BBBBs Figure 2 2 One of the latest wattmeter available An electronic wattmeter is a small digital power measurement tool which is capable of measuring power with ease and accurately as it display real digital values 4 13 2 4 Reviews from Journals 2 4 1 Data Acquisition System In today we are required to monitor a lot of system so that to know the parameters the effects of a change done to a system to know the reliability and constrain of a system to do analysis of certain control system and much more For examples a soft drink production factory need to control the rate of flow of the water into the cans and a thermal power plant needs to control the heat of the boiler so that the power plant can effectively generate the required amount of power To be able to do these a data monitoring and acquisition system must be made to obtain the data and to do analysis on the data logged somewhere whether handwritten or directly copied into computers or other equipment Most of the data that we obtain directly from the external world is in analog form As digital system is rapidly developed many of these analog data have to be converted into digital form in various ways One of the easiest ways is to use an analog to digital converter However this is still not enough Most of the data acquisition system contains its own unique circuit or machine which every output must be shown in
82. og to digital converter and it received the output signals from the sensors The ADC will then convert the signal into digital form with the command from the host via microcontroller Later the microcontroller will activate the conversion process of ADC and received the digital signal from the ADC After that it will transmit the data through PDIUSBDI2 to the computer The software 15 created using LabVIEW software developed by National Instruments will act to store and display the data collected LabVIEW provide a graphical programming environment mostly needed by the engineers and scientists who want to do measurement graphical plotting and analysis using the data from the external devices LabVIEW can also interact with other development software such as Matlab and C Languages The advantages of this method used are the GUI of the interface and data presentation is good and the information can be stored for further analysis 14 Almost similar data acquisition system based on USB also been developed by Bi Bo Sun Shuyung and Wang Chunping in the year 2007 and was published in The Eighth International Conference on Electronic Measurement and Instruments Using USB protocol allows intercommunication between peripheral devices and plug and play services Plug and play services provide the users to easily connect or disconnect the device without problem of damaging the USB device or installing before used Various speeds can be chosen including
83. oller Please refer to USB interface section The power LED will light ON when the USB cable is connected Created by Cytron Technologies Sdn Bhd All Rights Reserved 6 T 78 APPENDIX E Firmware of PIC18F4550 Hardware profile ifndef HARDWARE PROFILE PICDEM FSUSB H define HARDWARE PROFILE PICDEM FSUSB define tris self power TRISAbits TRISA2 if defined USE SELF POWER SENSE IO define self power PORTAbits RA2 else define self_power 1 endif define USE USB BUS SENSE IO define tris usb bus sense TRISAbits TRISAT if definedUSE USB BUS SENSE IO define USB BUS SENSE PORTAbits RAI else define USB_BUS_SENSE 1 endif define PROGRAMMABLE WITH USB HID BOOTLOADER define DEMO BOARD PICDEM FS USB define PICDEM FS USB define CLOCK FREQ 48000000 SWITCH define mInitAllSwitches TRISBbits TRISBO 1 define button PORTBbits RBO define mInitPOT1 TRISA 0b00000001 ADCON0 0b00000001 ADCON 1 0x00 ADCON2 0b10010 100 define mInitPOT2 TRISA 0b00000010 ADCON0 0b00000101 ADCON1 0x00 ADCON2 0b 10010 100 79 USB external transceiver define tris usb TRISBbits TRISB3 Output define tris usb vmo TRISBbits TRISB2 Output define tris usb rcv TRISAbits TRISA4 Input define tris usb vp TRISCbits TRISC5 Input define tris usb vm TRISCbits TRISC4 Input define tris usb oe TRISCbits TRISC1 Output define tris usb suspnd TRISAbits TRISA3
84. or the method used is also relies on the accuracy of how fast the system finds the highest voltage and current Power factor calculation can differ much even the error of the system is low This is because the frequency of the system is 50 Hz and hence in one cycle the time is only 0 02 s Difference in 0 01 s will cause 50 of error in the system and that is why the speed of the system to acquire data utmost important 58 In order to make the system more stable and accurate the speed of the system to obtain data from must be increased To improve the speed of the system a faster programming language such as C or can be used so that the running of the code in the software is faster and hence the speed of the system Besides that an external memory can also be used as the temporary storage for the system to store the data from the PIC first After all the data had been collected in the external memory the data will only be sent to the PC using USB to reduce the time to transfer and process data Other than that another method such as Zero Crossing to calculate the power factor can also be used so that the phase difference between voltage and current can be easily found This is because the method used in this project is to find the highest point in the sinusoidal waveform of voltage and current This method can be hard to obtain the accurate highest point especially there is a short time interval between the acquisitions of 2 dat
85. pline Chart1 Series Add Series1 Chart1 Size New System Drawing Size 1000 800 Chart1 TabIndex 0 Chart1 Text Chart1 Chart1 Series Series1 X ValueMember time Chart1 Series Series 1 Y ValueMembers power Chart1 DataSource Me Database1 DataSet powerProfile End Sub Private Sub PowerProfileBindingNavigatorSaveltem_Click ByVal sender As System Object ByVal e As System EventArgs Handles PowerProfileBindingNavigatorSaveltem Click Me Validate Me PowerProfileBindingSource EndEdit Me TableAdapterManager UpdateAll Me Database1 DataSet End Sub End Class
86. quipment being measured The profile of all the parameters will also be plotted automatically by the software itself Users can easily interact with the software through clearly labeled push buttons on the interface of the software p Figure 3 23 The interface of the software 39 Table 3 4 The description of the software interface No Description 1 Instantaneous voltage 2 Instantaneous current 3 Power factor 4 Average power 5 Highest rms voltage logged 6 Highest rms current logged 7 Time logged when the highest rms voltage occurs 8 Time logged when the highest rms voltage occurs 9 Push buttons to show the profile of voltage current and power 10 Insert data button is used when we want to save the result in database delete button will clear all the database and Restart button stop and reset the timer 11 Detect whether the circuit is connected to the USB port of computer When the system runs the data from both transducers will be sent to the PIC and then converted into digital form The digital signals will then be sent to the computer via USB cable and then capture by the software interface The software will get the data alternately and then calculate and shows in area 1 and 2 As the data keep flowing into the system the software will continue to capture the values of the instantaneous voltage and current If the value of instantaneous voltage and current captured
87. r rate of change of charge Coulomb Joule Current rate of change of time maximum voltage maximum current PIC USB AC DC ADC RAM ROM I O ports EEPROM RS 232 IEEE GUI IDE HID PID VID RMS xiv LIST OF ABBREVIATIONS Peripheral Interface Controller Universal Serial Bus Alternate current Direct current Analog to digital converter Random Access Memory Read Only Memory Input output ports Electrical Erasable Programmable Read Only Memory Recommended Standard 232 Institute of Electrical and Electronics Engineers Graphical User Interface Integrated Development Environment Human Interface Device Product ID Vendor ID Root mean square APPENDIX A moa LIST OF APPENDICES TITLE PIC18F4550 Datasheet LV 25 P Voltage Transducer Datasheet LA 25 NP Current Transducer Datasheet SK40C Development Board User Manual Firmware of PIC18F4550 Coding of Software Interface XV PAGE 61 69 70 72 73 74 75 77 78 91 92 114 CHAPTER 1 INTRODUCTION 1 1 Background Power measurement is important from research area to domestic houses It is used in all kinds of field especially in the electrical engineering Power measurement is useful in measuring the power consumption of a house or factory thereby knowing its rate of power consumption each day or monthly and hence be able to make plans to conserve electric usage or to know the power used by each machine As for the electrical supplier the gener
88. r 236 7 1 9 0 989 444 5 3l 4 5 Result from Power Meter To verify the result of the circuit system implemented in this project the power meter was used to measure the actual power of the equipment being measured The power meter was connected as shown in the schematic below power Socket power meter Current clipper port Figure 4 14 Connection of power meter Figure 4 15 Power meter kettle 52 Figure 4 16 Power meter toaster Table 4 4 Result of power meter ELECTRICAL RMS RMS CURRENT POWER AVERAGE APPLIANCES VOLTAGE FACTOR POWER Electric Kettle 241 V 92V 1 0 2220W Electric Toaster 244 V 2 9 V 1 0 709 W 4 6 Discussion From the first test on the ability of voltage and current transducer the waveform and values that were obtained are almost as accurate The output waveforms show the sinusoidal waveform with frequency of 50 Hz and different amplitudes Hence the test had proven that the transducers successfully convert the high voltage and current from supply in within 5 V In the second phase the outputs from the transducers were fed into the bridge rectifiers The result shows that the negative side of the sinusoidal waveform had been successfully filtered out with a small drop in voltages This happens because the rectifier requires a small forward voltage before it conduct electric 53 When the whole system were being ran output result that i
89. ring data to PC Data were collected by the software and then calculated by the program The results were clearly shown in the interface of the software The test was repeated by replacing the electric kettle with electric toaster 47 4 4 2 Result mm DAD 6 sn in lt 0 jJoo n X H s 2060 445954 Device Found AttachedState TRUE Figure 4 6 The result from the software electric kettle ic HID PnP Demo AEA Figure 4 8 Voltage profile electric kettle 49 2 M X dd I i Figure 4 11 Voltage profile electric toaster Figure 4 13 Power profile electric toaster Table 4 3 Result of system test 50 ELECTRICAL RMS RMS POWER AVERAGE APPLIANCES VOLTAGE CURRENT FACTOR POWER Electric Kettle 231 96 V 8 9 V 0 9981 2060 W Electric Toaste
90. s shown gives almost accurate values comparing to the actual values measured by using power meter There is about 10 of error when compared with the values obtained from power meter with the one using the circuit system when tested with electric kettle On the other hand the test with the electric toaster yielded larger error about 37 In order to acquire more accurate result the system needs to find the actual highest rms voltage and current when operating Because the speed limitation of the system it needs to operate for a longer time in order to become more accurate Also from the comparison between the different ratings of power of electrical appliances because the minimum nominal value of current is 5 A hence the power of the equipment being measured must have at least 1 kW to obtain the best accuracy from the system The error of the accuracy increases as the value of current of the input decreases From the case of electric kettle it clearly shows that the current of the input will heavily affect the accuracy of the system From calculations the nominal value of the input current of the electric toaster should be around 3 A and this value is well below the rating of the nominal current and hence the accuracy suffers Regarding the power factor of the system because the time used to calculate the power factor is depending on the ability of system to obtain the highest rms values of both the voltage and current hence it will take
91. stem Runtime InteropServices Imports System Threading Imports System Data SqlClient Public Class Form1 Dim DeviceIDToFind As String Vid 04d8 amp Pid 003f Const DIGCF PRESENT As Ulnteger amp H2 Const DIGCF DEVICEINTERFACE As UlInteger amp H10 Const FILE ATTRIBUTE NORMAL As Short amp H80 Const INVALID HANDLE VALUE As Short 1 Const GENERIC READ As Ulnteger amp H80000000 Const GENERIC WRITE As Ulnteger amp H40000000 Const CREATE NEW As Ulnteger amp 1 Const CREATE ALWAYS As Ulnteger amp H2 Const OPEN EXISTING As Ulnteger amp H3 Const FILE SHARE READ As Ulnteger amp 1 Const FILE SHARE WRITE As Ulnteger amp H2 Const WM DEVICECHANGE As Ulnteger amp H219 Const DBT DEVICEARRIVAL As Ulnteger amp H8000 Const DEVICEREMOVEPENDING As Ulnteger amp H8003 Const DBT DEVICEREMOVECOMPLETE As Ulnteger amp H8004 Const CONFIGCHANGED As Ulnteger amp H18 Const DBT DEVTYP DEVICEINTERFACE As Ulnteger amp H5 Const DEVICE NOTIFY WINDOW HANDLE As Ulnteger amp HO Const ERROR SUCCESS As Ulnteger amp Const ERROR NO MORE ITEMS As Ulnteger amp H103 Const SPDRP HARDWAREID As Ulnteger amp 1 Structure SP DEVICE INTERFACE DATA Dim cbSize As Ulnteger Dim InterfaceClassGuid As Guid Dim Flags As Ulnteger Dim Reserved As IntPtr End Structure 93 Structure SP DEVICE INTERFACE DETAIL DATA Dim cbSize As Ulnteger Dim DevicePath As Char End Structure Structure SP DEVI
92. surement Theory To know how to measure the power we must first know its parameter that forms it Voltage or potential difference is the energy required to move a unit charge through an element measured in volts V By mathematically derivation d Vab d where V is the voltage between two points a and b w is the energy in joule J and q is the charge in coulombs C In this term the voltage also can be interpret as the work that is required to move a unit charge from point a to point b in an electric circuit given the potential at point b is lower than the potential at point b Current is the rate of change of charge measured in amperes A The relationship between charge q current I and time t can be express in mathematical equation as follow d bs Ts m where 115 the current in ampere q is charge in coulomb and t is time in second Given 1 ampere is equal to 1 coulomb second There are two types of currents one is which the current remains constant at all time that we called direct current DC and another one is called alternate current AC where its current changes sinusoidally with time Power is the time rate of expending or absorbing energy measured in watts W The relationship of power with voltage and current is given by P mi vi where P is power in watt W w is energy in joule and t is time in second For direct current and voltage the above expression for power pers
93. t A supply voltage must be applied to a microcontroller for it to operate 5 V is mostly used in the microcontroller with some tolerance The microcontroller contains its own instruction set The users must use the instruction set available in order to program the microcontroller Not all the instruction set for every microcontroller is the same Therefore the users must study what is available for them before starting to write the program in it There are a number of Input and Output ports I O ports available for users to program and use them Some of the ports are analog or digital or both depending on the initiation done in the firmware They can be input port or otherwise output port Users no longer needed to worry about the insufficient of input or output ports and buy another microcontroller to cater with ports that is fixed on the type 7 i PICISF4550 Figure 3 12 PIC18F4550 27 MCLR VPP RE3 1 RB7 KBIS PGD RAD ANO I RB6 KBI2 PGC RA1 AN1 O 3 RBS KBI1 PGM RA2IAN2 VnEF CVREF 4 RB4 AN11 KBIO CSSPP RA3 AN3 VREF e 5 RB3 ANSICCP2UD PO RAA TOCKI CT1OUT RCV 6 RB2 ANS INT2 VMO RAS AN4 SS HLVDINIC2OUT 7 RB1 AN10 INT1 SCK SCL REDIANSICKISPP 8 RBO AN12 INTO FLTO SDUSDA RET ANG CK2SPP 9 o RE2 ANT OESPP 7 i Mss gt
94. t 1 data latches 1 Alternate method 1 to clear output 1 data latches 1 Configure A D 1 for digital inputs 1 Configure comparators 1 for digital input 1 Value used to 1 initialize data 1 direction 1 Set RA lt 3 0 gt as inputs 1 RA 5 4 as outputs 2009 Microchip Technology Inc DS39632E page 113 PIC18F2455 2550 4455 4550 17 0 UNIVERSAL SERIAL BUS USB This section describes the detais of the USB peripheral Because of the very specific nature of the module knowledge of USB is expected Some high level USB information is provided in Section 17 10 Overview of USB only for application design reference Designers are encouraged to refer to the official specification published by the USB Imple menters Forum USB IF for the latest information USB specification Revision 2 0 s the most current specification at the time of publication of this document 17 1 Overview of the USB Peripheral The PIC1B8FX455 X550 device family contains a full speed and low speed compatible USB Serial Inter face Engine SIE that allows fast communication between any USB host and the PIC microcontroller FIGURE 17 1 PIC18FX455 X550 Family www 4 USB PERIPHERAL AND OPTIONS The SIE can be interfaced directly to the USB utilizing the internal transceiver or it can be connected through an external transceiver An intemal 3 3V regulator is also available to power the internal transceiver in 5V applicatons
95. t Board 30 3 3 1 4 Ports 31 Software Part 34 3 3 2 Personal Computer 34 3 3 2 2 MPLAB IDE and PICkit2 34 3 3 2 3 Visual Basic 2008 36 viii 4 RESULT AND DISCUSSION 4 1 Introduction 4 2 Output from Transducers 4 2 Procedures 4 2 2 Result 4 3 Output from Transducer through Bridge Rectifier 4 3 Procedures 4 3 2 Result 4 4 Output of the Whole Circuit System 4 4 Procedures 4 4 2 Result 4 5 Result from Power Meter 4 6 Discussion 5 CONCLUSION AND RECOMMENDATIONS 5 1 Conclusion 5 2 Recommendations REFERENCES APPENDICES A F 41 41 41 42 43 43 44 44 45 46 47 51 52 56 56 57 59 61 114 TABLE NO 3 1 3 2 3 3 3 4 4 1 4 2 4 3 4 4 LIST OF TABLES TITLE Pins used in project USB Standard Pinout USB Mini Micro Pinouts The description of the software interface Result of first test Result of second test Result of system test Result of power meter PAGE 28 33 34 39 43 45 50 52 FIGURE NO 1 1 1 2 1 3 1 4 1 5 2 1 2 2 3 1 3 2 3 3 3 4 3 5 3 6 327 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 LIST OF FIGURES TITLE Hardware Part Interface Software Part Interface Hardware Design Gantt Chart FYP 1 Gantt Chart FYP 2 D Arsonval meter at the University of Toronto One of the latest wattmeter available Block diagram of the whole circuit system Schematic of the hardware design Voltage Transducer LV 25 P Connection of LV 25 P Current Transducer LA 25 N
96. t is created using Visual Basic Language The system had been run and tested part by part before the whole system is being combined and implemented A benchmark is also done using the commercial power meter to measure the actual power of the equipment used in the tests and then compare with the result obtained from the system developed The result shows that there is some error due to the system speed is not fast enough to cater the requirement to produce an accurate result vi ABSTRAK Pengukuran kuasa bukanlah suatu ungkapan yang baru kepada manusia dan industri Tak kira mereka adalah ahli kajian kompani elektrik kilang kilang mahupun rakyat biasa mereka turut membuat pengukuran kuasa pada setiap masa Ahli kajian perlu membuat analisis dalam bidang electrik kompani elektrik perlu mempertingkatkan keupayaan penjana dan membuat pengiraan tariff kilang kilang perlu memantau kegunaan kuasa dan faktor kuasa dan rakyat biasa perlu mengetahui berapa kuasa yang telah digunakan dalam masa setahun Projek ini bertujuan untuk menghasilkan suatu alat untuk mengukur kuasa sesuatu alatan dan memantau profil kuasa untuk jangka masa yang panjang Alat pengukuran kuasa ini dicipta berdasarkan konsep pengambilalihan data menggunakan PIC dan USB Perisian dihasilkan untuk mengawal alatan dan memaparkan keputusan dengan menggunakan bahasa Visual Basic Sistem ini telah dioperasikan dan diuji bahagian demi bahagian sebelum seluruh sistem ini digabungkan Suatu
97. tPtr IntPtr Zero Dim MatchFound As Boolean False Dim ErrorStatus As Ulnteger 0 Dim LoopCounter As Ulnteger 0 Dim DeviceIDToFind As String Vid 04d8 amp Pid 003f DevicelnfoTable SetupDiGetClassDevs InterfaceClassGuid IntPtr Zero IntPtr Zero DIGCF PRESENT Or DIGCF DEVICEINTERFACE If DeviceInfoTable lt gt IntPtr Zero Then While True InterfaceDataStructure cbSize Marshal SizeOf InterfaceDataStructure 100 If SetupDiEnumDevicelnterfaces DevicelnfoTable IntPtr Zero InterfaceClassGuid InterfaceIndex InterfaceDataStructure Then ErrorStatus Marshal GetLastWin32Error If ErrorStatus ERROR NO MORE ITEMS SetupDiDestroyDeviceInfoList DeviceInfoTable Return False End If DevInfoData cbSize Marshal SizeOf DevInfoData SetupDiEnumDevicelnfo DevicelnfoTable InterfaceIndex DevInfoData SetupDiGetDeviceRegistryProperty DeviceInfoTable DevInfoData SPDRP HARDWAREID dwRegType IntPtr Zero 0 dwRegSize PropertyValueBuffer Marshal AllocHGlobal CType dwRegsSize IntPtr SetupDiGetDeviceRegistryProperty DeviceInfoTable DevInfoData SPDRP HARDWAREID dwRegType Property ValueBuffer dwRegSize dwRegSize2 ErrorStatus Marshal GetLastWin32Error Dim DeviceIDFromRegistry As String DeviceIDFromRegistry Marshal PtrToStringUni PropertyValueBuffer Marshal FreeHGlobal PropertyV alueBuffer DeviceIDFromRegistry DeviceIDFromRegistry ToLowerlInvariant DeviceIDToFind DeviceIDToFind ToLowerlnvariant
98. tains some basic components needed to do programming such as reset button connector for programmer power indicator LED USB connector programmable push buttons and others All the interface and program must be written and construct by the users themselves By using the development board many soldering work can be eliminated 3l and users no longer requires to plug in and out the PIC for programming in all it helps new microcontroller users to develop their project faster and more comfortable Figure shows the connection made on the SK40C development board The output voltages from the rectifiers were fed into port RAO and RAI The crystal oscillator is connected on the port OSC1 and OSC2 The USB port is already connected well in the board and hence the port can be plugged in directly using the suitable pair of the USB head 3 3 1 4 Ports Figure 3 17 Parallel port Figure 3 18 Serial port Figure 3 19 USB port Ports are use to link the circuitry and the computer system together They act as the medium for communication link Ports such as serial and parallel port will be chosen to achieve the purpose mentioned Serial ports allow information transferring and receiving one bit at a time Serial port uses RS232 standard as its protocol 8 32 On the other hand parallel interfacing which uses parallel port as communication and transmission link is able to transmit and receive bits of data at the same time Par
99. the project also includes measuring the rms voltage rms current power factor and average power of the electrical appliances to create a software used to calculate and show results of the measured parameters to use PIC and USB port as the interfacing devices as well as to plot the voltage current and power profile of the load Computer is a very powerful calculator and is able to receive data and the process it in lightning speed By using computer data can also be easily stored without much effort These data can be called at anytime and the result can be monitor with just a few clicks on the keyboard An accurate graph can be plot instantly and show on the screen with ease 1 4 Scope The scope of the project includes Write a program using programming language Visual Basic to calculate and show data such as voltage current power factor and power through load and its power profile Design a circuit to convert the single phase analog voltage and current to digital signal using PIC and transducers Create a circuit to allow load or equipments to connect to the circuit system to be measured Implement the designed circuit system into hardware and interfacing the hardware to computer using USB ports The system is for domestic uses which the voltage rating is 230V and 5 lt lt 30 15 Methodology and Approach The overview of the methodology and approach of the project is shown below Careful planning and steps had been
100. time for the power factor to be stable and accurate too 54 0 06 Figure 4 17 Calculation of power factor Let say if the peak voltage occurs at point A at 0 005 sec and the peak current occurs at point B at 0 006 sec The power factor will be Time voltage peak Time current peak PF cos 0 02 x 360 22 0 006 arn ET X 01 i ES 0 02 But because the system cannot capture the peak current at a short interval after it capture the peak voltage hence it might capture the peak current at another cycle Then we do the calculations when the time captured at point C or at point D where the current is at peak value at time 0 026 sec and 0 046 sec respectively while the time of the peak voltage is maintain at 0 005 sec Time voltage peak Time current peak PF cos 0 02 x 360 BE 0026 0 046 4 T X o X gt 0 02 d 0 02 0 9511 It is found out that the power factor remains the same because from the trigonometrical identities cos 0 2m cos Hence the concept used in the calculation of power factor is correct Besides that the voltage current and power profile were shown when the buttons on the software interface The graph of voltage current and power against time were plotted 55 CHAPTER 5 CONCLUSION AND RECOMMENDATIONS 5 1 Conclusion In conclusion power measurement is used not only in industry and research area but also
101. tions on the LATA register read and write the latched output value for PORTA The RA4 pin is multiplexed with the Timer module clock input to become the RA4 TOCK pin The RAS pin is multiplexed with the main oscillator pin it is enabled as an oscillator or I O pin by the selection of the main oscillator Regster 1H see Section 25 1 Configuration Bits for details When not used as a port pin RA6 and its associated TRIS and LAT bits are read as 0 is also multiplexed with the USB module it serves as a receiver input from an external USB transceiver For detais on configuraton of the USB module see Section 17 2 USB Status and Control Several PORTA pins are multiplexed with analog inputs the analog Vrer and VRrer inputs and the comparator voltage reference output The operation of pns RAS and RAX RAD as A D converter inputs is selected by clearing setting the control bits in the ADCON1 register A D Control Register 1 Note On a Power on Reset RA5 and RA3 RAO are configured as analog inputs and read as 0 RA4 is configured as a digital input All other PORTA pins have TTL input levels and full CMOS output drivers The TRISA register controls the direction of the RA pins even when they are being used as analog inputs The user must ensure the bits in the TRISA register are maintained set when using them as analog inputs EXAMPLE 10 1 INITIALIZING PORTA 1 Initialize FORTA by 1 clearing outpu
102. torque so that it will return to original position From the Ohm s Law developed by Georg Ohm which states that the voltage across a conductor is directly proportional to the current through it measurement of voltage and current can be made and hence power can be obtained To be able to do this the electromagnetic torque produced by the moving coils and magnet is proportional to the current in the coil and the restoring torque is proportional to the angle of twist of the suspension fiber At equilibrium 11 state the current flowing through it is directly proportional to the angle of deflection Scales can then be made to acquire the voltage 2 The form of D Arsonval galvanometer today is built with a coil of wire in surrounding the permanent magnet The magnet produces magnetic field and this magnetic field will act against the magnetic field produced by the coil when current flows through the coil The coil will be twisted due to this action and will push against the spring which is connected to the meter pointer The pointer will points to the value of the current or voltage measured 3 2 3 3 Electrodynamic Meter Electrodynamic meter consists of a pair of fixed coil known as current coil and a movable coil which is the potential coil The potential coil which connected in parallel with the circuit carries a needle that moves over a scale to show the measured value The current coils that are connected in series with the circuit ge
103. tware created in the computer When signal is sent from the microcontroller to tell the USB interface to initiate its operations the USB interface will start receiving data from the data bus Before anything can be received the ADCs must be activated first in the software Because the ADCSs do not require control signals from the microcontroller therefore the speed of conversion is faster and will be able to directly send the converted signal into the 16 bit data bus of the microcontroller and USB interface Then the data will be sent to the computer through the USB ports to show in the software 13 Another suggestion from Yanpeng Wang and Mingming Fu about the data acquisition system using microcontroller with USB interface device was made in the year 2010 in WASE International Conference on Information Engineering The main idea was to create a portable data acquisition device by implementing USB ports To obtain high speed data acquisition and to meet the real time requirements the conventional method of data transmission 15 too slow to realize the concept of the project The data transmission using parallel port is complicated and expensive Even by using RS232 serial port the speed is relatively slow With the emergence of USB protocols all these limits had been broke off The system developed by the two China people uses ADC0820 PDIUSBD12 USB interface and AT89S51 microcontroller as the main system components ADC0820 is an 8 bit anal
104. vice CreateFile DevicePath GENERIC READ FILE SHARE READ Or FILE SHARE WRITE IntPtr Zero OPEN EXISTING 0 IntPtr Zero ErrorStatusRead Marshal GetLastWin32Error If ErrorStatusWrite ERROR SUCCESS And ErrorStatusRead ERROR SUCCESS Then AttachedState True AttachedButBroken False StatusBox txtbx Text Device Found AttachedState TRUE Else AttachedState False AttachedButBroken True If ErrorStatusWrite ERROR SUCCESS Then WriteHandleToUSBDevice Close End If If ErrorStatusRead ERROR SUCCESS Then ReadHandleToUSBDevice Close End If End If Else AttachedState False 98 AttachedButBroken False End If If AttachedState True Then StatusBox txtbx Text Device Found AttachedState TRUE Else StatusBox txtbx Text Device not found verify connect correct firmware End If ReadWriteThread RunWorkerAsync End Sub FUNCTION WndProc Protected Overrides Sub WndProc ByRef m As System Windows Forms Message If m Msg WM DEVICECHANGE Then If m WParam DBT DEVICEARRIVAL Or m WParam DBT DEVICEREMOVEPENDING Or m WParam DBT DEVICEREMOVECOMPLETE Or m WParam DBT CONFIGCHANGED Then If CheckIfPresentAndGetUSBDevicePath True If AttachedState False Or AttachedButBroken True Then Dim ErrorStatusRead As Ulnteger Dim ErrorStatusWrite As UInteger WriteHandleToUSBDevice CreateFile DevicePath GENERIC WRITE FILE SHARE READ Or FILE SHARE WRITE IntPtr Zero O
Download Pdf Manuals
Related Search
Related Contents
Nokia 808 PureView User Guide Philips JW-0611 GB User's Manual 3.0 Computer assembly DeLOCK 2m Toslink Standard PowerPoint プレゼンテーション PMC66-SIO4BXR - General Standards Corporation Mora VM 632 X 安全データシート - 林純薬 – 電子材料 照明器具 施工説明書 照明器具 取扱説明書 ITTM Easy5+ 75g Copyright © All rights reserved.
Failed to retrieve file