I have been trying to create a RTTY tuning aid similar in function to the Toni Tuna I built years ago. I have been trying to modify Nick12AB's improved bargraph code so that instead of getting a bar graph I get a moving indicator as I sweep the voltage up and down on one of the ADC inputs on my 20M2. I have created new CGRAMs but something is not right. The single pixel wide vertical bar of the display should move smoothly from left to right but it is jerky. As I don't fully understand the operation of Nicks code I am seeking some help.
I have tried both the unique bar graph code and also the linear code but with differing effects, any help gratefully received. This is the first part of my project but need this working properly before I can continue. Copies are posted for perusal.
Nick if you see this and are able and willing, I would really be grateful for an explanation on how the code works.
Hamtech
Other code tried out
I have tried both the unique bar graph code and also the linear code but with differing effects, any help gratefully received. This is the first part of my project but need this working properly before I can continue. Copies are posted for perusal.
Nick if you see this and are able and willing, I would really be grateful for an explanation on how the code works.
Hamtech
Code:
#picaxe 20M2
#no_data
#no_end
DirsB=%11111111
let adcsetup = %0000000000000100 ; set ADC0,1,2,3
symbol enable = C.0
symbol rs = C.1
symbol lcddata=PinsB
symbol readvarA= w1
symbol barvalue=b4
symbol barlength=b5
symbol startposition = b6
symbol startat =b7
Symbol length = b10
symbol charactercounter = b11
symbol loopcounter= b12
init:
dirsB=255
low rs
low enable
lcddata = %00000001: pulsout enable, 608
lcddata = %00000110: pulsout enable, 100
lcddata = %00001100 :pulsout enable, 608
lcddata = %00111011: pulsout enable, 100
setfreq m16
lcddata =64 : pulsout enable, 1
high rs
for loopcounter = 0 to 47
lookup loopcounter,(48,48,48,48,48,48,48,32,40,40,40,40,40,40,40,32,36,36,36,36,36,36,36,32,34,34,34,34,34,34,34,32,33,33,33,33,33,33,33,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
startposition = 128
barlength = 16
startat = 0
main:
readadc c.2, barvalue ' using a variable resistor to change adc input volts
gosub displaybargraph
debug
goto main
displayBargraph:
length = barlength *6 - startat * barvalue/255+startat
low rs
lcddata = startposition: pulsout enable ,1
high rs
charactercounter = barlength
do
if length =>6 then
lcddata = 32: pulsout enable, 1
length = length -6
else if length=5 then
lcddata =11: pulsout enable, 1
length = length - 5
else
exit
end if
dec charactercounter
loop
If length >0 then
lcddata = length +8 :pulsout enable ,1
dec charactercounter
end if
do while charactercounter > 0
lcddata =32: pulsout enable,1
dec charactercounter
loop
return
Other code tried out
Code:
#picaxe 20M2
#no_data
#no_end
DirsB=%11111111
let adcsetup = %0000000000000100 ; set ADC0,1,2,3
symbol enable = C.0
symbol rs = C.1
symbol lcddata=PinsB
symbol readvarA= w1
symbol barvalue=b4
symbol barlength=b5
symbol startposition = b6
symbol startat =b7
Symbol length = b10
symbol charactercounter = b11
symbol loopcounter= b12
init:
dirsB=255
low rs
low enable
lcddata = %00000001: pulsout enable, 608
lcddata = %00000110: pulsout enable, 100
lcddata = %00001100 :pulsout enable, 608
lcddata = %00111011: pulsout enable, 100
setfreq m16
lcddata =64 : pulsout enable, 1
high rs
for loopcounter = 0 to 47
lookup loopcounter,(48,48,48,48,48,48,48,32,40,40,40,40,40,40,40,32,36,36,36,36,36,36,36,32,34,34,34,34,34,34,34,32,33,33,33,33,33,33,33,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
startposition = 192
barlength = 18
startat = 0
main:
readadc c.2, barvalue
gosub displaybargraph
goto main
displayBargraph:
length = barlength -2*3 - startat * barvalue/255+startat
low rs
lcddata = startposition + barlength-1: pulsout enable ,1
high rs
lcddata =10: pulsout enable, 1 ' end
low rs
lcddata = startposition: pulsout enable ,1
high rs
lcddata= 8: pulsout enable, 1 '
charactercounter=barlength -2
do
if length >3 then
lcddata = 32: pulsout enable, 1
length = length -3
else exit
end if
dec charactercounter
loop
If length >0 then
lcddata = length +8 :pulsout enable ,1
dec charactercounter
end if
do while charactercounter > 0
lcddata =32: pulsout enable,1 ' characters to right of end of bargarph display level to bar length (normally set to 8 = a dot)
dec charactercounter
loop
return