Hello all, axe133

I am currently in school with my A-Level teacher, we have my very amazing product all fit and now all we need to do is program. I will upload my product on a later date, we have a problem with the LCD screen as I will need to be displying adc values.

Here is my code so far:
Code:
ReadADC B.1, b1 'read some values
ReadADC B.3, b2
Serout C.5, N2400, ( 254, $80 ) 'Move to first line
Serout C.5, N2400, ( b1,b2) 'Display values
Debug 'Get a real time look.

goto Start_Execution
For some reason it doesnt display the numbers, I think I am getting the asci representation of the values. I literally only want the integer values to be displayed.

Thank you for your time

The Arnewood School
Trevor Boultwood
 

srnet

Senior Member
Use;

Serout C.5, N2400, ( #b1,#b2) 'Display values

But you likely want to add a space between the two values so;

Serout C.5, N2400, ( #b1," ",#b2) 'Display values

Hint: The use of # is described in the manual description of serout, see page 208
 

Technical

Technical Support
Staff member
We'd be tempted to use bintoascii to structure the display better

Code:
ReadADC B.1, b1 'read some values
ReadADC B.3, b2
BinToASCII b1,b10,b11,b12 'convert into 3 ASCII characters
BinToASCII b2,b13,b14,b15
Serout C.5, N2400, ( 254, $80 ) 'Move to first line
Serout C.5, N2400, ( b10,b11,b12," ",b13,b14,b15) 'Display values
Debug 'Get a real time look.

goto Start_Execution
 

nick12ab

Senior Member
If only there was an easy way to replace unwanted leading zeros with spaces, I just dont like the look of 004 as a value on a display.
Yes - use IF statements:
Code:
	readadc adcpin,adcvar
	bintoascii adcvar,bta1,bta2,bta3
	if bta1 = "0" then
		bta1 = " "
		if bta2 = "0" then
			bta2 = " "
		end if
	end if
	serout serpin,N2400,(bta1,bta2,bta3)
bta1,bta2,bta3 and adcvar are byte variables.
 

srnet

Senior Member
I can work out how to do it with extra code.

The firmware (or PE ?) is already making a decision not to print the leading zeros when # is used, would it be that difficult to change to print a space instead ?
 

nick12ab

Senior Member
The firmware (or PE ?) is already making a decision not to print the leading zeros when # is used, would it be that difficult to change to print a space instead ?
I can see no reason why they could not do that. They would have to give this as an option since some people might want the zeros.

They could provide this option the same way that the pwmdiv16/pwmdiv64 option is given in the pwmout command so that existing programs that use the bintoascii command will need no modification to work with newer versions of the compiler. There's nothing worse than finding a code example on the internet for another system (Arduino), copying and pasting it, downloading all the libraries then finding that it doesn't work because 'they' decided to change something in a software update.

ADDED: It would require the interpreter to do more work (to implement leading zero blanking) since currently it can simply break the number down into three digits and add 48 to each of them to make an ASCII character. However Rev-Ed could program the compiler to insert those if statements in after the bintoascii command when compiling if the user specifies that they want leading zero blanking in the bintoascii command and that would mean no changes to the interpreter firmware are needed.
 
Top