Schema: Zener – diode – led tester

Met dit schema kan je een zener / diode / led testen op zijn werking.
Als het een zener is kan men zien op welke spanning hij werkt.
Bij een diode kan men zien wat de spanningsval is.
Bij een led kan men de V forward aflezen.
Ook kan men natuurlijk zien of een component al dan niet stuk is.

https://upload.schematheek.net/images/1186.png

 

 

https://upload.schematheek.net/images/1187.png

De code:

'****************************************************************
'* Name : zener, diode led tester *
'* Author : reddevil *
'* Notice : Copyright (c) 2010 *
'* : All Rights Reserved *
'* Date : 01/08/2010 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************************************
DEVICE 16F877A
XTAL = 20
ALL_DIGITAL = true
TRISA = %000011 ' Configure AN0 (PORTA.0) as an input
TRISB = %00000000
TRISC = %00000000
TRISD = %00000000
TRISE = %000

LCD_DTPIN PORTC.4
LCD_ENPIN PORTC.3
LCD_RSPIN PORTC.2

SYMBOL T0IE = INTCON.5
SYMBOL T0IF = INTCON.2
SYMBOL GIE = INTCON.7
SYMBOL T0CS = OPTION_REG.5

SYMBOL ledpoortd = PORTD

ADCON1 = %10000000
DECLARE ADIN_RES 10
DECLARE ADIN_TAD 32_FOSC
DECLARE ADIN_STIME 100

; instellen van interrupt
OPTION_REG = %00000000
GIE = 0
T0CS = 0
TMR0 = 125
T0IE = 1
GIE = 1 '

DIM t AS WORD
DIM x AS WORD
DIM y AS WORD
DIM poortd AS BYTE

DIM programma AS BYTE
DIM dimwaarde AS BYTE
DIM kontroleprogramma AS BYTE
DIM pwmteller AS BYTE

DIM stroomm AS FLOAT

DIM blauw AS BYTE
DIM groen AS BYTE
DIM rood AS BYTE
DIM spanning AS FLOAT
DIM tussenspanning AS DWORD
DIM tussenstroom AS DWORD
DIM kanaal01 AS BYTE
DIM kanaal02 AS BYTE
DIM kanaal03 AS BYTE
DIM kanaal04 AS BYTE
DIM stroom AS BYTE

DIM led0 AS BYTE
DIM led1 AS BYTE
DIM led2 AS BYTE
DIM led3 AS BYTE

DIM var1 AS WORD
DIM var2 AS WORD
SYMBOL knop_up = PORTB.1
SYMBOL knop_down =PORTB.0

CLEAR
CLS



On_Interrupt GOTO scan
;*************************************************************************
; HOOFDPROGRAMMA
;*************************************************************************
lus2:

display:
rood = 255
PRINT $FE, $40
PRINT $FE,$40,$02,$04,$08,$1F,$02,$14,$18,$1C

PRINT AT 2,1, " REDDEVIL "
PRINT AT 2,13, 0

PRINT AT 1,1, " ZDL-tester "
DELAYMS 2000
CLS
lus:
IF stroom < 10 THEN
PRINT AT 1,12," "
PRINT AT 1,13,DEC stroom
ELSE
PRINT AT 1,12,DEC stroom
ENDIF
rood = 255
blauw = 255
groen = 255
PRINT AT 1,1,"Ingesteld:"
PRINT AT 1,15, "mA"
PRINT AT 2,6, "mA"
PRINT AT 2,16, "V"
var1 = ADIN 0
DELAYMS 50
var2 = ADIN 1
DELAYMS 50

stroomm= 0.0308791 * var1
spanning = 0.05160* var2
;PRINT AT 2,11,DEC4 var1
;PRINT AT 2,1,DEC4 var2
PRINT AT 2,11,DEC4 spanning
PRINT AT 2,1,DEC4 stroomm


GOSUB drukknop
GOTO lus
drukknop:
IF knop_up = 1 THEN
INC stroom
IF stroom > 20 THEN stroom = 0
IF stroom < 10 THEN
PRINT AT 1,12," "
PRINT AT 1,13,DEC stroom
ELSE
PRINT AT 1,12,DEC stroom
ENDIF
GOSUB tabel
DELAYMS 25
WHILE knop_up = 1 : WEND
ENDIF

IF knop_down = 1 THEN
DEC stroom
IF stroom < 0 THEN stroom = 20
IF stroom < 10 THEN
PRINT AT 1,12," "
PRINT AT 1,13,DEC stroom
ELSE
PRINT AT 1,12,DEC stroom
ENDIF
GOSUB tabel
DELAYMS 25
WHILE knop_down = 1 : WEND
ENDIF
RETURN

tabel:
SELECT stroom
CASE 0: kanaal01 = 0
CASE 1: kanaal01 = 12
CASE 2: kanaal01 = 25
CASE 3: kanaal01 = 38
CASE 4: kanaal01 = 51
CASE 5: kanaal01 = 64
CASE 6: kanaal01 = 76
CASE 7: kanaal01 = 89
CASE 8: kanaal01 = 102
CASE 9: kanaal01 = 115
CASE 10: kanaal01 = 127
CASE 11: kanaal01 = 140
CASE 12: kanaal01 = 153
CASE 13: kanaal01 = 166
CASE 14: kanaal01 = 178
CASE 15: kanaal01 = 191
CASE 16: kanaal01 = 204
CASE 17: kanaal01 = 217
CASE 18: kanaal01 = 230
CASE 19: kanaal01 = 242
CASE 20: kanaal01 = 255
ENDSELECT
RETURN
GOTO lus

;************************************************************************
;************************************************************************
;****** Interrupt routine PWM sturing ******
;************************************************************************
scan:

kanaal02 = rood
kanaal03 = groen
kanaal04 = blauw
TMR0 = 125 ;75Hz = '255-((kristal/8)/255)/75Hz' eerst 125
ASM

INCF pwmteller,f
MOVF pwmteller,w
XORLW 255
BNZ leds

CLRF pwmteller
MOVLW 255
MOVWF poortd

MOVF kanaal01,w
MOVWF led0
MOVF kanaal02,w
MOVWF led1
MOVF kanaal03,w
MOVWF led2
MOVF kanaal04,w
MOVWF led3

leds:
NOP
NOP
MOVF pwmteller,W
XORWF led0,W
SKPNZ
BCF poortd,0
MOVF pwmteller,W
XORWF led1,W
SKPNZ
BCF poortd,1
MOVF pwmteller,W
XORWF led2,W
SKPNZ
BCF poortd,2
MOVF pwmteller,W
XORWF led3,W
SKPNZ





MOVF poortd,W
MOVWF ledpoortd



ENDASM

T0IF = 0

CONTEXT RESTORE
END

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

Ingestuurd door: reddevil

Een reactie achterlaten

Your email address will not be published.