zasilacz ster procesorem.rar

Zasilacz 0-25V sterowany cyfrowo

Czesc , a co sadzicie o tym zasilaczu.

  • zasilacz ster procesorem.rar
    • SCH2.TIF
    • PCB2B.BMP
    • PCB2A.BMP
    • PROJECT.PCB
    • PROJECT2.PCB
    • README~1.TXT
    • NSCODAC.LIB
    • MANUAL.DOC
    • PCB1A.BMP
    • POWER.ERR
    • PROJECT.SCH
    • POWER.HEX
    • MRMC8BT.LIB
    • SCH1.TIF
    • POWER.ASM
    • PCB1B.BMP
    • DEVICE.LIB
    • P16C84.INC
    • PROJECT2.SCH


Pobierz plik - link do postu

zasilacz ster procesorem.rar > README~1.TXT

The following are the list of files on this diskette:

Device.lib Protel device library
Mrmc8bt.lib Protel Microchip library
Nscodac.lib Protel National Semiconductor DAC library
Manual.doc Hardware and Software short description (Word 97 format)
P16C84.inc MPASM PIC16C84 header file
PCB1a.bmp Bitmap Power Supply PCB Board (Solder side)
PCB1b.bmp Bitmap Power Supply PCB Board (Component side)
PCB2a.bmp Bitmap Microcontroller PCB Board (Solder side)
PCB2b.bmp Bitmap Microcontroller PCB Board (Component side)
Power.asm PIC16C84 Microcontroller Source code
Power.hex PIC16C84 Microcontroller Intel Hex code
Project.pcb Protel Power Supply PCB Board
Project2.pcb Protel Microcontroller PCB Board
Project.sch Power Supply Board Schematic Diagram
Project2.sch Microcontroller Board Schematic Diagram
Sch1.tif TIFF for Power Supply Board Schematic Diagram
Sch2.tif TIFF for Microcontroller Board Schematic Diagram
Readme.lst This file

Due to space limitation, MPASM Microchip Assembler couldn't be included it.
However, the assembler can be downloaded from the Microchip Web site (www.microchip.com)

Name: Tak Meng Cheang (Felix)
Email: takmeng@usa.net


zasilacz ster procesorem.rar > MANUAL.DOC

Microcontroller Based MOSFET Variable Bench Power Supply

by

Tak Meng Cheang

Software Description

The PIC microcontroller program POWER.ASM was written in assembly
language format based on the Microchip instruction sets. The
microcontroller is used to sample the key input data from the keypad and
process it internal. The result of this process will be used to set the
reference signal for the power supply control circuitry. The program
contains subroutines for sampling the key pad (select mode, input
voltage or current level and enter key), converting the input
voltage/current to an 8-bit digital code, selecting which DAC port
(voltage port or current port) and output the 8-bit code to the
designated DAC port.

The source code was written using a text editor and assembled using
MPASM Ver. 1.4.

Software Source Code

;

; TITLE : Microcontroller Based MOSFET Variable Bench Power Supply

;

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

;This program is used to control the voltage setting and current

;limit setting of a MOSFET variable bench power supply using a
;Microchip PIC16C84.

;

;External Oscillator used = 4.000 MHz. Prescaler of 32 used, which
;gives a 32 microsec. increment of the RTCC. The RTCC timer, is used ;in
internal interrupt mode, is set to 96 and will overflow to 0 in ;5.088
msec.

;

;Copyright(C)Tak Meng Cheang, 1997

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

INCLUDE P16C84.INC

Err EQU 2 ;Error LED

_CS1 EQU 0 ;Voltage DAC selector

_CS2 EQU 1 ;Current DAC selector

Key_Hit EQU 0 ;Key pressed

;indicator

Mode EQU 0 ;Mode indicator

Err_Hit EQU 1 ;Error indicator

DebnceOn EQU 1 ;Debounce On/Off

ServKey EQU 2 ;Service key On/Off

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

;

;Define Keyflag register and function:

;

Keyflag EQU 1F

; Bit # 7|6|5|4|3|2|1|0|

; --------|-|-|-|-|-|-|-|

; X|X|X|X|X|Y|Y|1| - & gt; Key pressed!

; X|X|X|X|X|Y|1|Y| - & gt; Debounce timing on

; X|X|X|X|X|1|Y|Y| - & gt; Servicing key pressed

; X = Not implemented

; Y = No care

;

;Define Control register and function:

;

Control EQU 0C

; Bit # 7|6|5|4|3|2|1|0|

; --------|-|-|-|-|-|-|-|

; X|X|X|X|X|X|Y|1| - & gt; Voltage mode

; X|X|X|X|X|X|Y|0| - & gt; Current mode

; X|X|X|X|X|X|1|Y| - & gt; Error!

; X = Not implemented

; Y = No care

;

DOutput EQU 0D ;DAC input.

HundredEntry EQU 0E ;input register.

TenEntry EQU 0F

UnitEntry EQU 10

Mulcnd EQU 15 ;register related to

Mulplr EQU 16 ;multiplication

;routine.

L_Byte EQU 17

H_Byte EQU 18

Msb EQU 19 ;multiplication

;output register.

Lsb EQU 1A

Count EQU 1B ;Count register.

New_Key EQU 1D

Key_Nibl EQU 1E

Temp EQU 1C ;temp general purpose

TempC EQU 20 ;register.

TempD EQU 21

TempE EQU 22

PBBuf EQU 23

Debnce EQU 24 ;debounce counter.

WBuffer EQU 25

StatBuffer EQU 26

Update_Register EQU 27 ;Direction register.

ORG H'0000'

GOTO Start ;skip over interrupt

;vector.



ORG H'0004'

;It is always a good practice to save and restore the w register and
;the status register during an interrupt.

MOVWF WBuffer

SWAPF WBuffer,F

SWAPF STATUS,W

MOVWF StatBuffer

CALL ServiceInterrupts

SWAPF StatBuffer,W

MOVWF STATUS

SWAPF WBuffer,W

RETFIE

Start

CALL InitPorts ;initialize i/o port.

CALL InitTimers ;initialize various

;timers.

CLRF Keyflag ;clear keyflag

;register.

CLRF Control ;clear control

;register.

BCF PORTA,_CS1 ;initialize and clear

BCF PORTA,_CS2 ;DAC buffers.

Clear1

NOP

BSF PORTA,_CS1

BSF PORTA,_CS2

MOVLW B'00000010' ;set direction.

MOVWF Update_Register



Loop1

BTFSC Keyflag,ServKey ;key service pending.

CALL ServiceKey ;yes then service.

BTFSC Update_Register,0 ;check for error.

BSF PORTA,Err ;yes then set error

;indicator.

BTFSS Update_Register,7 ;key input routine

;completed?

GOTO Loop1 ;no then loop again.

GOTO Multply ;yes then initiate

;multiplication

;process.

Finish

CLRF PORTB ;write

;multiplication's

BSF STATUS,RP0 ;result to

;corresponding DAC

CLRF TRISB ;buffer.

BCF STATUS,RP0

MOVF DOutput,W

MOVWF PORTB

BTFSS Control,Mode ;check mode?

GOTO Current

BCF PORTA,_CS1 ;update voltage DAC

BCF Update_Register,7 ;reset DAC update

;flag.

GOTO Clear1

Current

BCF PORTA,_CS2 ;update current DAC

BCF Update_Register,7 ;reset DAC update

;flag.

GOTO Clear1

;

;ServiceKey, does the software service for a keyhit. After a key
;service, the ServKey flag is reset, to denote a completed operation.

ServiceKey

MOVF New_Key,W ;get key value.

MOVWF Temp ;save in Temp.

CALL Director

BCF Keyflag,ServKey ;reset service flag.

RETURN

Director

BTFSC Update_Register,0 ;check the direction

GOTO ServiceError ;register bit to

;select appropriate

BTFSC Update_Register,1 ;function.

GOTO SetEntry

BTFSC Update_Register,2

GOTO ModeEntry

BTFSC Update_Register,3

GOTO FirstEntry

BTFSC Update_Register,4

GOTO SecondEntry

BTFSC Update_Register,5

GOTO ThirdEntry

BTFSC Update_Register,6

GOTO EndEntry

GOTO ServiceError

;ServiceError, a subroutine used to service error condition if an ;error
has encountered.

ServiceError

MOVF Temp,W

XORLW 0C

BTFSS STATUS,Z

RETURN

BCF Update_Register,0

BCF PORTA,Err ;clear error

;indicator.

MOVLW B'00000100'

MOVWF Update_Register

RETURN

;

;The following subroutines are used to input the various values, from
;the keypad entry, into corresponding registers.

SetEntry

MOVF Temp,W ;check for set mode

;key.

XORLW 0C

BTFSS STATUS,Z

GOTO Action1 ;no then recheck

;again.

BCF Update_Register,1 ;yes then service set

;mode.



BSF Update_Register,2

Action1

RETURN

ModeEntry

MOVF Temp,W ;check voltage mode

;key.

XORLW 0D

BTFSS STATUS,Z

GOTO Other ;no then check

;current mode.

BSF Control,Mode

GOTO Action2a

Other

MOVF Temp,W ;if not current mode, XORLW 0E
;then error!

BTFSS STATUS,Z

GOTO Action3

GOTO Action2

Action3

BSF Update_Register,0

BCF Update_Register,2

RETURN

Action2

BCF Control,Mode

Action2a

BCF Update_Register,2

BSF Update_Register,3

RETURN

FirstEntry

CALL Chk_Err ;check error?

BTFSC Control,Err_Hit

GOTO Action4 ;yes then service

;error.

MOVF Temp,W

XORLW 0F

BTFSC STATUS,Z

GOTO Action4

MOVF Temp,W

MOVWF HundredEntry ;store 1st value to

;register.

BCF Update_Register,3

BSF Update_Register,4

RETURN

Action4

BCF Update_Register,3

BSF Update_Register,0

RETURN

SecondEntry

CALL Chk_Err ;check error?

BTFSC Control,Err_Hit

GOTO Action5 ;yes then service

;error.

MOVF Temp,W

XORLW 0F

BTFSC STATUS,Z

GOTO Action5

MOVF Temp,W

MOVWF TenEntry ;store 2nd value to

;register.

BCF Update_Register,4

BSF Update_Register,5

RETURN

Action5

BCF Update_Register,4

BSF Update_Register,0

RETURN

ThirdEntry

CALL Chk_Err ;check error?

BTFSC Control,Err_Hit

GOTO Action6 ;yes then service

;error.

MOVF Temp,W

XORLW 0F

BTFSC STATUS,Z

GOTO Action6

MOVF Temp,W

MOVWF UnitEntry ;store 3rd value to

;register.

BCF Update_Register,5

BSF Update_Register,6

RETURN

Action6

BCF Update_Register,5

BSF Update_Register,0

RETURN

EndEntry

CALL Chk_Err ;check error?

BTFSC Control,Err_Hit

GOTO Action7 ;yes then service

;error.

MOVF Temp,W

XORLW 0F

BTFSS STATUS,Z

GOTO Action7

BCF Update_Register,6

BSF Update_Register,7

RETURN

Action7

BCF Update_Register,6 ;input value routine

BSF Update_Register,0 ;completed.

RETURN

InitPorts

BSF STATUS,RP0 ;initialize portA and

;portB.

CLRF TRISA

CLRF TRISB

BCF STATUS,RP0

CLRF PORTB

MOVLW B'00000011'

MOVWF PORTA

RETURN

InitTimers

BSF STATUS,RP0 ;initialize various

;timers.

MOVLW B'10000100'

MOVWF OPTION_REG

BCF STATUS,RP0

MOVLW B'00100000'

MOVWF INTCON

MOVLW .96

MOVWF TMR0

RETFIE

ServiceInterrupts

BTFSC INTCON,T0IF ;check type of

;interrupt.

GOTO ServiceRTCC

CLRF INTCON

BSF INTCON,T0IE

RETURN

ServiceRTCC

MOVLW .96 ;service RTCC

;interrupt.

MOVWF TMR0

BCF INTCON,T0IF

CALL ScanKeys

RETURN

;

;ScanKeys, scans the 4X4 keypad matrix and returns a key value in

;New_Key (0 - F) if a key is pressed, if not it clears the Key_Hit
;flag.

;

ScanKeys

BTFSS Keyflag,DebnceOn ;check debounce.

GOTO Scan1

DECFSZ Debnce,F

RETURN

BCF Keyflag,DebnceOn

RETURN

Scan1

CALL SavePorts ;save ports.

MOVLW B'11101111'

MOVWF TempD

ScanNext

MOVF PORTB,W ;capture keypad raw

;input.

BCF INTCON,RBIF

RRF TempD,F

BTFSS STATUS,C

GOTO Nokey

MOVF TempD,W

MOVWF PORTB

NOP

BTFSS INTCON,RBIF

GOTO ScanNext

BTFSC Keyflag,Key_Hit ;if key_hit set.

GOTO SKReturn

BSF Keyflag,Key_Hit ;no then set it.

SWAPF PORTB,W

MOVWF TempE

CALL GetKeyvalue

MOVWF New_Key

BSF Keyflag,ServKey ;set service flag.

BSF Keyflag,DebnceOn ;set debounce flag.

MOVLW 4

MOVWF Debnce

SKReturn

CALL RestorePorts ;restore ports.

RETURN

Nokey

BCF Keyflag,Key_Hit ;no key scanned, then

;return.

GOTO SKReturn

GetKeyvalue

CLRF TempC ;interpret key value

;based on

BTFSS TempD,3 ;raw input from

;keypad's scan.

GOTO RowValEnd

INCF TempC,1

BTFSS TempD,2

GOTO RowValEnd

INCF TempC,1

BTFSS TempD,1

GOTO RowValEnd

INCF TempC,1

RowValEnd

BTFSS TempE,0

GOTO GetValCom

BTFSS TempE,1

GOTO Get4567

BTFSS TempE,2

GOTO Get89AB

GetCDEF

BSF TempC,2

Get89AB

BSF TempC,3

GOTO GetValCom

Get4567

BSF TempC,2

GetValCom

MOVF TempC,W

ADDWF PCL,F

RETLW 1

RETLW 2

RETLW 3

RETLW 0C

RETLW 4

RETLW 5

RETLW 6

RETLW 0D

RETLW 7

RETLW 8

RETLW 9

RETLW 0E

RETLW 0A

RETLW 0

RETLW 0B

RETLW 0F

SavePorts

MOVF PORTB,W ;save ports routine.

MOVWF PBBuf

MOVLW 0XFF

MOVWF PORTB

BSF STATUS,RP0

BCF OPTION_REG,7

MOVLW B'11110000'

MOVWF TRISB

BCF STATUS,RP0

RETURN

RestorePorts

MOVF PBBuf,W ;restore ports

;routine.

MOVWF PORTB

BSF STATUS,RP0

BSF OPTION_REG,7

CLRF TRISB

BCF STATUS,RP0

RETURN

Chk_Err

MOVF Temp,W ;error checking

;routine.

XORLW 0C ;if error, flagged

;error bit.

BTFSS STATUS,Z

GOTO Next1

BSF Control,Err_Hit

RETURN

Next1

MOVF Temp,W

XORLW 0D

BTFSS STATUS,Z

GOTO Next2

BSF Control,Err_Hit

RETURN

Next2

MOVF Temp,W

XORLW 0E

BTFSS STATUS,Z

GOTO Next3

BSF Control,Err_Hit

RETURN

Next3

BCF Control,Err_Hit

RETURN

Multply BTFSS Control,Mode ;check voltage or

;current?

GOTO MultplyC

MultplyV

MOVF HundredEntry,W ;voltage

;multiplication

;routine.

MOVWF Mulcnd ;input 1st

;multiplicand.

MOVLW B'01100100' ;set multiplier to

;100.

MOVWF Mulplr

CALL Mpy ;call multiply

;process.

MOVF L_Byte,W ;store lower nibble

MOVWF Msb ;to MSB register.

MOVF TenEntry,W

MOVWF Mulcnd ;input 2nd

;multiplicand.

MOVLW B'00001010'

MOVWF Mulplr ;set multiplier to 10

CALL Mpy ;call multiply

;process.

MOVF L_Byte,W ;store lower nibble

MOVWF Lsb ;to LSB register.

MOVF UnitEntry,W

ADDWF Lsb,W ;add registers.

ADDWF Msb,W

MOVWF DOutput ;store result to

;register.

;

;The following routine will check whether the result in DOutput
;register is bigger than 255 or not - Voltage section.

;

MOVF Msb,W ;if the result is

;less than

XORLW 0 ;255, goto Okay.

BTFSC STATUS,Z ;if not, flagged

;error bit.

GOTO OkayV

MOVF Msb,W

XORLW D'100'

BTFSC STATUS,Z

GOTO OkayV

MOVF Msb,W

XORLW D'200'

BTFSC STATUS,Z

GOTO TestLsbV

GOTO OverflowV

TestLsbV

MOVF Lsb,W

ANDLW B'01000000'

XORLW B'00000000'

BTFSS STATUS,Z

GOTO OverflowV

BTFSS Lsb,5

GOTO OkayV

BTFSS Lsb,4

GOTO OkayV

GOTO TestUnitEntryV

TestUnitEntryV

BTFSC Lsb,3

GOTO OverflowV

BTFSC UnitEntry,3

GOTO OverflowV

BTFSS UnitEntry,2

GOTO OkayV

BTFSS UnitEntry,1

GOTO OkayV

GOTO OverflowV

OverflowV

BSF Update_Register,0

BCF Update_Register,7

GOTO Loop1

OkayV

CLRF HundredEntry ;clean up all

;corresponding

CLRF TenEntry ;registers.

CLRF UnitEntry

CLRF Msb

CLRF Lsb

GOTO Finish

MultplyC

MOVF TenEntry,W ;current

;multiplication

;routine.

MOVWF Mulcnd ;input 1st

;multiplicand.

MOVLW B'01100100'

MOVWF Mulplr ;set multiplier to

;100.

CALL Mpy ;call multiply

;process store lower

MOVF L_Byte,W ;nibble to MSB.

MOVWF Msb

MOVF UnitEntry,W

MOVWF Mulcnd ;input 2nd

;multiplicand.

MOVLW B'00001010'

MOVWF Mulplr ;set multiplier to 10

CALL Mpy ;call multiply

;process store lower

MOVF L_Byte,W ;nibble to LSB.

MOVWF Lsb

MOVF Msb,W

ADDWF Lsb,W ;add registers

MOVWF DOutput ;store result in

;register

;The following routine will check whether the result in DOutput
;register is bigger than 255 or not - Current section.

;

MOVF Msb,W ;if the result is

;less than 255,

XORLW 0 ;goto Okay.

BTFSC STATUS,Z ;if not, flagged

;error bit.

GOTO OkayC

MOVF Msb,W

XORLW D'100'

BTFSC STATUS,Z

GOTO OkayC

MOVF Msb,W

XORLW D'200'

BTFSC STATUS,Z

GOTO TestLsbC

GOTO OverflowC

TestLsbC

MOVF Lsb,W

ANDLW B'01000000'

XORLW B'00000000'

BTFSS STATUS,Z

GOTO OverflowC

BTFSS Lsb,5

GOTO OkayC

BTFSS Lsb,4

GOTO OkayC

BTFSS Lsb,3

GOTO OkayC

MOVF Lsb,W

XORLW B'00110010'

BTFSS STATUS,Z

GOTO OverflowC

GOTO OkayC

OverflowC

BSF Update_Register,0

BCF Update_Register,7

GOTO Loop1

OkayC

CLRF HundredEntry ;clean up all

;corresponding

CLRF TenEntry ;registers

CLRF UnitEntry

CLRF Msb

CLRF Lsb

GOTO Finish

Mpy ;multiply process



CLRF H_Byte ;this routine will

;multiply

CLRF L_Byte ;two 8-bit registers

;into a

MOVLW B'00001000' ;16-bit registers

;(multiplier

MOVWF Count ; & multiplicand).

;Since the result

;will not be more

MOVF Mulcnd,W ;than 255, only the

BCF STATUS,Z ;lower nibble of the

;output register is

Loop ;required.



RRF Mulplr,F

BTFSC STATUS,C

ADDWF H_Byte,F

RRF H_Byte,F

RRF L_Byte,F

DECFSZ Count,F

GOTO Loop

RETLW 0



END

Hardware Description

The circuit diagram for the Switching Pre-regulated Power Supply is from
the Everyday with Practical Electronics, April 1994. This power supply
circuitry is based on series voltage regulator design. The heat
dissipation of this design is considerably low due to the added "low
frequency pre-regulator". This pre-regulator reduces the voltage
across the main smoothing capacitor so that it Is never more than 5
volts above the output voltage setting. Hence the amount of power that
needs to be dissipated is fixed to a 5 volts level only. The reference
voltage for the comparator is from the dual DAC (digital-to-analogue
converter) onboard the controller board. This dual DAC convert the 8-bit
digital code from the PIC16C84 microcontroller into an analogue
reference voltage.

The schematic diagram for the power supply board and microcontroller
board are illustrated in the following pages. Below are the PCB layout
for both board.

Fig. 1. P.C.B. layout and wiring diagram for power supply board.

Fig. 2. P.C.B. layout and wiring diagram for the microcontroller board.

Note: Voltage regulator LM7805CT and LM7812CT together with C10 and C11,
which are illustrated on the power supply board schematic diagram, are
mounted on the microcontroller board instead of on the power supply
board.



Components

Power Supply Board

Resistors (? W)



Capacitors

R1, R7, R9 470( R18, R20, R29 1k( C1 10nF 50V ceramic

R2, R8, R11, R24 100( R19 0.1( 3W C2 100(F 50V elect.

R4 10k( R21, R26 1M( C3 470(F 50V elect.

R5, R13, R27 3.3k( R22 39k( C4 6800(F 56V elect.

R6 4.7k( R23 25k( 1% C5 100pF 50V ceramic

R12 68( R25 10k( 1% C6,C8 100nF 50V polyester

R14 47k( R30, R31 2.2k( C7 4.7nF 50V mylar

R15, R28 470k(

C9 4.7(F 30V elect.

R16, R17 1.5k(

C10, C11 100nF 50V ceramic



Semiconductors



Hardware

D1 to D4 1N5402 TR4 BC212 S1 DPST main switch

D5, D6, D8 1N4002 TR5 BC182 SK1 3 pins header

D7, D13 5V6 500mW Zener TR6 IRF530 FS1 1A main fuse

D9 12V 500mW Zener CSR1 TIC106D FS2 4A secondary fuse

D10 15V 500mW Zener IC1 LM324 ME1, ME2 Panel meter 1mA

D11 1N914 IC2 LM7805CT T1 Main transformer

D12 3mm LED IC3 LM7812CT

30V-0V 120VA

TR1, TR2 TIP137





TR3 ZTX650







Microcontroller Board

Resistors (? W)



R1, R2, R3, R4 1k( IC1 DAC0890 8-bit DAC



IC2 PIC16C84-10 8-bit RISC microcontroller

Capacitors



C1 10(F 16V elect. Miscellaneous

C2 100nF 50V ceramic X1 4 MHz crystal

C3, C4 33pF 50V ceramic S1-S16 4x4 matrix keypad



K1, K2 16 pins header

Semiconductors

SK1 3 pins header

D1 3mm LED





Author Information:

Name:

English Name:

Permanent Address:

Correspondence Address:

Email: Tak Meng Cheang

Felix

31, Jalan Bunga Dahlia 7A, Taman Saraya, 56100 Kuala Lumpur, Malaysia.

HYPERLINK mailto:takmeng@usa.net takmeng@usa.net



PAGE

PAGE 1