Yet another Volume controlers and source selections

Hi dobrivoje,
Iam making test now so in the weekend I post the code for VU with RC5 special
Half-wave rectifier Schmatic
and the video (wma) VIDEO

Here is my Test code !!
Code:
'$sim
$regfile = "m32def.dat"
$crystal = 8000000
$hwstack = 32
$swstack = 30
$framesize = 34
Config Lcdpin = Pin , Db4 = Portc.5 , Db5 = Portc.4 , Db6 = Portc.3 , Db7 = Portc.2 , E = Portc.6 , Rs = Portc.7
Config Lcd = 16 * 2

Cursor Off
Cls

Config Timer1 = Timer , Prescale = 1024
Start Timer1
  Portd.3 = 0
  Input_pin Alias Pind.3                                    ' TSOP1736
  Config Timer0 = Timer , Prescale = 8
  On Timer0 Timer_irq
  Const Timeconst = 78
  Enable Timer0
  Disable Int1
  Enable Interrupts


  Const Samples_early = 8
  Const Samples_late = 12
  Const Samples_min = 3


  Dim Sample As Byte
  Dim Ir_lastsample As Byte
  Dim Ir_bittimer As Byte
  Dim Ir_data_tmp As Word
  Dim Ir_bitcount As Byte



Dim Address_rc5 As Byte , Command_rc5 As Byte , Rc5_flag As Bit

'vu bars
Deflcdchar 1 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16        ' replace ? with number (0-7)
Deflcdchar 2 , 24 , 24 , 24 , 24 , 24 , 24 , 24 , 24        ' replace ? with number (0-7)
Deflcdchar 3 , 28 , 28 , 28 , 28 , 28 , 28 , 28 , 28        ' replace ? with number (0-7)
Deflcdchar 4 , 30 , 30 , 30 , 30 , 30 , 30 , 30 , 30        ' replace ? with number (0-7)
Deflcdchar 5 , 31 , 31 , 31 , 31 , 31 , 31 , 31 , 31        ' replace ? with number (0-7)
Deflcdchar 0 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32        ' replace ? with number (0-7)


Config Adc = Single , Prescaler = Auto , Reference = Internal       ' Avcc
Start Adc

Dim W As Word
Dim Left_vu As Word
Dim L1 As Word
Dim L2 As Byte
Dim L3 As Word
Dim Sel As Byte
Dim Right_vu As Word
Dim R1 As Word
Dim R2 As Single
Dim R3 As Word
Cursor Off
Dim Vol As Byte
Vol = 20
Sel = 1
Cls
Locate 1 , 1
Lcd Version(1)
Locate 2 , 1
Lcd "FarmTech 2010 VU"
Wait 2
Cls
Locate 1 , 1
Lcd "R"
Locate 2 , 1
Lcd "L"
Gosub Select_inp
Locate 2 , 10
Lcd "Vol " ; Vol
 Dim K As Word , K1 As Word
Do


If Rc5_flag = 1 Then

   Reset Rc5_flag
   Command_rc5 = Command_rc5 And &B01111111

   Locate 2 , 3
   Lcd "      "
   Locate 1 , 3
   Lcd "      "

   If Address_rc5 = 0 Then
   Locate 2 , 14
      If Command_rc5 = 16 Then
         Incr Vol                                           'vol+
         If Vol > 99 Then Vol = 99
         If Vol < 10 Then Lcd " "
         Lcd Vol
      End If
      If Command_rc5 = 17 Then
         Decr Vol                                           'vol-
         If Vol < 1 Then Vol = 1
         If Vol < 10 Then Lcd " "
         Lcd Vol
      End If

      If Command_rc5 = 32 Then                              'ch+
      Incr Sel
      Gosub Select_inp
      Waitms 200
      End If
      If Command_rc5 = 33 Then                              'ch-
         Decr Sel
      Gosub Select_inp
       Waitms 200
      End If

      Waitms 50
     Command_rc5 = 255
     Address_rc5 = 255
    End If
    Reset Rc5_flag
End If

  W = Timer1
If W => 20000 And W < 21000 Then
   Locate 1 , 1
   Lcd "R"
   Locate 2 , 1
   Lcd "L"
End If

If W => 29800 And Rc5_flag = 0 Then
   Stop Timer1
   Left_vu = Getadc(2)                                      ' left ch line in  via LM358
   Right_vu = Getadc(3)                                     '  Right ch line in via LM358

    Right_vu = Right_vu - 12  'some noice i have on the line
    Left_vu = Left_vu - 12                                  'some noice i have on the line
    If Right_vu > 1023 Then Right_vu = 0                    'if negativ value
    If Left_vu > 1023 Then Left_vu = 0                      'if negativ value

   Left_vu = Left_vu / 21                                   'temp div factor for adc in from lm358
   Right_vu = Right_vu / 21

   L2 = Left_vu
   R2 = Right_vu

   'Left

   If L2 = 0 Then
      Locate 2 , 3
      Lcd Chr(l3)
      Lcd "     "
   End If
   If L2 => 0 And L2 < 6 Then
      L3 = L2
      Locate 2 , 3
      Lcd Chr(l3)
      Locate 2 , 4
      Lcd "     "
   End If

   If L2 > 5 And L2 < 11 Then
       L3 = L2 - 5
      Locate 2 , 3
      Lcd Chr(5) ; Chr(l3)
      Locate 2 , 5
      Lcd "    "
   End If

   If L2 > 9 And L2 < 16 Then
      L3 = L2 - 10
      Locate 2 , 3
      Lcd Chr(5) ; Chr(5) ; Chr(l3)
      Locate 2 , 6
      Lcd "   "
   End If

   If L2 > 14 And L2 < 21 Then
       L3 = L2 - 15
      Locate 2 , 3
      Lcd Chr(5) ; Chr(5) ; Chr(5) ; Chr(l3)
      Locate 2 , 7
      Lcd "  "
   End If

   If L2 > 19 And L2 < 26 Then
      L3 = L2 - 20
      Locate 2 , 3
      Lcd Chr(5) ; Chr(5) ; Chr(5) ; Chr(5) ; Chr(l3)
      Locate 2 , 8
      Lcd " "
   End If

   If L2 > 24 And L2 < 31 Then
      L3 = L2 - 25
      Locate 2 , 3
      Lcd Chr(5) ; Chr(5) ; Chr(5) ; Chr(5) ; Chr(5) ; Chr(l3)
   End If

   '-------------------------------------------------------------
    'Right

   If R2 => 0 And R2 < 6 Then
      R3 = R2
      Locate 1 , 3
     Lcd Chr(r3)
      Locate 1 , 4
      Lcd "     "
   End If

   If R2 > 4 And R2 < 11 Then
   R3 = R2 - 5
      Locate 1 , 3
      Lcd Chr(5) ; Chr(r3)
      Locate 1 , 5
      Lcd "    "

   End If

   If R2 > 9 And R2 < 16 Then
      R3 = R2 - 10
      Locate 1 , 3
      Lcd Chr(5) ; Chr(5) ; Chr(r3)
      Locate 1 , 6
      Lcd "   "
   End If

   If R2 > 14 And R2 < 21 Then
      R3 = R2 - 15
      Locate 1 , 3
      Lcd Chr(5) ; Chr(5) ; Chr(5) ; Chr(r3)
      Locate 1 , 7
      Lcd "  "
   End If

   If R2 > 19 And R2 < 26 Then
      R3 = R2 - 20
      Locate 1 , 3
      Lcd Chr(5) ; Chr(5) ; Chr(5) ; Chr(5) ; Chr(r3)
      Locate 1 , 8
      Lcd " "

   End If
   If R2 > 24 And R2 < 31 Then
   R3 = R2 - 25
      Locate 1 , 3
      Lcd Chr(5) ; Chr(5) ; Chr(5) ; Chr(5) ; Chr(5) ; Chr(r3)

   End If

 End If

 Loop
 End


Select_inp:
 Locate 1 , 10
 If Sel > 6 Then Sel = 1
 If Sel = 0 Then Sel = 6
 If Sel = 1 Then Lcd "CD   "
 If Sel = 2 Then Lcd "Radio"
 If Sel = 3 Then Lcd "Tape "
 If Sel = 4 Then Lcd "Blu  "
 If Sel = 5 Then Lcd "Video"
 If Sel = 6 Then Lcd "DVD  "
 Return


'New RC5 code
Timer_irq:
  Timer0 = Timeconst
  Sample = Not Input_pin


  If Ir_bittimer < 255 Then Incr Ir_bittimer
  If Ir_lastsample <> Sample Then
  If Ir_bittimer <= Samples_min Then
     Ir_bitcount = 0
  Else
     If Ir_bittimer >= Samples_early Then
         If Ir_bittimer <= Samples_late Then
            Shift Ir_data_tmp , Left , 1
            Ir_data_tmp = Ir_data_tmp + Sample
            Incr Ir_bitcount
          Else
            Ir_bitcount = 1
            Ir_data_tmp = Sample
          End If
          Ir_bittimer = 0
       End If
     End If


     If Ir_bitcount = 1 Then Ir_bitcount = Ir_data_tmp.0
     If Ir_bitcount >= 14 Then
       Timer1 = 0
       Command_rc5 = Ir_data_tmp
       Shift Ir_data_tmp , Right , 6
       Address_rc5 = Ir_data_tmp And &B00011111
       Command_rc5.6 = Not Ir_data_tmp.6
       Command_rc5.7 = Ir_data_tmp.5
       Set Rc5_flag
       Ir_bitcount = 0
       Timer1 = 15000
       Start Timer1
     End If

  End If

  Ir_lastsample = Sample

Return


what software version do you use ?
 
Last edited:
Hi dobrivoje,
Iam making test now so in the weekend I post the code for VU with RC5 special

what software version do you use ?

OK, I can wait until weekend.

Actually, my 8515/PGA controller is not ready yet.
I've made mega16/R2R this spring, it works perfect.
Later on, Danzup kindly made change in firmware on my request, adding bar strip for volume, post #198. I made new, more compact PCB with thru hole components, but didn't finish yet, I had a lot obligations this summer. Danzup is still waiting to see result (sorry, Danzup).
Meanwhile, I started to play with 8515/PGA controller, PCB is still in computer, almost ready. I wanted to implement your firmware with learn RC5, post #277, but it is even better to add VU meter. That's why I'm impatient, I want to finish hardware. Also, I'm not good in programming, so I'm expecting you to finish firmware, my job is only to program 8515.

Greetings and keep on working.
 
Hi dobrivoje,

Thats is a good idea cuz Iam not strong in electronic & pcb

Danzup made a good program , its allways hard to get "the" Idea , but so easy just to copy other , I see if I get time to make the M8535 file with RC5 leran/ level meter this week end ,
think I´ll add a full wave rectifier and sample 128 times ,
this will never be a 100% thue VU meter but think its ok for show some kind of level on lcd

But I need some info on the version that is used cuz there are many here
diffrent lcd setup for M8535/8515 version (M8515 cant do the level meter)
I look at schematic and see ADC 6 , 7 is free on M16 version so this can be used

Just a short update on the meter In4148 is now BAT42 its better and only loos 200mV (1N4148 700mV)
Lm324 is better for full wave rectifier (4 opamps)
I will need 2 pr ch in full wave rectifier

Added the 128 sample to my test code and its smoot on lcd now , cant wait to try full wave rectifier ,

SYL8R / Kim
 
lrc5ok is used in calculation (procedure get_rc5) only
rc5ok is same bit but when you call something you cant use same var_name

procedure eval_rc5 is
get_rc5 (address, command, toogle, rc5ok)

procedure get_rc5 (byte out laddress, byte out lcommand, bit out ltoogle, bit out lrc5ok)

I dont think I say its easy but I point to what you maybe must check is you dont like to set pin high via pullup res ,
 
made a new video of the lcd VIDEO
smooth volume in power on / off & mute (steps volume)
show:
Power on
input select
vol +
vol -
mute on
mute off
power off

now I just wait for Danzup to say "ok" to relase code for M16 R2R

Sorry that I am very busy with some project (atmel avr of course !) (the deadline is next week ) so I have no time to test the code !
If you want you can release the code and when I have time to test it .... I will say .
 
Hi,
Just sent a beta test for M16 R2R to dobrivoje for some beta test
whats new :
Learn RC5
Edit input text
Backlight auto off or On
Vu Meter via Adc6 & 7 LM358
Save settings to eeprom volume, backlight, new RC5 code & new input select text

Lets see what he thinks about it then we publish the code

/Kim
 
Last edited:
Sorry that I am very busy with some project (atmel avr of course !) (the deadline is next week ) so I have no time to test the code !
If you want you can release the code and when I have time to test it .... I will say .

Ok , I just need to know how to setup the Portd.5 for tube amp on after warmup tube time ?
and the jumper for R2R/shont is it just a step 32 or 64 on pin status ?

/Kim
 
I just finished my new code modification and I proudly present my last achievment in programming. :p I solved many problems, and hopefully did not create new.So if somebody see some errors, it would be nice if you talk me about.
 

Attachments

  • preamp_mod4_2.zip
    108.8 KB · Views: 208