Lcd rtty tuning aid

hamtech

Member
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





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
 

papaof2

Senior Member
Wouldn't an LED bargraph with directly driven segments have faster response than an LCD? It also avoids the problem of creating the proper characters - which seems to be a challenge for many users.
 

radiogareth

Senior Member
Wouldn't an LED bargraph with directly driven segments have faster response than an LCD? It also avoids the problem of creating the proper characters - which seems to be a challenge for many users.
Yes and no - LEDs would draw more current so for portable (away from mains use) I can see the attraction - also a lot more user-configurable plus messages etc. I'm also trying to get my head around Nicks code - just for a couple of side by side bars on a 16*2 AXE133, so I'm reading with interest :)
 

AllyCat

Senior Member
Hi,

The single pixel wide vertical bar of the display should move smoothly from left to right but it is jerky.
What if you increase the frequency to m32 ? Is it then acceptable, or at least much less jerky? If not then either there is a bug / application error, or it's just not a sensible method / hardware to use.

It may be possible to speed up the code somewhat, but probably only at the expense of readability of the source code.

Cheers, Alan.
 

hamtech

Member
Yes and no - LEDs would draw more current so for portable (away from mains use) I can see the attraction - also a lot more user-configurable plus messages etc. I'm also trying to get my head around Nicks code - just for a couple of side by side bars on a 16*2 AXE133, so I'm reading with interest :)

I have already got three of nicks bargraphs running on one display side by side see my idigital voter project.

This differs in that i want to display a vertical bar one pixel wide and eventually the position of the single vertical bar will be frequency related via freq to voltage converting chip. I have got the bar moving but it appears to jump some character positions and although i have created the new cgrams. They don't all appear to get used by the program. Hence the need to understand nicks code's workings - which i don't fully understand. Once i have a smooth sweep up the scale also given there are gaps between characters, i will try to display the bar many times a second so that it appears that there are two bars showing which move. The mark and space voltages. But first things first, i need to resolve this issue with the movement created by the adc reading a varying voltage on the input. Hope that explains things abit better.

Hamtech
 

Paix

Senior Member
I was a member of the BARTG back for quite a number of yeardin the day when G2FUD Arthur Owen was Secretary, it was then known as the British Amateur Radio Teleprinter Group and 88mH toroids were king.

I think that this was almost pre ST5 Terminal Unit days, but had an interest in all those things and remember when the now lowly 709 op amp was a new kid on the block

@Hamtech, where are you taking your signal for your tuner, a composite audio signal from the receiver or the output of a discriminator or filters?
I'm not sure what form your tuning aid will take or actually indicate in the amplitude/frequency domain?

Normaly information as to frequency balance of the tones is a handy thing to have as well as the apparent instantaneous amplitude of the tones to show not only correct tuning, but fast fading of individual tones too.
 

hamtech

Member
I was a member of the BARTG back for quite a number of yeardin the day when G2FUD Arthur Owen was Secretary, it was then known as the British Amateur Radio Teleprinter Group and 88mH toroids were king.

I think that this was almost pre ST5 Terminal Unit days, but had an interest in all those things and remember when the now lowly 709 op amp was a new kid on the block

@Hamtech, where are you taking your signal for your tuner, a composite audio signal from the receiver or the output of a discriminator or filters?
I'm not sure what form your tuning aid will take or actually indicate in the amplitude/frequency domain?
The display will display a freq as in the toni tuna. Goes a bit like this......
Audio op from my hf rig, feeds into freq to volts convert chip , in my toni tuna it was a 9400 but they are not avilable. Now planning to use lm2917 i think it is. Same sort of chip and it will provide a varying dc which will feed to the adc input of my 20m2 picaxe.
It may not be possible to get the display i want but i will only find out by trying, and anyway, i cant see why it won't work. It will require fast switching to fool the eye as the toni tuna does. This is for fun really but i am inquisitive and would like to see this working!
 

hamtech

Member
Alley cat

I don't believe it is s speed issue, i think it is something wrong with the code. I have modifed nick12ab's code but may not have got it right. Certainly his code as posted works very well. It is how i have amended it for my purpose is the problem. Only i can't see what is up.
 

AllyCat

Senior Member
Hi,

Code:
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
I don't know what nick wrote and haven't checked the remainder of your code, but I can tell you that the above will execute S-L-O-W-L-Y (in terms of a video display). The PICaxe interpreter (which is relatively slow anyway) receives it from the PE as a string of 56 IF.... THENs (which are always ALL executed).

EDIT: Ah, it doesn't appear to be in the main loop so maybe not the fundamental problem.
EDIT2: Have you left the (very slow) DEBUG in the main loop?

Cheers, Alan.
 
Last edited:

Rick100

Senior Member
You appear to have 56 entries in your lookup table but only loop through 48 times. I don't think that's your problem though. I tried your redefined characters in this LCD simulator and it looks like you redefined them right.
lcd_snip.JPG

I'm not sure why bit 5 of the new characters is always set, but I probably missed something in the code. I think Nicks original code will require a few modifications.

Good luck,
Rick
 
Last edited:

hippy

Technical Support
Staff member
I'm not sure why bit 5 of the new characters is always set, but I might have missed something in the code.
That's usually done to avoid a CGRAM byte definition of zero ( or other low values ) sent to a serial-to-LCD controller being interpreted as a command for the controller rather than CGRAM data to be passed to the display.

The display ignores bits 5, 6 and 7 when programming CGRAM so it's not necessary in the case of direct drive of LCD but should do no harm. Setting bits 5 to 7 as zero will however reduce the memory space used by the LOOKUP.
 

Rick100

Senior Member
That's usually done to avoid a CGRAM byte definition of zero ( or other low values ) sent to a serial-to-LCD controller being interpreted as a command for the controller rather than CGRAM data to be passed to the display.
Thanks hippy. I found what you were referring to in the axe033 datasheet.
 

srnet

Senior Member
I have been trying to create a RTTY tuning aid similar in function to the Toni Tuna I built years ago.
I am intrigued as to the reason for the RTTY tuning aid, as these data even a humble low power netbook PC will do a very good job of decoding RTTY, no real need to tune it either as the the software has a very good AFC.

Sent you a PM.
 

hamtech

Member
I have almost achieved a result. I now get four of the five pixel column lit one by one. What is strange is that the first column does not light. Further more once the fifth column of the 5x8 pixels lights the software jumps it back one column before then jumping to column two of the next character. I am simply using a for next loop to generate the movement for the pixel movement. But I cannot see what is wrong, any one can help ???

here is the code I am using and my cgrams.

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

for barvalue = 1 to 255
gosub displaybargraph
 
pause 700 'so I can see what is happening

next
goto  main









displayBargraph:
	
	length = barlength *6 * barvalue/255
	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
 

Rick100

Senior Member
Code:
displayBargraph:
	length = barlength * 5 * barvalue/255
      
   lcddata = startposition	'set cursor for first character
   gosub SendCmdByte
   
	charactercounter = barlength
 
	do
	if length > 5 then	'print leading spaces
		lcddata = 32
		gosub SendDataByte
		length = length - 5
	else
		exit
	end if
	dec charactercounter
	loop

	
	if length > 0 then
		lcddata = length + 7	'determine which custom character
		gosub SendDataByte
		dec charactercounter
	end if
	
	do while charactercounter > 0
		lcddata = 32	' zero bars
		gosub SendDataByte
		dec charactercounter
	loop
	
	return
Hello hamtech. I had a i2c lcd display set up on my breadboard, so I tried your code. I made a few changes in the 'displayBargraph' routine and got it to work. You will have to change the 'gosub SendDataByte' and 'gosub SendCmdByte' lines back to control your parallel lcd. For the 'gosub SendDataByte' you need add back in the 'high rs' and 'pulsout enable ,1' . For the 'gosub SendCmdByte' you need add back in the 'low rs' and 'pulsout enable ,1' .

Good luck,
Rick
 

hippy

Technical Support
Staff member
But I cannot see what is wrong, any one can help ???
You can add SERTXD or DEBUG commands so you see what is happening in your program and what values variables have or you can simulate the program to see what is going on.
 

radiogareth

Senior Member
I'd be interested to see the whole listing as I'm working on a dual bar on an AXE133, nothing special, just working on it.
 
Top