Eine bekannte Situation, man ist im Auto unterwegs und die Batterie vom Smartphone ist leer. Da braucht man eine Spannungsversorgung mit USB-Buchse. Im Prinzip ganz einfach, ein Stecker fürs Auto, ein 7805 und eine USB Buchse. Dazu noch ein Voltmeter und eine Stromanzeige und es ist komplett. Das Voltmeter zeigt die Batteriespannung (oben) und die Ausgangsspannung (unten links) und den Ausgangsstrom in mA (unten rechts).
So kann man es aufbauen, die rote Led wird von der Eingangsspannung betrieben und soll das Display beleuchten. Links ist die USB Buchse, in der Mitte der 7805 auf einem Kühlblech und rechts das Voltmeter. Der ATMega48 ist unter dem Display.
Das kleine Gerät kann man im Auto verwenden oder auch zu Hause mit einem 12 V Steckernetzteil. So kann man die Batterien im Smartphone überall aufladen.
Download: DVMLCDsm3.zip
'***************************************************************************
' ATMega48 USB +5V pwr supply with small LCD display
' digital volt/mAmeter
'
' 7 - 22 V to measure Voltage ingoing, to 7805
' 0 - 11 V to measure 7805 voltage out
' 0 - 11 V to measure voltage behind resistor R
' I = (adc(5)-adc(3)/R gives current in mA
' R = 4.7 Ohm (7 33 Ohm parallel)
'
' 4 ADC readings / channel 3 4 5, Reference = internal (1.077 V)
' running average
' 10k /90k divider ADC channel adc(5) 0 - 11 V +5V
' 4.7k/90k divider ADC channel adc(4) 0 - 22 V +12V in
' 10k /90k divider ADC channel adc(3) 0 - 11 V +5V out
' calibrate factor: volts / ADC count
' RS232 output on comd.1 for 3 voltages
'
' small LCD display:
' 12345678
' --------
' 12.00 V
' 5.00 000
' --------
'
' GS 3-2011, updated 5-2014
'
' This program is free software; you can redistribute it and/or
' modify it under the terms of the GNU General Public License.
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY;
'
'***************************************************************************
' ATMega48 PDIP
'
' (PCINT14/RESET) PC6 1 28 PC5 (ADC5/SCL/PCINT13)
' (PCINT16) PD0 2 27 PC4 (ADC4/SDA/PCINT12)
' (PCINT17) PD1 3 26 PC3 (ADC3/PCINT11)
' (PCINT18/INT0) PD2 4 25 PC2 (ADC2/PCINT10)
' (PCINT19/INT1) PD3 5 24 PC1 (ADC1/PCINT9)
' (PCINT20/T0) PD4 6 23 PC0 (ADC0/PCINT8)
' VCC 7 22 GND
' GND 8 21 PC7 (PCINT15) (Vref)
' (PCINT6/CLKI) PB6 9 20 AVCC
' (PCINT7) PB7 10 19 PB5 (SCK/PCINT5)
' (PCINT21/T1) PD5 11 18 PB4 (MISO/PCINT4)
' (PCINT22/AIN0) PD6 12 17 PB3 (MOSI/PCINT3)
' (PCINT23/AIN1) PD7 13 16 PB2 (SS/OC1B/PCINT2)
' (PCINT0/CLKO/ICP1)PB0 14 15 PB1 (OC1A/PCINT1)
'
'***************************************************************************
' Hardware: LCD-Display B port
' Pins ATMega48:
' R/S PortB 5 Lcd pin 4
' E PortB 4 Lcd pin 6
' DB4 PortB 3 Lcd pin 7
' DB5 PortB 2 Lcd pin 8
' DB6 PortB 1 Lcd pin 9
' DB7 PortB 0 Lcd pin 10
$regfile = "m48def.dat"
$crystal = 1000000
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 10 ' default use 10 for the SW stack
$framesize = 40 ' default use 40 for the frame space
'$baud = 9600
'*********************************************************************
Mpulse Alias Portd.7
Const Calfactor4 = 2187 'calibrate adc(4)
Const Calfactor5 = 1080 'calibrate adc(5)
Const Calfactor3 = 1080 'calibrate adc(3)
Const Calfactorma = 238 'calibrate mA adc(5-3)
Dim I As Byte , N As Byte
Dim W As Word
Dim Ad As Integer
Dim Adch3 As Long
Dim Adch4 As Long
Dim Adch5 As Long
Dim Avgvalue5 As Word
Dim Avgvalue4 As Word
Dim Avgvalue3 As Word
Dim S As String * 10
Dim S4 As String * 6
Dim S5 As String * 6
Dim S3 As String * 6
'*********************************************************************
Config Lcd = 16 * 1a
Config Lcdpin = Pin , Db7 = Portb.0 , Db6 = Portb.1 , Db5 = Portb.2 , Db4 = Portb.3 , E = Portb.4 , Rs = Portb.5
Ddrb = &B00111111
Portb = &B00000000
Ddrc = &B00000111
Portc = &B00000000
Didr0 = &B00111000 'ch1 3 4 & 5 M48 only
Ddrd = &B10011110
Portd = &B11011111
Config Adc = Single , Prescaler = Auto , Reference = Internal '1.1 V
Start Adc
'Enable Interrupts
'*********************************************************************
Waitms 500
Lcd "GS DVM"
Wait 2
Cls
Cursor Off
Open "comd.1:9600,8,n,1,INVERTED" For Output As #1
Do
' measure voltage loop, all in one
Mpulse = 1
W = 0
Adch4 = 0 ' V Getadc(4)
For N = 1 To 4 ' get ch 4
W = Getadc(4)
Adch4 = Adch4 + W
Next N
Shift Adch4 , Right , 2 ' div 4
Avgvalue4 = Avgvalue4 * 3 ' (Avgvalue*3 + Currentvalue)/4
Avgvalue4 = Avgvalue4 + Adch4
Shift Avgvalue4 , Right , 2 ' running average
Adch4 = Avgvalue4 * Calfactor4 ' volt/count, calibrate
Adch4 = Adch4 / 1000
S4 = Str(adch4)
S4 = Format(s4 , " 0.00")
S4 = S4 + " V"
W = 0
Adch5 = 0 ' V Getadc(5) 0 - 11 V
For N = 1 To 4 ' get ch 5
W = Getadc(5)
Adch5 = Adch5 + W
Next N
Shift Adch5 , Right , 2 ' div 4
Avgvalue5 = Avgvalue5 * 3 ' (Avgvalue*3 + Currentvalue)/4
Avgvalue5 = Avgvalue5 + Adch5
Shift Avgvalue5 , Right , 2 ' running average
Adch5 = Avgvalue5 * Calfactor5 ' volt/count, calibrate
Adch5 = Adch5 / 1000
Ad = Adch5
S5 = Str(adch5)
S5 = Format(s5 , "0.00")
'S5 = S5 + "V"
W = 0
Adch3 = 0 ' V Getadc(3) 0 - 11 V
For N = 1 To 4 ' get ch 3
W = Getadc(3)
Adch3 = Adch3 + W
Next N
Shift Adch3 , Right , 2 ' div 4
Avgvalue3 = Avgvalue3 * 3 ' (Avgvalue*3 + Currentvalue)/4
Avgvalue3 = Avgvalue3 + Adch3
Shift Avgvalue3 , Right , 2 ' running average
Adch3 = Avgvalue3 * Calfactor3 ' volt/count, calibrate
Adch3 = Adch3 / 1000
S3 = Str(adch3)
S3 = Format(s3 , "0.00")
'S3 = S3 + " V"
Ad = Ad - Adch3 ' adc5 - adc3
Ad = Abs(ad)
Ad = Ad * Calfactorma ' current I = U / R
Ad = Ad / 100
S = Str(ad)
S = Format(s , " ")
Mpulse = 0
Home Upper
Lcd S4 ' display Volt in
Lowerline ' select the lower line
Lcd S3 ' display Volt out
Locate 2 , 6
Lcd S ' display mA
'Waitms 400
'S1 = Str(Adch4)
'S2 = Str(Adch5)
Print #1 , S4 ; ";" ; S5 ; ";" ; S3
Loop ' do again
'*********************************************************************
End