digitale
Lautstärkeregelung mit dem PGA2310
Hier ein Beispiel
für eine einfache , digitale Lautstärke-Regelung
mit dem IC : PGA2310
Hier die
Schaltung aus dem Datenblatt :

Es werden extern nur ein paar Elkos (100µF ) und
Kondensatoren (100nF) benötigt.
Ausser der positiven und negativen Spannung von min. + - 5V bis max.
+ - 15V für
den analog Teil eine simple Schaltung.
In diesem Beispiel nutze ich ein 16x2 Display als Visualisierung der
eingestellten
Lautstärke und einen Drehgeber als Stellglied.
Eine Routine für Drehgeber ist ja bereits in BASCOM enthalten.
Schaltplan :

Der Code
würde dann wie folgt aussehen :
$regfile = "m8def.dat"
$crystal = 8000000
$hwstack = 40
$swstack = 40
$framesize = 40
Config Spi = Hard , Interrupt = Off , Data Order = msb , Master = Yes ,
Polarity = high , Phase = 0 , Clockrate = 128 , Noss = 0
Spiinit
Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 ,
Db7 = Portd.7 , E = Portd.3 , Rs = Portd.2
Config Lcd = 16 * 2
Cursor Off
Cls
config portb.2 = output
CS alias portb.2
config PORTC.2 = input
Taster_Mute alias pinc.2
portc.2 = 1
config portc.3 = output
Ext_Mute alias portc.3
config PORTC.4 = output
Zero_Crossing alias portc.4
dim Vol_Wert as byte
dim Retval as byte
dim Mute as byte
dim Vol_Alt as byte
dim Volumen as byte
dim LCD_Vol as single
dim Vol as byte
gosub init
do
Retval = Encoder(pinc.0 , Pinc.1 , Minus , Plus , 0)
if Vol_Alt <> Vol_Wert then
Vol_Alt = Vol_Wert
CS = 0
Volumen = Vol_wert + 128
spiout Volumen , 1
spiout Volumen , 1
CS = 1
LCD_Vol = Vol_Wert / 1.26
lcd_Vol = int(LCD_Vol)
Vol = LCD_Vol
locate 2 , 11 : lcd Vol ; " % "
endif
if Taster_Mute = 0 then
do
loop until Taster_Mute = 1
waitms 100
Mute = Mute xor 1
locate 2 , 16
if Mute = 0 then
lcd "M"
else
lcd " "
endif
Ext_Mute = Mute
endif
loop
end
Minus:
if Vol_Wert > 0 then
decr Vol_Wert
endif
return
Plus:
if Vol_Wert < 126 then
incr Vol_Wert
endif
return
init:
locate 1 , 1
lcd "PGA-2310 Regler "
locate 2 , 1
lcd "Volumen
: "
CS = 1
Ext_Mute = 1
Mute = 1
Zero_Crossing = 0
Vol_Wert = 100
Vol_alt = 100
CS = 0
Volumen = Vol_Wert + 128
spiout Volumen , 1
spiout Volumen , 1
CS = 1
LCD_Vol = Vol_Wert / 1.26
LCD_Vol = int(LCD_Vol)
Vol = LCD_Vol
locate 2 , 11 : lcd Vol ; " % "
return