how to count and display above 255 help needed

driedeker

New Member
I am trying to count above 255 and send to a serial display,
Can anyone help with this, or is it not possible with a 28x2.
Thanks
 

techElder

Well-known member
The solution may be as simple as using "word" variables (W0, W1, etc.) instead of "byte" variables (B0, B1, etc.)

It would be nice to see your program lines.
 

nick12ab

Senior Member
Yes it is possible. PICAXE supports 16-bit variables (which go up to 65535 and are called word variables) but they are not implemented in Logicator. There are many ways of working around this.

A word variable is made up of two byte variables. Logicator will only let you manipulate byte variables without using a BASIC cell but there is a word variable (wx) for every two consecutive byte variables (bx) so you can manipulate the byte variables instead. Examples:
w0 = b1 : b0 (varB : varA)
w1 = b3 : b2 (varD : varC)
w2 = b5 : b4 (varF : varE)
...and so on...
The byte variable on the left is the most significant byte and the byte variable on the right is the least significant byte. The variable names in brackets correspond to the Logicator variables. Therefore if you use an inc command on variable A, the word variable will increase by 1 but if you use an inc command on variable B, the word variable will increase by 256.

You can then display this variable by entering the following code into a BASIC cell:
Code:
bintoascii w0,b8,b9,b10,b11,b12
serout [I]pin[/I],N2400,(254,[I]n[/I],b8,b9,b10,b11,b12)
pin is the pin the serial LCD is connected to.
n is the location on the display where the leftmost digit of the number will be displayed. The first square on the top row is 128 and the first square on the bottom row is 192.
 

Technoman

Senior Member
Hi

I was wondering for some time how to get a 16 bit counter the elegant way. Inspired by the recent nick12ab's post, I tried different solutions but with no success.
I was not able either to drive the LCD with the code inserted in a Basic cell. I must do something wrong (variable name, ...)? It is working fine (8 bits) with the Logicator blocks.

View attachment test inc word.plf
 

nick12ab

Senior Member
I was wondering for some time how to get a 16 bit counter the elegant way. Inspired by the recent nick12ab's post, I tried different solutions but with no success.
I was not able either to drive the LCD with the code inserted in a Basic cell. I must do something wrong (variable name, ...)? It is working fine (8 bits) with the Logicator blocks.
Did you try the code on a real PICAXE? BASIC cells are not simulated in Logicator.
 

Technoman

Senior Member
Thank you, it is working fine in the real world.

We do like having the students to go through the simulation before downloading. Still, a subroutine will be necessary.
May be, one day, the 16-bit variables will be implemented in Logicator...
 
Top