Dital Audio selection by Picaxe

hamtech

Member
Digital Audio selection by Picaxe

Digital Voter:


The purpose of this project is use a 28X2 picaxe to choose the strongest audio from three NOAA weather satelite receivers. It works on the basis that the level of audio rises from a low point to a higher point as the satellite receiver rises in the sky until the automatic gain control of the receiver maxes out.
The audio is peak level detected to convert from audio to a varying DC level which is fed to the ADC of the Picaxe. The picaxe then enables one of four switches in a CD4066 to allow the selected audio through to my PC which does the work of decoding the signal, using WXtoIMG software.

The issue I try to resolve is of inaccuracies in my helical antennas that I have made and low signals just over the horizon as the satellite comes into view. Once it is over about 30 degrees over the horizon the strengths are generally very good.

The project uses Nick12AB's bargraph code to display the three varying levels on a LCD display which works on a 4 line parallel LCD - thanks to him for his help and uses the ADCs in the 28X2 for level conversion using a 10 bit resolution.

I have also used the picaxe to have an override switch for my HF Receiver audio when I want to decode RTTY, and other digital modes on my PC. My final design has an override switch for a specific Sat RX R2ZX which has additional filters for NOAA 18 reception which is affecte d by pagers where I live. This is not shown on the circuit as is specific to my needs but just uses the final spare intput and is identical to the HF switch circuitry.

I attach the circuit and the code for your perusal. The code may help some one looking to do something similar, I don't expect too many will receive satelite images from NOAA polar orbiters. I hope it is of interest to some.

You can open the code in PE.
Hamtech
 

Attachments

Last edited:

hamtech

Member
Code:
'This version only uses alternate columns on the LCD/OLED so that the gap between characters goes unnoticed. There are also down/up indicators at the ends of the bargraph so the lcdsize constant must be set to the desired size of the bargraph bit not the length of the LCD.
'Has seperate switches to select HF RX and R2ZX Outputs


#picaxe 28X2
#no_data
#no_end


DirsA=%00000000
DirsB=%11111111
Dirsa=%00000000
Dirsc=%01011111
let adcsetup = %0000000000001111 ; set ADC0,1,2,3

symbol outA   = C.0
symbol outB   = C.1
symbol outC   = C.2
symbol outD   = C.3
symbol enable = C.4
symbol hfsw   = C.5
symbol rs     = C.6


symbol readvarA= w1
symbol readvarB= w2
symbol readvarC= w3
symbol length = b10
symbol loopcounter = b11
symbol charactercounter = b12
symbol endposition = b13
symbol lcddata = pinsB
symbol lcdsize = 18


Table 0,  ("Bob's")
Table 10, ("28X2 PICAXE")
Table 32, ("Digital Voter")
Table 48, ("November 2013")
table 70, ("Voted Output= RX")





symbol index =b15



'Initialise LCD Display

pause 100   ' wait for LCD to reset

low rs     							' set command mode

lcddata = %00110000: pulsout enable, 100	 ' Function  8 bit, 2 line, 5 x 8
pause 15				
lcddata = %00110000: pulsout enable, 100   ' Function  (data transfers by pulsing enable output)
pause 15
lcddata = %00110000: pulsout enable, 100   ' Function  8 bit, 2 line, 5 x 8
pause 5
setfreq m16


lcddata= %00111000 : pulsout enable,10  	' Function again
lcddata= %00000001 : pulsout enable,10	' clear display
pause 10						' wait 10ms
lcddata =%00000010 : pulsout enable,10	' return home to position
lcddata= %00000110 : pulsout enable,10	' set entry mode
pause 10						' wait 10ms
lcddata =%00001100 : pulsout enable,10	; display on, no cursor

' next two lines from bargraph routine 
lcddata = %00111000 : pulsout enable,10	' output 16 = Move cursor left


lcddata = 64	  : pulsout enable,1	' set Graphics address		'
high rs						' set data mode

for loopcounter = 0 to 47
lookup loopcounter,(32,32,32,53,32,32,32,32,32,48,48,53,48,48,32,32,32,52,52,53,52,52,32,32,32,53,53,53,53,53,32,32,34,39,47,49,47,39,34,32,40,60,58,49,58,60,40,32),lcddata
pulsout enable,1   '  sets up user defined grapics 

next

sign_on:   '  Sig on message displays for 5 seconds


 '  Display 1st line message

low RS ' set to command mode
lcddata =128: pulsout enable, 10 ' line 1 position 1
high rs
for index = 0 to 4
readtable index, lcddata: pulsout  enable, 10 ' send charachter to display
next index

'  display 2nd line  message

low RS ' set to command mode
lcddata =192: pulsout enable, 10 ' line 2 position 1
high rs
for index = 10 to 20
readtable index, lcddata: pulsout  enable, 10 ' send charachter to display
next index

' display 3rd line of message

low RS ' set to command mode
lcddata =148: pulsout enable, 10 ' line 3 position 1
high rs
for index = 32 to 44
readtable index, lcddata: pulsout  enable, 10 ' send charachter to display
next index

' display 4th line of message

low RS ' set to command mode
lcddata =212: pulsout enable, 10 ' line 4 position 1
high rs
for index = 48 to 60
readtable index, lcddata: pulsout  enable, 10 ' send charachter to display
next index

Pause 3000

low RS ' set to command mode
lcddata =1: pulsout enable, 10  '  clear screen
high rs

'Voter message 
low rs
lcddata =128: pulsout enable, 10  ' (128-147) line 1 position ($80 + 1-19)
high rs

For index = 69 to 85
READTABLE index, lcddata: pulsout enable,10  ' sending characters to line 1
next index



endposition = lcdsize + 193

'*********************** start of main routine **************************************************

main:
setfreq m16
do

readadc10 A.0, readvarA   ' read ADC 1 input voltage and convert to a decimal value
readadc10 A.1, readvarB  ' read ADC 2 input voltage and convert to a decimal value
readadc10 A.2, readvarC	' read ADC 3 input voltage and convert to a decimal value

pause 100



gosub voting



length = lcdsize * 3 - 1 * readvarA / 1024 + 1

low rs					' set command mode
lcddata = endposition : pulsout enable,1
high rs					' set data mode
lcddata = 13 : pulsout enable,1
low rs					' set command mode
lcddata = 192 : pulsout enable,1 	' set line bargraph is on
high rs					' set data mode


lcddata = 12 : pulsout enable,1	
charactercounter = lcdsize
do
dec charactercounter
if length > 3 then
lcddata = 11 : pulsout enable,1
length = length - 3
else
exit
end if
loop
lcddata = length + 8 : pulsout enable,1

looplabel:
if charactercounter > 0 then
lcddata = 8 : pulsout enable,1
dec charactercounter
else

gosub main2
gosub main3


goto main

end if
goto looplabel


loop





main2:

endposition = lcdsize + 149


length = lcdsize * 3 - 1 * readvarB / 1024 + 1

low rs						' set command mode
lcddata = endposition : pulsout enable,1
high rs						' set data mode
lcddata = 13 : pulsout enable,1
low rs						'set command mode
lcddata = 148 : pulsout enable,1   		' set Line  bargraph is on
high rs					'	set data mode
lcddata = 12 : pulsout enable,1
charactercounter = lcdsize
do
dec charactercounter
if length > 3 then
lcddata = 11 : pulsout enable,1
length = length - 3
else
exit
end if
loop
lcddata = length + 8 : pulsout enable,1

looplabel1:
if charactercounter > 0 then
lcddata = 8 : pulsout enable,1
dec charactercounter

else

return


end if
goto looplabel1


return


main3:
endposition = lcdsize + 213



length = lcdsize * 3 - 1 * readvarC / 1024 + 1

low rs
lcddata = endposition : pulsout enable,1
high rs
lcddata = 13 : pulsout enable,1
low rs
lcddata = 212 : pulsout enable,1   ' Line  bargraph is on
high rs
lcddata = 12 : pulsout enable,1
charactercounter = lcdsize
do
dec charactercounter
if length > 3 then
lcddata = 11 : pulsout enable,1
length = length - 3
else
exit
end if
loop
lcddata = length + 8 : pulsout enable,1

looplabel2:
if charactercounter > 0 then
lcddata = 8 : pulsout enable,1
dec charactercounter
else
return

end if
goto looplabel2
return



  
  
  
  



       

Voting:    ' option 1

If pinc.5 = 1 then ' select HF RX Audio
goto HFAF
end if

if pinc.7 = 1  Then  ' Select R2ZX Rx audio

goto R2ZX
end if



low rs
lcddata = 146: pulsout enable, 10 ' set cursor position
high rs
lcddata = " ": pulsout enable,10 ' send " " to display

if readvarA > readvarB  AND readvarA > readvarC then  ' A is highest

low outB: low outC: low outD:  High outA    ' set Output A high

low rs
lcddata = 145: pulsout enable, 10 ' set cursor position
high rs
lcddata = "A": pulsout enable,10 ' send "A" to display


elseif   readvarB > readvarC  then  ' B is highest 


low outA: low outC: low outD:  High outB   '   Set output B high

low rs
lcddata = 145: pulsout enable, 10 ' set cursor position
high rs
lcddata = "B": pulsout enable,10 ' send "B" to display




else ' C is highest 



Low outA: low outB: low outD:  High outC   '   Set output C high

low rs
lcddata = 145: pulsout enable, 10 ' set cursor position
high rs
lcddata = "C": pulsout enable,10 ' send "C" to display

endif

return



HFAF: ' Manual select HF RX audio

LOW outA: Low outB: low outC: High outD   ' set output D high
low rs
lcddata = 145: pulsout enable, 10 ' set cursor position
high rs
lcddata = "H": pulsout enable,10 ' send "H" to display
lcddata = "F": pulsout enable,10 ' send "F" to display


return


R2ZX:  '  Manual Select R2ZX audio


Low outA: low outB: low outD:  High outC   '   Set output C high

low rs
lcddata = 145: pulsout enable, 10 ' set cursor position
high rs
lcddata = "C": pulsout enable,10 ' send "C" to display

 return
 

hippy

Ex-Staff (retired)
Excellent work. There is a trick for 'voting', finding which of a number of variables holds the highest value, which can simplify the program code and avoid lots of IF comparisons. The MIN operator ( somewhat counter-intuitively ) delivers the highest of two values so you can determine what the highest value is using MIN and then match that with a SELECT CASE ...

Code:
highestValue = readvarA Min readvarB Min readvarC
Select Case highestValue
  Case readvarA: ... ; readvarA was highest
  Case readvarB: ... ; readvarB was highest
  Case readvarC: ... ; readvarC was highest
End Select
 

MPep

Senior Member
Good work.
Just a question, should the transistors for the LEDs not be NPN? You've shown PNPs. Lower left of the schematic.
 

hamtech

Member
Mpep

You are correct! I must have inadvertently picked the wrong transistor shape in Visio. They should all be NPN of course, thanks for the correction.

I will amend the drawing some time soon.
 
Top