b0,b1,b2,b3 to word bit?

orjanjan

New Member
Hi

I have a pressure sensor where after calculations of sensordata i get out one digit at a time. To write this to a LCD is wery easy, but i want to save the value with the put command.
the typical value is 1024mbar.

from program:
RMSW = RMSW //10000 : B0= RMSW / 1000 +48 : SerOut SerLCD, baud, (B0); output Thousands value
RMSW = RMSW //1000 : B0= RMSW / 100 +48 : SerOut SerLCD, baud, (B0); output Hundreds value
RMSW = RMSW //100 : B0= RMSW / 10 +48 : SerOut SerLCD, baud, (B0); output Tens value
RMSW = RMSW //10 : B0= RMSW + 48 : SerOut SerLCD, baud, (B0); output Units value

How can I do this? is it possible to convert this to a word bit?
I want to save 24 values. One for eath hour.


thanks for all help

Jansen
 

eclectic

Moderator
Do you mean something like this?

Code:
b0 = 1
b1 = 0
b2 = 2
b3 = 4

w5 = b0 * 1000

w5 = b1 * 100 + W5

W5 = b2 * 10  + W5

W5 = b3       + W5

sertxd (#w5)
e
 

Goeytex

Senior Member
Consider the following example

Code:
#picaxe 20X2

Symbol RMSW = W2
Symbol location = b22
 
Do
     for loc[COLOR="#FF0000"]ation[/COLOR] = 0 to 46 step 2
          'read sensor
          put location,word RMSW 
         'pause 1 hour 
     next
Loop
 
Last edited by a moderator:

inglewoodpete

Senior Member
Hi

I have a pressure sensor where after calculations of sensordata i get out one digit at a time. To write this to a LCD is wery easy, but i want to save the value with the put command.
the typical value is 1024mbar.
<code example>
How can I do this? is it possible to convert this to a word bit?
I want to save 24 values. One for eath hour.


thanks for all help

Jansen
Hi Jansen, the following routine does both: puts the number in the scratchpad as ascii characters and then sends it to the LCD. The code assumes that the word value is in w10.

Code:
   bPtr = 0                  'Point to start of scratchpad buffer
   BinToASCII w10, @PtrInc, @PtrInc, @PtrInc, @PtrInc, @PtrInc
   @Ptr = 0                  'Terminator byte = 0
   Ptr = 0                   'Point to start of scratchpad buffer
   b7 = @bPtrInc             'Get first character
   Do
      SerOut SerLCD, baud, (b7);  'Send to LCD
      bLCDChar = @b7
   Loop Until b7 < 32        'Stop on non-printing value
 
Top