Latest project, amplifier power meter.

Hi,

Pretty useless device for a music amplifier, and using theoretical loads.

All amplifiers clip with music way below RMS sine wave power ratings
as decent quality programme spends ~ 80% of the time below ~ 20%.

rgds, sreten.

As your not using the real load what it tells you at best is academic.
 
Last edited:
Interesting:)
Is this your own design?
Is the firmware and pcb for share?
Schematic then PIC code.

[IMGDEAD]http://www.ckpr.talktalk.net/powermeter2.bmp[/IMGDEAD]

PIC CODE

;inth0.ASM
;*********
#include p16f73.inc
LIST R=DEC


;----- CONFIG Options --------------------------------------------------
_FOSC_LP EQU H'3FFC' ; LP oscillator
_LP_OSC EQU H'3FFC' ; LP oscillator
_FOSC_XT EQU H'3FFD' ; XT oscillator
_XT_OSC EQU H'3FFD' ; XT oscillator
_FOSC_HS EQU H'3FFE' ; HS oscillator
_HS_OSC EQU H'3FFE' ; HS oscillator
_FOSC_RC EQU H'3FFF' ; RC oscillator
_RC_OSC EQU H'3FFF' ; RC oscillator

_WDTE_OFF EQU H'3FFB' ; WDT disabled
_WDT_OFF EQU H'3FFB' ; WDT disabled
_WDTE_ON EQU H'3FFF' ; WDT enabled
_WDT_ON EQU H'3FFF' ; WDT enabled

_PWRTE_ON EQU H'3FF7' ; PWRT enabled
_PWRTE_OFF EQU H'3FFF' ; PWRT disabled

_CP_ON EQU H'3FEF' ; All Memory locations code protected
_CP_ALL EQU H'3FEF' ; All Memory locations code protected
_CP_OFF EQU H'3FFF' ; Code protection off

_BOREN_OFF EQU H'3FBF' ; BOR disabled
_BODEN_OFF EQU H'3FBF' ; BOR disabled
_BOREN_ON EQU H'3FFF' ; BOR enabled
_BODEN_ON EQU H'3FFF' ; BOR enabled


__CONFIG _WDT_OFF & _CP_OFF & _XT_OSC & _PWRTE_ON &_BODEN_ON

CBLOCK 20H
FLAGS
LCDTEMP
INPUTCOUNTL
INPUTCOUNTH
PREVIOUSHIGHEST
LCDDELAYCOUNT
LCDDELAYCOUNT2
NO1_0
NO1_1
NO1_2
NO1_3
NO2_0
NO2_1
NO2_2
NO2_3
NO3_0
NO3_1
NO3_2
NO3_3
TEMP_0
TEMP_1
TEMP_2
TEMP_3
TRIAL_0
TRIAL_1
TRIAL_2
TRIAL_3
ANSER_0
ANSER_1
ANSER_2
ANSER_3
LOOPCOUNT
ENDC

;FLAGS
#DEFINE DIGITNOTZERO FLAGS,0


#DEFINE LCD_E PORTB,0
#DEFINE LCD_R_W PORTB,1
#DEFINE LCD_RS PORTB,2
#DEFINE LED PORTB,4


;*****************************************
;SUBWF FLAGS
;IF W > MEM THEN NC
;IF W = MEM THEN C
;IF W < MEM THEN C
;IF W<= MEM THEN C

;IF MEM>=W THEN C
;IF MEM<W THEN NC
;*****************************************


ORG 0
CLRF FSR ;BANK 0 RAM


MOVLW 255
BSF STATUS,RP0
MOVWF TRISA-80H
BCF STATUS,RP0

MOVLW 81H
MOVWF ADCON0

BSF STATUS,RP0 ;9FH
MOVLW 4
MOVWF ADCON1-80H
BCF STATUS,RP0

MOVLW 255
BSF STATUS,RP0
MOVWF TRISC-80H
BCF STATUS,RP0

MOVLW 0
BSF STATUS,RP0
MOVWF TRISB-80H
BCF STATUS,RP0
MOVLW 0
MOVWF PORTB

MOVLW 80H ;PORT B PULL UPS OFF
BSF STATUS,RP0
MOVWF OPTION_REG-80H
BCF STATUS,RP0

BSF LED ;SHOW POWER ON


;SET UP LCD
CALL INITLCD






MLOOP CLRF INPUTCOUNTL
CLRF INPUTCOUNTH
CLRF PREVIOUSHIGHEST

MLOOP2 BSF ADCON0,GO
WAIT
BTFSC ADCON0,GO
GOTO WAIT


;IF MEM>=W THEN C
;IF MEM<W THEN NC
MOVF ADRES,W
SUBWF PREVIOUSHIGHEST,W
BC NOCHANGE
MOVF ADRES,W
MOVWF PREVIOUSHIGHEST
NOCHANGE


INCFSZ INPUTCOUNTL,F
DECF INPUTCOUNTH,F
INCF INPUTCOUNTH,F

MOVLW LOW 10000
XORWF INPUTCOUNTL,W
BNZ MLOOP2

MOVLW HIGH 10000
XORWF INPUTCOUNTH,W
BNZ MLOOP2

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;ADJUST FOR POTENTIAL DIVIDER WHICH DIVIDES BY 22.
MOVF PREVIOUSHIGHEST,W
CALL CLEARNO1
MOVWF NO1_0

CALL CLEARNO2
MOVLW 22 ;TIMES 22
MOVWF NO2_0

CALL MPY32

CALL ANSER_TO_NO1

;DIV 51 FOR A2D 255/5 / VOLT
CALL CLEARNO2
MOVLW 51
MOVWF NO2_0

CALL DIV32

;WATTS = VSQUARED / R
CALL ANSER_TO_NO1
CALL ANSER_TO_NO2
CALL MPY32

CALL ANSER_TO_NO1
CALL CLEARNO2
MOVLW 2 ;DIV 2 OHMS
MOVWF NO2_0
CALL DIV32




;TIMES 0.707 TO GET RMS VALUE
;SO TIMES BY 707 THEN DIV BY 1000

CALL ANSER_TO_NO1

CALL CLEARNO2
MOVLW LOW 707
MOVWF NO2_0
MOVLW HIGH 707
MOVWF NO2_1

CALL MPY32

CALL ANSER_TO_NO1

CALL CLEARNO2
MOVLW LOW 1000
MOVWF NO2_0
MOVLW HIGH 1000
MOVWF NO2_1

CALL DIV32



;PRINT OUT RESULT
CALL CLS
MOVLW '2'
CALL LCDSOD
MOVLW 'R'
CALL LCDSOD
MOVLW '='
CALL LCDSOD

CALL ANSER_TO_NO3 ;SAVE FOR LATER
CALL ANSER_TO_NO1
CALL SAX2DEC
;2ND LINE
MOVLW 10
CALL SETCURSORPOSW
MOVLW '4'
CALL LCDSOD
MOVLW 'R'
CALL LCDSOD
MOVLW '='
CALL LCDSOD

CALL NO3_TO_NO1
CALL NO1_DIV2
CALL NO1_TO_NO3
CALL SAX2DEC

;3RD LINE
MOVLW 40
CALL SETCURSORPOSW
MOVLW '8'
CALL LCDSOD
MOVLW 'R'
CALL LCDSOD
MOVLW '='
CALL LCDSOD

CALL NO3_TO_NO1
CALL NO1_DIV2
CALL NO1_TO_NO3
CALL SAX2DEC

;4TH LINE
MOVLW 50
CALL SETCURSORPOSW
MOVLW '1'
CALL LCDSOD
MOVLW '6'
CALL LCDSOD
MOVLW 'R'
CALL LCDSOD
MOVLW '='
CALL LCDSOD

CALL NO3_TO_NO1
CALL NO1_DIV2
CALL NO1_TO_NO3
CALL SAX2DEC





GOTO MLOOP


;LCD.ASM
;*******************************
INITLCD
CALL WAIT40MS

MOVLW 30H
CALL LCD_INSTR2
CALL WAIT4MS

MOVLW 30H
CALL LCD_INSTR2
CALL WAIT4MS

MOVLW 30H
CALL LCD_INSTR2
CALL WAIT4MS
;;;;
MOVLW 3CH ;NO OF LINES=4 FONT 7*5
CALL LCD_INSTR
CALL WAIT4MS

MOVLW 1 ;CLS
CALL LCD_INSTR
CALL WAIT4MS

; MOVLW 0FH ;DISPLAY ON CURSOR BLINK
MOVLW 0CH ;DISPLAY ON NO CURSOR AND NO BLINK
CALL LCD_INSTR
CALL WAIT4MS

RETURN

;**********************
LCD_INSTR2 MOVWF LCDTEMP ;NO TEST FOR BUSY
GOTO IN22


LCD_INSTR MOVWF LCDTEMP ;TEST FOR BUSY FIRST

CALL BUSYQ

IN22 CALL WAIT4MS

CALL DATABUSOUTPUT

MOVF LCDTEMP,W
MOVWF PORTC

BCF LCD_RS
BCF LCD_R_W
BSF LCD_E
NOP
NOP
BCF LCD_E
BSF LCD_R_W
RETURN
;***********************
SPACE_ MOVLW ' '
;CALLED HERE AS WELL
LCDSOD MOVWF PORTC
GOTO LCD_DATA
;************************
LCD_DATA MOVWF LCDTEMP
CALL BUSYQ

CALL WAIT4MS

CALL DATABUSOUTPUT
MOVF LCDTEMP,W
MOVWF PORTC
BSF LCD_RS
BCF LCD_R_W
BSF LCD_E
NOP
NOP
BCF LCD_E
BSF LCD_R_W

RETURN
;***********************
BUSYQ CALL DATABUSINPUT
STILLBUSY2
BSF LCD_R_W
BCF LCD_RS

BSF LCD_E
NOP
NOP

BCF LCD_E
BTFSC PORTC,7 ;B7=1=BUSY
GOTO STILLBUSY2

RETURN
;***************************
CLS CALL BUSYQ

CALL WAIT4MS

BCF LCD_RS
BCF LCD_R_W

CALL DATABUSOUTPUT

MOVLW 1
MOVWF PORTC

BSF LCD_E
NOP
NOP
BCF LCD_E
BSF LCD_R_W
GOTO WAIT40MS
;**********************
DATABUSINPUT BSF STATUS,RP0
MOVLW 255
MOVWF PORTC
BCF STATUS,RP0
RETURN
;***************************
DATABUSOUTPUT BSF STATUS,RP0
CLRF PORTC
BCF STATUS,RP0
RETURN
;***************************
WAIT40MS MOVLW 50
GOTO W2
;
WAIT4MS MOVLW 5
W2 MOVWF LCDDELAYCOUNT2
CLRF LCDDELAYCOUNT
W4 DECFSZ LCDDELAYCOUNT,F
GOTO W4
DECFSZ LCDDELAYCOUNT2,F
GOTO W4
RETURN
;*******************************
SETCURSORPOSW
ANDLW 3FH
IORLW 80H
GOTO LCD_INSTR
;********************************














;MATHS.ASM
;*********
NO2_TO_NO1
MOVF NO2_0,W
MOVWF NO1_0
MOVF NO2_1,W
MOVWF NO1_1
MOVF NO2_2,W
MOVWF NO1_2
MOVF NO2_3,W
MOVWF NO1_3
RETURN
;*****************
CLEARANSER CLRF ANSER_0
CLRF ANSER_1
CLRF ANSER_2
CLRF ANSER_3
RETURN
;************************
CLEARNO1
CLRF NO1_0
CLRF NO1_1
CLRF NO1_2
CLRF NO1_3
RETURN
;***************************
CLEARNO2
CLRF NO2_0
CLRF NO2_1
CLRF NO2_2
CLRF NO2_3
RETURN
;***************************
NO1_TO_NO2
MOVF NO1_0,W
MOVWF NO2_0
MOVF NO1_1,W
MOVWF NO2_1
MOVF NO1_2,W
MOVWF NO2_2
MOVF NO1_3,W
MOVWF NO2_3
RETURN
;*****************
ANSER_TO_NO1
MOVF ANSER_0,W
MOVWF NO1_0
MOVF ANSER_1,W
MOVWF NO1_1
MOVF ANSER_2,W
MOVWF NO1_2
MOVF ANSER_3,W
MOVWF NO1_3
RETURN
;*****************************
TRIAL_TO_NO1 MOVF TRIAL_0,W
MOVWF NO1_0
MOVF TRIAL_1,W
MOVWF NO1_1
MOVF TRIAL_2,W
MOVWF NO1_2
MOVF TRIAL_3,W
MOVWF NO1_3
RETURN
;*****************************
;NO1 / NO2 TO ANSER
;RETURNS REMAINDER IN TRIAL

;32*32 DIVIDE WITH 40 BIT RESULT
DIV32
CALL CLEARANSER
CALL CLEARTRIAL

MOVLW 32
MOVWF LOOPCOUNT
D32LOOP
;ANSER*2
CLRC
RLF ANSER_0,F
RLF ANSER_1,F
RLF ANSER_2,F
RLF ANSER_3,F

;RLF NO1 INTO TRIAL
CLRC
RLF NO1_0,F
RLF NO1_1,F
RLF NO1_2,F
RLF NO1_3,F

RLF TRIAL_0,F
RLF TRIAL_1,F
RLF TRIAL_2,F
RLF TRIAL_3,F

;NO2 COMPLEMENTED TO TEMP
COMF NO2_0,W
MOVWF TEMP_0
COMF NO2_1,W
MOVWF TEMP_1
COMF NO2_2,W
MOVWF TEMP_2
COMF NO2_3,W
MOVWF TEMP_3

;ADD 1 TO COMPLETE NEGATION OF TEMP
INCFSZ TEMP_0,F
GOTO OVER
INCFSZ TEMP_1,F
GOTO OVER
INCFSZ TEMP_2,F
GOTO OVER
INCF TEMP_3,F

OVER

;NEGATED TEMP + TRIAL TO TEMP
MOVF TRIAL_0,W ;SIMPLE ADD OF 1ST TWO BYTES
ADDWF TEMP_0,F

MOVF TRIAL_1,W
BTFSC STATUS,C ;IF CARRY THEN INC NEXT BYTE UP
INCFSZ TRIAL_1,W ;DONT ADD IF WAS INCED TO ZERO FROM 255 ELSE CARRY LOST
ADDWF TEMP_1,F ;IF THIS IS SKIPPED THEN CARRY IS SENT TO NEXT STAGE

MOVF TRIAL_2,W
BTFSC STATUS,C
INCFSZ TRIAL_2,W
ADDWF TEMP_2,F

MOVF TRIAL_3,W
BTFSC STATUS,C
INCFSZ TRIAL_3,W
ADDWF TEMP_3,F

BNC JSROT32

;NEW VALUE TO TRIAL
MOVF TEMP_0,W
MOVWF TRIAL_0
MOVF TEMP_1,W
MOVWF TRIAL_1
MOVF TEMP_2,W
MOVWF TRIAL_2
MOVF TEMP_3,W
MOVWF TRIAL_3

BSF ANSER_0,0

JSROT32 DECFSZ LOOPCOUNT,F
GOTO D32LOOP

RETURN
;*************************************
CLEARTRIAL CLRF TRIAL_0
CLRF TRIAL_1
CLRF TRIAL_2
CLRF TRIAL_3
RETURN
;**************************************
MPY32
;NO1 * NO2 TO ANSER
;32*32 BIT MPY WITH 32 BIT ANSWER
CALL CLEARANSER

MOVLW 32
MOVWF LOOPCOUNT
SHADD_32
CLRC
RLF ANSER_0,F
RLF ANSER_1,F
RLF ANSER_2,F
RLF ANSER_3,F

;NO1 SHIFT LEFT ONE BIT INTO CARRY
CLRC
RLF NO1_0,F
RLF NO1_1,F
RLF NO1_2,F
RLF NO1_3,F

BNC NOADD_32
;;;;;;;;;;;;;;;
;ADD NO2 TO ANSER
MOVF NO2_0,W ;SIMPLE ADD OF 1ST TWO BYTES
ADDWF ANSER_0,F

MOVF NO2_1,W
BTFSC STATUS,C ;IF CARRY THEN INC NEXT BYTE UP
INCFSZ NO2_1,W ;DONT ADD IF WAS INCED TO ZERO FROM 255 ELSE CARRY LOST
ADDWF ANSER_1,F ;IF THIS IS SKIPPED THEN CARRY IS SENT TO NEXT STAGE

MOVF NO2_2,W
BTFSC STATUS,C
INCFSZ NO2_2,W
ADDWF ANSER_2,F

MOVF NO2_3,W
BTFSC STATUS,C
INCFSZ NO2_3,W
ADDWF ANSER_3,F

;;;;;;
NOADD_32
DECFSZ LOOPCOUNT,F
GOTO SHADD_32

RETURN
;*****************************************
ANSER_TO_NO2 MOVF ANSER_0,W
MOVWF NO2_0
MOVF ANSER_1,W
MOVWF NO2_1
MOVF ANSER_2,W
MOVWF NO2_2
MOVF ANSER_3,W
MOVWF NO2_3

RETURN
;******************************
;ADD NO1+NO2 TO ANSER
;NO1 AND NO2 ARE LEFT INTACT
;CARRYOUT HOLDS CARRY STATUS
;ADD32 ;
;
;MOVE NO2 TO ANSER
; MOVF NO2_0,W
; MOVWF ANSER_0
; MOVF NO2_1,W
; MOVWF ANSER_1
; MOVF NO2_2,W
; MOVWF ANSER_2
; MOVF NO2_3,W
; MOVWF ANSER_3

;ADD NO1 TO ANSER
; MOVF NO1_0,W ;SIMPLE ADD OF 1ST TWO BYTES
; ADDWF ANSER_0,F
;
; MOVF NO1_1,W
; BTFSC CARRYFLAG ;IF CARRY THEN INC NEXT BYTE UP
; INCFSZ NO1_1,W ;DONT ADD IF WAS INCED TO ZERO FROM 255 ELSE CARRY LOST
; ADDWF ANSER_1,F ;IF THIS IS SKIPPED THEN CARRY IS SENT TO NEXT STAGE
;
; MOVF NO1_2,W
; BTFSC CARRYFLAG
; INCFSZ NO1_2,W
; ADDWF ANSER_2,F
;
; MOVF NO1_3,W
; BTFSC CARRYFLAG
; INCFSZ NO1_3,W
; ADDWF ANSER_3,F
;
; BCF CARRYOUT ;STORE CARRY FOR LATER USE
; SKPNC
; BSF CARRYOUT
; RETURN
;*************************************









;**************

;NO1 TO DECIMAL ON SCREEN WITH LEADING ZEROES SUPPRESSED
;24 BITS TO 0 TO 16777216
SAX2DEC

BCF DIGITNOTZERO ;FOR LEADING ZERO SUPPRESSION
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CALL CLEARNO2
MOVLW 10000000 & 0FFH
MOVWF NO2_0
MOVLW (10000000/256) & 0FFH
MOVWF NO2_1
MOVLW (10000000/65536) & 0FFH
MOVWF NO2_2
CALL DIV32

MOVF ANSER_0,W
CALL DODIGIT
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CALL TRIAL_TO_NO1
CALL CLEARNO2
MOVLW 1000000 & 0FFH
MOVWF NO2_0
MOVLW (1000000/256) & 0FFH
MOVWF NO2_1
MOVLW (1000000/65536) & 0FFH
MOVWF NO2_2
CALL DIV32

MOVF ANSER_0,W
CALL DODIGIT
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CALL TRIAL_TO_NO1
CALL CLEARNO2
MOVLW 100000 & 0FFH
MOVWF NO2_0
MOVLW (100000/256) & 0FFH
MOVWF NO2_1
MOVLW (100000/65536) & 0FFH
MOVWF NO2_2
CALL DIV32

MOVF ANSER_0,W
CALL DODIGIT
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CALL TRIAL_TO_NO1
CALL CLEARNO2
MOVLW LOW 10000
MOVWF NO2_0
MOVLW HIGH 10000
MOVWF NO2_1
CALL DIV32

MOVF ANSER_0,W
CALL DODIGIT
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CALL TRIAL_TO_NO1
CALL CLEARNO2
MOVLW LOW 1000
MOVWF NO2_0
MOVLW HIGH 1000
MOVWF NO2_1
CALL DIV32

MOVF ANSER_0,W
CALL DODIGIT
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CALL TRIAL_TO_NO1
CALL CLEARNO2
MOVLW 100
MOVWF NO2_0
CALL DIV32

MOVF ANSER_0,W
CALL DODIGIT
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CALL TRIAL_TO_NO1
CALL CLEARNO2
MOVLW 10
MOVWF NO2_0
CALL DIV32

MOVF ANSER_0,W
CALL DODIGIT
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;ALWAYS DO LAST DIGIT!!!!
MOVF TRIAL_0,W
IORLW '0'
GOTO LCDSOD
;****************************
DODIGIT
IORLW 0 ;SET FLAGS
SKPZ
BSF DIGITNOTZERO

BTFSS DIGITNOTZERO
RETURN
IORLW '0'

GOTO LCDSOD
;************************************
ANSER_TO_NO3
MOVF ANSER_0,W
MOVWF NO3_0
MOVF ANSER_1,W
MOVWF NO3_1
MOVF ANSER_2,W
MOVWF NO3_2
MOVF ANSER_3,W
MOVWF NO3_3
RETURN
;**************************************
NO3_TO_NO1
MOVF NO3_0,W
MOVWF NO1_0
MOVF NO3_1,W
MOVWF NO1_1
MOVF NO3_2,W
MOVWF NO1_2
MOVF NO3_3,W
MOVWF NO1_3
RETURN
;**************************************
NO1_TO_NO3
MOVF NO1_0,W
MOVWF NO3_0
MOVF NO1_1,W
MOVWF NO3_1
MOVF NO1_2,W
MOVWF NO3_2
MOVF NO1_3,W
MOVWF NO3_3
RETURN
;**************************************
NO1_DIV2 CLRC
RRF NO1_3,F
RRF NO1_2,F
RRF NO1_1,F
RRF NO1_0,F
RETURN
;***************************************

END
 
Hi,

Pretty useless device for a music amplifier, and using theoretical loads.

All amplifiers clip with music way below RMS sine wave power ratings
as decent quality programme spends ~ 80% of the time below ~ 20%.

rgds, sreten.

As your not using the real load what it tells you at best is academic.

Where have I said its not a speaker load ?

A speaker is very complex so its never going to be spot on.
It was for myself with a mobile disco to get an idea of how many watts I am pushing into my speaker stack.
Its to save me blowing up the speakers with too much power.
 
A speaker is very complex so its never going to be spot on.
It was for myself with a mobile disco to get an idea of
how many watts I am pushing into my speaker stack.
Its to save me blowing up the speakers with too much power.

Hi,

The information you will be getting is next to useless.
It won't save or predict imminent speaker driver failure
in any practical set up, that uses a basic stack set up.

rgds, sreten.
 
Hi,

The information you will be getting is next to useless.
It won't save or predict imminent speaker driver failure
in any practical set up, that uses a basic stack set up.

rgds, sreten.

The information gives exact wattage being produced by the amplifier and is extremely useful to know.

Clearly if the amp is putting out 200 watts into a 100 watt speaker you have a warning that something is seriously wrong.

Its as accurate (32 bit arithmetic) if not better than a DMM.

I have 5 power amplifiers all of different output wattages.
This meter has proved e4xtremely useful and saved me hundreds if not thousands in fried speakers.
 
Bling for your stereo!!

The first one I built had black characters on a green background.
That is the standard model.

The next one I am building is the deluxe model with white characters on blue background with a back light. Only problem is backlight takes another 30ma from battery, but it does have an on/off switch. There is an option on the pcb to plug in a mains adaptor.
One little trick I used to save battery power is to allow the amplifier input to charge the 5 volt rail via the PIC's i/o pins.