Using an LCD Display

#1
Hi,

I need some help for a project I am doing using PICAXE and an LCD display. I am using logicator to program the chip.

On the LCD display, I need 6 random numbers to be displayed. Two of them need to be 2-digit numbers, and the other four need to be 1-digit numbers.

On the first line of the LCD display, I want it to show the random number being selected for each of the six numbers. After it has generated the random number on line 1, I want that number to be put onto line 2, and for line 1 to then display the next random number. After the second number has been generated on line 1, I would like it to be moved to line 2. This will happen until 6 random numbers are shown on line 2, and line 1 to be empty (as line 1 is only used to display each number as it is being generated).

Please Help me program the chip,

Thanks
 
#2
Welcome to the forum.
I don't use logicator so can't be of specific help.
However, to get a better response it would be a good idea to be more specific with your question.
What have you done so far?
Are you confident about generating the random numbers and just need help displaying them?
Which LCD display? Serial, parallel, 8-bit, 4-bit, I2C, SPI or other?
 
#3
Welcome to the forum.
I don't use logicator so can't be of specific help.
However, to get a better response it would be a good idea to be more specific with your question.
What have you done so far?
Are you confident about generating the random numbers and just need help displaying them?
Which LCD display? Serial, parallel, 8-bit, 4-bit, I2C, SPI or other?
Thanks for your reply,

I am using the LCD display shown on this link: http://www.picaxe.com/Hardware/Add-on-Modules/Budget-Serial-OLED-Module/

So far, I have managed to display random numbers on the screen, I just need it to display the numbers in the manner shown on my first post.

Thanks
 
#5
Please post your current logicator program.

Can you then post the program,
after conversion to BASIC.

e
View attachment Initial Ideas Flow Chart.plf View attachment Initial Ideas Flow Chart BASIC.bas

Here I have attached the program in logicator and one converted to BASIC. I have found a solution to complete my problem, however, the variables are displayed on the LCD display as 3 digits for example, 1 is displayed as 001. This means I can only add 2 variables to the second line and not 6 as I need it due to lack of space.
 
#6
Thanks for posting.

1. Which model of PICAXE is the controller?

2. I've posted the code to make it easier for others to read.

Code:
'BASIC converted from Logicator for PICAXE flowsheet:
 'N:\Electronics\Initial Ideas Flow Chart.plf
 'Converted on 8/10/2014 at 13:10:12
  ;Symbols 
 {
 symbol varA = b0
 symbol varB = b1
 symbol varC = b2
 symbol varD = b3
 symbol varE = b4
 symbol varF = b5
 symbol varG = b6
 symbol varH = b7
 symbol varI = b14
 symbol varJ = b15
 symbol varK = b16
 symbol varL = b17
 symbol varM = b18
 symbol varN = b19
 symbol varO = b20
 symbol varP = b21
 symbol varQ = b22
 symbol varR = b23
 symbol varS = b24
 symbol varT = b25
 symbol timer = time
 }
   
 let dirsB = %11111111
   
 main:
 label_7:	random w6	'store random number in w6 (b13:b12)
 		let varA = b13	'Random command
 		if pinC.2 = 1 then label_97	'Decision command
 		goto label_7
  label_97:
 		if varA <= 28 then label_87	'Compare command
 		if varA <= 57 then label_88	'Compare command
 		if varA <= 85 then label_89	'Compare command
 		if varA <= 113 then label_90	'Compare command
 		if varA <= 142 then label_91	'Compare command
 		if varA <= 170 then label_92	'Compare command
 		if varA <= 198 then label_93	'Compare command
 		if varA <= 227 then label_94	'Compare command
 		let varA = 9  	'Expression command
 		bintoascii varA,b8,b9,b10
 		serout 7,N2400_4,(254,128,b8,b9,b10,"             ")
 	bintoascii varA,b8,b9,b10
 			serout 7,N2400_4,(254,192,b8,b9,b10,"             ")
 		gosub prc_NUMBER1	'Do Procedure 
 		bintoascii varB,b8,b9,b10
 		serout 7,N2400_4,(254,128,b8,b9,b10,"             ")
 	bintoascii varA,b8,b9,b10
 		bintoascii varB,b11,b12,b13
 			serout 7,N2400_4,(254,192,b8,b9,b10,",",b11,b12,b13,"         ")
 		gosub prc_NUMBER2	'Do Procedure 
 loop0:
 		goto loop0
  prc_NUMBER2:
 		random w6	'store random number in w6 (b13:b12)
 		let varC = b13	'Random command
 		if varC <= 28 then label_135	'Compare command
 		if varC <= 57 then label_136	'Compare command
 		if varC <= 85 then label_137	'Compare command
 		if varC <= 113 then label_138	'Compare command
 		if varC <= 142 then label_139	'Compare command
 		if varC <= 170 then label_140	'Compare command
 		if varC <= 198 then label_141	'Compare command
 		if varC <= 227 then label_142	'Compare command
 		let varC = 9  	'Expression command
 label_144:	return		'Return 
  label_142:
 		let varC = 8  	'Expression command
 		goto label_144
  label_141:
 		let varC = 7  	'Expression command
 		goto label_144
  label_140:
 		let varC = 6  	'Expression command
 		goto label_144
  label_139:
 		let varC = 5  	'Expression command
 		goto label_144
  label_138:
 		let varC = 4  	'Expression command
 		goto label_144
  label_137:
 		let varC = 3  	'Expression command
 		goto label_144
  label_136:
 		let varC = 2  	'Expression command
 		goto label_144
  label_135:
 		let varC = 1  	'Expression command
 		goto label_144
  prc_NUMBER1:
 		random w6	'store random number in w6 (b13:b12)
 		let varB = b13	'Random command
 		if varB <= 28 then label_58	'Compare command
 		if varB <= 57 then label_59	'Compare command
 		if varB <= 85 then label_60	'Compare command
 		if varB <= 113 then label_61	'Compare command
 		if varB <= 142 then label_62	'Compare command
 		if varB <= 170 then label_63	'Compare command
 		if varB <= 198 then label_64	'Compare command
 		if varB <= 227 then label_65	'Compare command
 		let varB = 9  	'Expression command
 label_106:	return		'Return 
  label_65:
 		let varB = 8  	'Expression command
 		goto label_106
  label_64:
 		let varB = 7  	'Expression command
 		goto label_106
  label_63:
 		let varB = 6  	'Expression command
 		goto label_106
  label_62:
 		let varB = 5  	'Expression command
 		goto label_106
  label_61:
 		let varB = 4  	'Expression command
 		goto label_106
  label_60:
 		let varB = 3  	'Expression command
 		goto label_106
  label_59:
 		let varB = 2  	'Expression command
 		goto label_106
  label_58:
 		let varB = 1  	'Expression command
 		goto label_106
  label_94:
 		let varA = 8  	'Expression command
 		bintoascii varA,b8,b9,b10
 		serout 7,N2400_4,(254,128,b8,b9,b10,"             ")
 	bintoascii varA,b8,b9,b10
 			serout 7,N2400_4,(254,192,b8,b9,b10,"             ")
 		gosub prc_NUMBER1	'Do Procedure 
 		bintoascii varB,b8,b9,b10
 		serout 7,N2400_4,(254,128,b8,b9,b10,"             ")
 	bintoascii varA,b8,b9,b10
 		bintoascii varB,b11,b12,b13
 			serout 7,N2400_4,(254,192,b8,b9,b10,",",b11,b12,b13,"         ")
 		gosub prc_NUMBER2	'Do Procedure 
 loop1:
 		goto loop1
  label_93:
 		let varA = 7  	'Expression command
 		bintoascii varA,b8,b9,b10
 		serout 7,N2400_4,(254,128,b8,b9,b10,"             ")
 	bintoascii varA,b8,b9,b10
 			serout 7,N2400_4,(254,192,b8,b9,b10,"             ")
 		gosub prc_NUMBER1	'Do Procedure 
 		bintoascii varB,b8,b9,b10
 		serout 7,N2400_4,(254,128,b8,b9,b10,"             ")
 	bintoascii varA,b8,b9,b10
 		bintoascii varB,b11,b12,b13
 			serout 7,N2400_4,(254,192,b8,b9,b10,",",b11,b12,b13,"         ")
 		gosub prc_NUMBER2	'Do Procedure 
 loop2:
 		goto loop2
  label_92:
 		let varA = 6  	'Expression command
 		bintoascii varA,b8,b9,b10
 		serout 7,N2400_4,(254,128,b8,b9,b10,"             ")
 	bintoascii varA,b8,b9,b10
 			serout 7,N2400_4,(254,192,b8,b9,b10,"             ")
 		gosub prc_NUMBER1	'Do Procedure 
 		bintoascii varB,b8,b9,b10
 		serout 7,N2400_4,(254,128,b8,b9,b10,"             ")
 	bintoascii varA,b8,b9,b10
 		bintoascii varB,b11,b12,b13
 			serout 7,N2400_4,(254,192,b8,b9,b10,",",b11,b12,b13,"         ")
 		gosub prc_NUMBER2	'Do Procedure 
 loop3:
 		goto loop3
  label_91:
 		let varA = 5  	'Expression command
 		bintoascii varA,b8,b9,b10
 		serout 7,N2400_4,(254,128,b8,b9,b10,"             ")
 	bintoascii varA,b8,b9,b10
 			serout 7,N2400_4,(254,192,b8,b9,b10,"             ")
 		gosub prc_NUMBER1	'Do Procedure 
 		bintoascii varB,b8,b9,b10
 		serout 7,N2400_4,(254,128,b8,b9,b10,"             ")
 	bintoascii varA,b8,b9,b10
 		bintoascii varB,b11,b12,b13
 			serout 7,N2400_4,(254,192,b8,b9,b10,",",b11,b12,b13,"         ")
 		gosub prc_NUMBER2	'Do Procedure 
 loop4:
 		goto loop4
  label_90:
 		let varA = 4  	'Expression command
 		bintoascii varA,b8,b9,b10
 		serout 7,N2400_4,(254,128,b8,b9,b10,"             ")
 	bintoascii varA,b8,b9,b10
 			serout 7,N2400_4,(254,192,b8,b9,b10,"             ")
 		gosub prc_NUMBER1	'Do Procedure 
 		bintoascii varB,b8,b9,b10
 		serout 7,N2400_4,(254,128,b8,b9,b10,"             ")
 	bintoascii varA,b8,b9,b10
 		bintoascii varB,b11,b12,b13
 			serout 7,N2400_4,(254,192,b8,b9,b10,",",b11,b12,b13,"         ")
 		gosub prc_NUMBER2	'Do Procedure 
 loop5:
 		goto loop5
  label_89:
 		let varA = 3  	'Expression command
 		bintoascii varA,b8,b9,b10
 		serout 7,N2400_4,(254,128,b8,b9,b10,"             ")
 	bintoascii varA,b8,b9,b10
 			serout 7,N2400_4,(254,192,b8,b9,b10,"             ")
 		gosub prc_NUMBER1	'Do Procedure 
 		bintoascii varB,b8,b9,b10
 		serout 7,N2400_4,(254,128,b8,b9,b10,"             ")
 	bintoascii varA,b8,b9,b10
 		bintoascii varB,b11,b12,b13
 			serout 7,N2400_4,(254,192,b8,b9,b10,",",b11,b12,b13,"         ")
 		gosub prc_NUMBER2	'Do Procedure 
 loop6:
 		goto loop6
  label_88:
 		let varA = 2  	'Expression command
 		bintoascii varA,b8,b9,b10
 		serout 7,N2400_4,(254,128,b8,b9,b10,"             ")
 	bintoascii varA,b8,b9,b10
 			serout 7,N2400_4,(254,192,b8,b9,b10,"             ")
 		gosub prc_NUMBER1	'Do Procedure 
 		bintoascii varB,b8,b9,b10
 		serout 7,N2400_4,(254,128,b8,b9,b10,"             ")
 	bintoascii varA,b8,b9,b10
 		bintoascii varB,b11,b12,b13
 			serout 7,N2400_4,(254,192,b8,b9,b10,",",b11,b12,b13,"         ")
 		gosub prc_NUMBER2	'Do Procedure 
 loop7:
 		goto loop7
  label_87:
 		let varA = 1  	'Expression command
 		bintoascii varA,b8,b9,b10
 		serout 7,N2400_4,(254,128,b8,b9,b10,"             ")
 	bintoascii varA,b8,b9,b10
 			serout 7,N2400_4,(254,192,b8,b9,b10,"             ")
 		gosub prc_NUMBER1	'Do Procedure 
 		bintoascii varB,b8,b9,b10
 		serout 7,N2400_4,(254,128,b8,b9,b10,"             ")
 	bintoascii varA,b8,b9,b10
 		bintoascii varB,b11,b12,b13
 			serout 7,N2400_4,(254,192,b8,b9,b10,",",b11,b12,b13,"         ")
 		gosub prc_NUMBER2	'Do Procedure 
 loop8:
 		goto loop8
  &#12288;
 #no_data	'reduce download time
 
#7
You need to do what you would do if using a pen and paper.
That is, make decision based on what the character you are about to 'print' actually is.
So, if the first character is "0", then don't print it.

I'm sure someone will come along soon with the exact code that you need.
I don't like to spoon-feed, I prefer to encourage people to work it out themselves.
 

hippy

Technical Support
Staff member
#8
The LCD flowchart cell allows for some simple display and formatting of variable values. Where more complicated display formats are required it may be best to replace LCD cells with BASIC cells and craft SEROUT commands to achieve what is needed.

Having a flowchart which generates all the numbers you want to display, and having a single BASIC cell which puts those on the display may be the easiest way to do that.
 
#9
The LCD flowchart cell allows for some simple display and formatting of variable values. Where more complicated display formats are required it may be best to replace LCD cells with BASIC cells and craft SEROUT commands to achieve what is needed.

Having a flowchart which generates all the numbers you want to display, and having a single BASIC cell which puts those on the display may be the easiest way to do that.
This sounds like a really good option, Thanks.

However, I am not familiar with coding BASIC. Could someone possibly provide me with the BASIC code?
 
Top