Convert Ascii to Binary

jims

Senior Member
I know that I've seen this on the FORUM before. However, been searching the FORUM for the past 2-3 hours and can't find the code to convert an Ascii character to binary. For example I want to take the Ascii coded character "v" and break it out into 3 binary characters the way that #b1 does it when b1 contains an Ascii "v" ; (118). To convert the Ascii "v" to the 3 characters 1,1,8. I know that I can let PE6 do this by using the #b1 command. However I'm trying to better understand different coding techniques. I'm not proficient enough with math to work this out by my self. Will appreciate help to get me started. With enough "hints" from FORUM members, I'm sure that I can do it. Jims
 
Last edited:

AllyCat

Senior Member
Hi Jims,

Basically, to convert any byte (or word) value to a decimal result, you repeatedly divide by 10 and show the remainder values in reverse order. You obtain the remainder by using the // operator. Normally you would "re-use" variables to avoid running out, but I'll use different variables here to show what's happening:
Code:
   let b1 = "v"    ; Example ASCII value is 118 (decimal)
   b2 = b1 // 10      ; First remainder = 8
   b3 = b1 / 10        ; The integer result of the first divison = 11
   b4 = b3 // 10       ; Second remainder is = 1
   b5 = b3 / 10        ; Integer result of the second division = 1
   b6 = b5 // 10      ; Third remainder is = 1
   b7 = b5 / 10       ; Third result of divison is 0, so we've finished
   sertxd(#b6,#b4,#b2,cr,lf)  ;  Send the result to the terminal
You can try this in the simulator or on a "real" PICaxe.

Cheers, Alan.
 

BeanieBots

Moderator
As per my reply to your previous post on the subject, there is no difference between "v" and 118.
They are both the same value stored in the same way. It is only the way it is displayed that is different.
If you had a box with 118 bricks in it, you could say that the contents of the box 'represented' "v".

b0 = "v" is the same as b0 = 118
Do a google for "ASCII table". It will show you all the values for all the letters.

if you the '#' in a serout statement, it will send out the individual ASCII characters that make up the number.
b0=118
serout b0 will send "v" to the terminal
serout #b0 will send "1" then "1" and finally "8" to the terminal.

BINTOASCII will convert a number to it's individual ASCII components.
If you want to convert those into their actual decimal values then there is a simple trick.
Just subtract 48 from each digit.
In HEX, it is much easier to remember because 48 in HEX is 0x30 which is "0" in ASCII.
So "0" minus "0" = 0
"1" minus "0" = 1
"2" minus "0" = 2
and so on and so on.

I hope that helps rather than confuses even more.
Don't hesitate to ask if it's still unclear. I'm sure somebody can explain it better than I can but really is easy once you see what is going on.
 

hippy

Technical Support
Staff member
Equivalent code for SERTXD(#b1) is ...

Code:
BinToAscii b1, b11,b12,b13
If b11 <> "0" Then
  SerTxd(b11,b12,b13)
Else
  If b12 <> "0" Then
    SerTxd(b12,b13)
  Else
    SerTxd(b13)
  End If
End If
That "BinToAscii b1, b11,b12,b13" can instead be ...

Code:
b11 = b1 / 100       + "0"
b12 = b1 / 10  // 10 + "0"
b13 = b1       // 10 + "0
 

jims

Senior Member
Thanks to all of you for the good ideas. I've used your ideas and sample code to put together this routine. It lets me watch the progression through the conversion process as I try to understand what is happening. Jims
Code:
[color=Green]'*************************************************************
'* 20X2 Converts serial receive data to 1,2,or 3 characters.
'* Run single step or run PE6 simulation at slow speed and
'* watch progression in Code explorer; SerTxd; and the 
'* Digital Simulation Dislay.
'***************************************************************[/color]

[color=Navy]#picaxe [/color][color=Black]20x2[/color]

[color=Blue]symbol RCV [/color][color=DarkCyan]= [/color][color=Blue]C.4
symbol [/color][color=Purple]dig1 [/color][color=DarkCyan]= [/color][color=Purple]b11[/color]
[color=Blue]symbol [/color][color=Purple]dig2 [/color][color=DarkCyan]= [/color][color=Purple]b12[/color]
[color=Blue]symbol [/color][color=Purple]dig3 [/color][color=DarkCyan]= [/color][color=Purple]b13[/color]

[color=Black]init:
      
      [/color][color=Purple]b5[/color][color=DarkCyan]=[/color][color=Navy]128
      [/color][color=Purple]dirsB [/color][color=DarkCyan]= [/color][color=Navy]%11111111[/color][color=Black]:[/color][color=Blue]pause [/color][color=Navy]50
      [/color][color=Purple]pinsB [/color][color=DarkCyan]= [/color][color=Navy]%00000000[/color][color=Black]:[/color][color=Blue]pause [/color][color=Navy]50    [/color][color=Green]'Clear pinsB
      [/color]
[color=Black]main:
      [/color][color=Purple]pinsB [/color][color=DarkCyan]= [/color][color=Navy]%00000000[/color][color=Black]:[/color][color=Blue]pause [/color][color=Navy]50    [/color][color=Green]'Clear pinsB
      
      [/color][color=Blue]serin rcv[/color][color=Black],[/color][color=Blue]N2400[/color][color=Black],[/color][color=Purple]b1      [/color][color=Green]'Enter eceive data.
      '* Begin routine to convert receive data. 
      [/color][color=Blue]BinToAscii [/color][color=Purple]b1[/color][color=Black], [/color][color=Purple]b11[/color][color=Black],[/color][color=Purple]b12[/color][color=Black],[/color][color=Purple]b13
      [/color][color=Blue]If [/color][color=Purple]b11 [/color][color=DarkCyan]<> [/color][color=Red]"0" [/color][color=Blue]Then
            SerTxd([/color][color=Purple]b11[/color][color=Black],[/color][color=Purple]b12[/color][color=Black],[/color][color=Purple]b13[/color][color=Black],[/color][color=Blue]cr[/color][color=Black],[/color][color=Blue]lf)
            Else
      If [/color][color=Purple]b12 [/color][color=DarkCyan]<> [/color][color=Red]"0" [/color][color=Blue]Then
            SerTxd([/color][color=Purple]b12[/color][color=Black],[/color][color=Purple]b13[/color][color=Black],[/color][color=Blue]cr[/color][color=Black],[/color][color=Blue]lf)
            Else
            SerTxd([/color][color=Purple]b13[/color][color=Black],[/color][color=Blue]cr[/color][color=Black],[/color][color=Blue]lf)
      End If
      
      [/color][color=Purple]pinsB[/color][color=DarkCyan]=[/color][color=Purple]b1    [/color][color=Green]'Watch data on pinsB.
      [/color][color=Blue]pause [/color][color=Navy]1000
      [/color][color=Blue]End If
            
      goto [/color][color=Black]main[/color]
 

inglewoodpete

Senior Member
Jim, Due to time zone differences, I seem to be chipping in when you're in bed and there has already been a very good discussion about your question already. I'll chip in with my thoughts, anyway.

I can see that you are still having a struggle with binary and ASCII. Perhaps another way to look at the issue is as follows. I hope I'm not making it more confusing.:)

  • Data transmissions are usually just a series of bytes. Each 8-bit byte can have a binary value %00000000 to %11111111 (0 to 255 decimal).
  • ASCII is a protocol that is overlaid over the byte-by-byte data transmission.
What is a protocol? It is a sender (or transmitter) of data and a receiver of data that have both agreed to encode and decode information in that byte-by-byte transmission. An example: Your OLED screen (receiver) can only display ASCII characters. So, in order to work correctly, your PICAXE (transmitter) must 'agree' to this protocol and send only ASCII characters. When both ends agree on a protocol, the receiver will always understand and correctly interpret what the transmitter sends.
 

hippy

Technical Support
Staff member
Thanks to all of you for the good ideas. I've used your ideas and sample code to put together this routine. It lets me watch the progression through the conversion process as I try to understand what is happening.
It may be worth explaining what problem you are having is as all that conversion code does is no more than SERTXD(#b1,CR,LF) would give you.
 

jims

Senior Member
Hippy...Here's where I going, and I'm working on it in stages. I now have 2 Picaxes talking to each other & doing this. Not complete code...used to show the comcept.

Terminal "A" (20M2): reads an LDR and 3 DS18b20 temp sensors into b2,b3,b4,b5 every 10 seconds, and transmits the resulting data to Terminal "B".. The data in each of the "b" variables ranges from 1 to 3 digits.
eg: serout txdl, N4800,(b2,b3,b4,b5) 'Xmit to terminal "B".

Terminal "B" (20X2): bacground receives the data into scratchpad memory, analyzes b2 data to determine if lights are ON/OFF, and sends control & data info to an AXE133Y OLED display.
eg: serout oled,n2400,(254,128,"LT:ON") : pause 10
serout oled,n2400,(254,138,"T1:",#b3) : pause 10
serout oled,n2400,(254,192,"T2:",#b4) : pause 10
serout oled,n2400,(254,202,"T3:",#b5) : pause 10

Next stage is to make the 18M2 in the AXE133Y OLED act like Terminal "B" and receive data using "serin".

Then: since the existing AXE133Y converts serial data to parallel and sends it to the display module as control and data characters. I will need to somehow emulate this function and send parallel data to the display module. Jims

The smiley faces that show are actually a ":" followed by a "p". Jims
 
Last edited by a moderator:

jims

Senior Member
Thank you...Westaust55...The smiley faces showed-up on my iPad but not on the PC display. I'll try to remember this in the future. Jims
 

westaust55

Moderator
Next stage is to make the 18M2 in the AXE133Y OLED act like Terminal "B" and receive data using "serin".

Then: since the existing AXE133Y converts serial data to parallel and sends it to the display module as control and data characters. I will need to somehow emulate this function and send parallel data to the display module. Jims
You seem to be over complicating and getting hung up on conversions.

Is the final display device an AXE133y or are you trying to construct a display to emulate.
Either way, Rev Ed on their PICAXE website make the code used in the AXE133 based PICAXE available.
You can download thy code and read through or run in the PE simulator to see how it works.

In simple terms:
The serial side receives a byte containing a value (usually as ASCII code).
The PICAXE chip in effect breaks this down to two Nybbles as upper 4-bits and separately the lower 4-bits.
These 4-bit parts are sent one at a time each followed by a pulse to signal to the display that there is data to receive.


The PICAXE determines if the next byte is a command or data, sets the command/data line accordingly and sends that byte to the OLED as 8 bits of parallel information with each byte followed by a pulse to signal to the display that there is data to receive/act upon.


EDIT:
for the AXE133Y firmware installed in the PICAXE 18M2 chip, loop under the resources tab on this web page:
http://www.picaxe.com/Hardware/Add-on-Modules/Budget-Serial-OLED-Module/

Opposite AXE133Y Firmware File is the tab to download the BASIC program file that comes with the AXE133 kits.
 
Last edited:

jims

Senior Member
@westaust55..I am using the AXE133Y code. It receives serial data, converts it to parallel, then sends it to the OLED module. I'm trying to find a way to take the serial data that I receive from another terminal, combine it with my template shown below, and emulate this data.

eg: serout oled,n2400,(254,128,"LT:ON") : pause 10
serout oled,n2400,(254,138,"T1:",#b3) : pause 10
serout oled,n2400,(254,192,"T2:",#b4) : pause 10
serout oled,n2400,(254,202,"T3:",#b5) : pause 10

I don't think that I can have my terminal "B" receive 4 bytes of serial data from terminal "A" and have terminal "B" send the above as serial data to itself. I believe that I need to combine the 4 data bytes from terminal "A" with my template shown in the 4 lines of code above, and send the data and control characters to the OLED module. Jims
 

westaust55

Moderator
So, in summary, what I believe you will have as an overall project is:

1 x LDR + 3 x DS18B20 conencted into a 20M2

every 10 seconds send 4 bytes of data representing light level and temps via SEROUT command

18M2 on AXE133Y display module to receive the 4 bytes, decide if light is on or off then send formatted status/temps to the OLED display.

Recommendation: In the 20M2 you can just send the 4 bytes of data in a single SEROUT command and have the amended code in the 18M2 on the AXE133Y module do the rest.


In the AXE133Y code you need to insert some added code to accept the 4 bytes of data and then in effect pass all the status/values with formatting onto the OLED display.

Looking into the AXE133Y standard code (I do not use this display myself) in fact there is an 8-bit parallel interface between the 18M2 and the OLED so less code is involved.

In the program where the lines start:
Code:
; main program loop, runs at 16MHz

main:

	serin RX,baud,b1			; wait for the next byte
you need to insert your own code.
Since you will send 4 bytes of datas do this in one SEROUt form the 20M2)
The SERIN command can be
serin RX,baud,b1,b2,b3,b4[/indent.
Then with the 4 bytes received, since you have 10 seconds before the next set of data there is ample time and one option is to:
1. Determine if light is on or off


2. Put the desired text and values into RAM using the @bptrinc pointer
Use the BINtoASCII command to extract the digits from each temp value for pre-saving in RAM.

In reality the text and formatting are the same each pass so only need to change the RAM locations for light on/off and the 3 temp values will need to be updted therefore some of the RAM information can be a once off set up befoire the Main: label.


3. Retrieve the data from RAM one byte at a time and pass onto the standard 18M2 code.
So make the SERIN command and your new section of code to manipulate the received data part of a new loop and use GOSUB to pass the data one byte at a time via byte variable b1 onto a subroutine which contains the existing standard IF&#8230;THEN&#8230;ELSEIF&#8230;ELSEIF&#8230;.ENDIF structure
Add a label for the subroutine and and add a RETURN plus change the GOTO Main lines to RETURN.

Otherwise have a read of the entire AXE133Y program code (it is not that long) from the link I gave above in post 11 (after the EDIT: ) on the PICAXE website and strip out all the unnecessary code and write you own project specific OLED code.

As there are more way to skin the proverbial cat, I am sure others will given alternative and potentially better ways to do all this.
Sorry I don't have time to write the 18M2 code for you at the moment. . .​
 
Last edited:

jims

Senior Member
Thank you...westaust55...I want to continue plugging away on this. Would not expect you to do the coding. I have it working with terminal "B" (20x2) recieving background data from the 20m2 terminal "A"; and showing the data on a serial OLED. Hope to use the good FORUM info and eliminate the intermediate 20x2 and do the job by recoding the 20m2 that's in the OLED display. I wasn't aware that I can use the @bptrinc with RAM in the 20m2 (I'll give it a try). Jims
 

jims

Senior Member
My error..westaust55...I'm really working on code for the 18m2 in the AXE133Y OLED display. After looking at this note on page 153 of the Picaxe Manual 2, I didn't think that I could use @bptrinc on the M2 chip. jims

For M2 parts:
The function of the poke/peek commands is amended on M2 parts.
The M2 parts have up to 512 bytes of user RAM.
The peek and poke commands are used to read and write to all 256 bytes of the
user RAM. However the lower 28 bytes (addresses 0 to 27) also correspond to the
variables b0 to b27. Therefore these lower bytes can be accessed in two ways, via
the bxx variable name or via the peek/poke command. The higher variables can
only be accessed via the peek/poke commands.
 

hippy

Technical Support
Staff member
@bptr and related are available on the 18M2 but won't be needed for simply taking your bytes in and putting them to the display. A simple SERIN to however many variables will do the job.
 

jims

Senior Member
Thanks to all of you for the ideas and suggestions. Due to some higher priorities, I need to put this project on "hold" for now. Will get back to it sometime later. Here's the code as it exists now. It runs error free using PE6 simulation......Jims.....

Code:
[color=Green]'*******************************************************
'* 18M2 receives 4 bytes of serial data from terminal "A".
'* Converts Ascii data to decimal & writes to RAM.
'* Reads data from RAM then sequences thru data 
'* using variable b1.
'* NEED TO INTEGRATE WITH AXE133Y CODE SO CAN ELIMINATE
'* THE INTERMEDIATE TERMINAL "B". SEROUT TO THE OLED
'* ARE ONLY USED FOR TESTING CODE WITH PE6 SIMULATE.
'* WILL BE REMOVED IN FINAL CODE>
'*******************************************************[/color]

[color=Navy]#picaxe [/color][color=Black]18M2      [/color][color=Green]'In AXE133Y OLED display.[/color]

[color=Blue]symbol RCV [/color][color=DarkCyan]= [/color][color=Blue]C.5
symbol oled [/color][color=DarkCyan]= [/color][color=Blue]C.3
symbol RLED [/color][color=DarkCyan]= [/color][color=Blue]C.2
symbol [/color][color=Purple]RAM_addr [/color][color=DarkCyan]= [/color][color=Purple]b0[/color]
[color=Blue]symbol [/color][color=Purple]rcv1 [/color][color=DarkCyan]= [/color][color=Purple]b6[/color]
[color=Blue]symbol [/color][color=Purple]rcv2 [/color][color=DarkCyan]= [/color][color=Purple]b7[/color]
[color=Blue]symbol [/color][color=Purple]rcv3 [/color][color=DarkCyan]= [/color][color=Purple]b8[/color]
[color=Blue]symbol [/color][color=Purple]rcv4 [/color][color=DarkCyan]= [/color][color=Purple]b9[/color]
[color=Blue]symbol [/color][color=Purple]temp_dig[/color][color=DarkCyan]= [/color][color=Purple]b10[/color]
[color=Blue]symbol [/color][color=Purple]dig1 [/color][color=DarkCyan]= [/color][color=Purple]b16[/color]
[color=Blue]symbol [/color][color=Purple]dig2 [/color][color=DarkCyan]= [/color][color=Purple]b17[/color]
[color=Blue]symbol [/color][color=Purple]dig3 [/color][color=DarkCyan]= [/color][color=Purple]b18[/color]


[color=Green]' Typical lights ON message: 120,22,33,44 .     
' Typical lights OFF message. 56,22,33,44 .[/color]

[color=Purple]RAM_addr [/color][color=DarkCyan]= [/color][color=Navy]30     [/color][color=Green]'Starting address for RAM data.[/color]
[color=Black]init: [/color][color=Green]'Load Template for fixed OLED data into RAM.
      [/color][color=Blue]poke [/color][color=Navy]30[/color][color=Black],[/color][color=Navy]254[/color][color=Black],[/color][color=Navy]128[/color][color=Black],[/color][color=Navy]76[/color][color=Black],[/color][color=Navy]49[/color][color=Black],[/color][color=Navy]58  [/color][color=Green]'go to pos 128,L,I,:
      [/color][color=Blue]poke [/color][color=Navy]38[/color][color=Black],[/color][color=Navy]254[/color][color=Black],[/color][color=Navy]138[/color][color=Black],[/color][color=Navy]84[/color][color=Black],[/color][color=Navy]49[/color][color=Black],[/color][color=Navy]58  [/color][color=Green]'go to pos 138,T,1,:
      [/color][color=Blue]poke [/color][color=Navy]46[/color][color=Black],[/color][color=Navy]254[/color][color=Black],[/color][color=Navy]192[/color][color=Black],[/color][color=Navy]84[/color][color=Black],[/color][color=Navy]50[/color][color=Black],[/color][color=Navy]58  [/color][color=Green]'go to pos 192,T,2,:
      [/color][color=Blue]poke [/color][color=Navy]54[/color][color=Black],[/color][color=Navy]254[/color][color=Black],[/color][color=Navy]202[/color][color=Black],[/color][color=Navy]84[/color][color=Black],[/color][color=Navy]51[/color][color=Black],[/color][color=Navy]58  [/color][color=Green]'go to pos 202,T,3,:
      [/color]
[color=Black]Main:
      
rcv_data:   [/color][color=Green]'Receive serial data from terminal "A".
      
      [/color][color=Blue]serin rcv[/color][color=Black],[/color][color=Blue]n2400[/color][color=Black],[/color][color=Purple]rcv1[/color][color=Black],[/color][color=Purple]rcv2[/color][color=Black],[/color][color=Purple]rcv3[/color][color=Black],[/color][color=Purple]rcv4
      [/color][color=Blue]call [/color][color=Black]check_1st    [/color][color=Green]'Check if terminal "A" lights are ON/OFF.
'** Analyze receive data & convert binary to Ascii.         [/color]
[color=Black]convert:    
      [/color][color=Blue]call [/color][color=Black]check_1st
      [/color][color=Blue]poke [/color][color=Navy]35[/color][color=Black],[/color][color=Purple]dig1[/color][color=Black],[/color][color=Purple]dig2[/color][color=Black],[/color][color=Purple]dig3  [/color][color=Green]'Writes to RAM address 35,36,37.
      [/color][color=Blue]BinToAscii  [/color][color=Purple]rcv2[/color][color=Black],[/color][color=Purple]dig1[/color][color=Black],[/color][color=Purple]dig2[/color][color=Black],[/color][color=Purple]dig3
      [/color][color=Blue]call [/color][color=Black]check
      [/color][color=Blue]poke [/color][color=Navy]43[/color][color=Black],[/color][color=Purple]dig1[/color][color=Black],[/color][color=Purple]dig2[/color][color=Black],[/color][color=Purple]dig3  [/color][color=Green]'Writes to RAM address 43,44,45.
      [/color][color=Blue]BinToAscii  [/color][color=Purple]rcv3[/color][color=Black],[/color][color=Purple]dig1[/color][color=Black],[/color][color=Purple]dig2[/color][color=Black],[/color][color=Purple]dig3
      [/color][color=Blue]call [/color][color=Black]check
      [/color][color=Blue]poke [/color][color=Navy]51[/color][color=Black],[/color][color=Purple]dig1[/color][color=Black],[/color][color=Purple]dig2[/color][color=Black],[/color][color=Purple]dig3  [/color][color=Green]'Writes to RAM address 51,52,53.
      [/color][color=Blue]BinToAscii  [/color][color=Purple]rcv4[/color][color=Black],[/color][color=Purple]dig1[/color][color=Black],[/color][color=Purple]dig2[/color][color=Black],[/color][color=Purple]dig3
      [/color][color=Blue]call [/color][color=Black]check
      [/color][color=Blue]poke [/color][color=Navy]59[/color][color=Black],[/color][color=Purple]dig1[/color][color=Black],[/color][color=Purple]dig2[/color][color=Black],[/color][color=Purple]dig3  [/color][color=Green]'Writes to RAM address 59,60,61
      [/color][color=Blue]call [/color][color=Black]see_data
      [/color][color=Blue]high RLED[/color][color=Black]:[/color][color=Blue]pause [/color][color=Navy]500[/color][color=Black]:[/color][color=Blue]low RLED  [/color][color=Green]'Terminal "heartbeat".
      [/color][color=Blue]goto [/color][color=Black]main[/color]
[color=Green]'** Analyze 1st character received to see
'** if  terminal "A" ilghts are ON/OFF.   [/color]
[color=Black]check_1st:  
      [/color][color=Blue]if [/color][color=Purple]rcv1 [/color][color=DarkCyan]=>[/color][color=Navy]100 [/color][color=Blue]then let [/color][color=Purple]dig1[/color][color=DarkCyan]=[/color][color=Navy]32[/color][color=Black]:[/color][color=Purple]dig2[/color][color=DarkCyan]=[/color][color=Navy]79[/color][color=Black]:[/color][color=Purple]dig3[/color][color=DarkCyan]=[/color][color=Navy]78  [/color][color=Green]'space, O,N.[/color]
[color=Blue]else  let [/color][color=Purple]dig1[/color][color=DarkCyan]=[/color][color=Navy]79[/color][color=Black]:[/color][color=Purple]dig2[/color][color=DarkCyan]=[/color][color=Black]70dig3[/color][color=DarkCyan]=[/color][color=Navy]70[/color][color=Black]:[/color][color=Blue]endif          [/color][color=Green]'O,F,F.
      [/color][color=Blue]return[/color]
[color=Green]'** Analyze 2nd,3rd,4th received characters.
'** Replace leading zero's with spaces.[/color]
[color=Black]check:
      [/color][color=Blue]if [/color][color=Purple]dig1 [/color][color=DarkCyan]=[/color][color=Navy]48 [/color][color=DarkCyan]and [/color][color=Purple]dig2 [/color][color=DarkCyan]=[/color][color=Navy]48 [/color][color=Blue]then  [/color][color=Black]char_1
      [/color][color=Blue]if [/color][color=Purple]dig1[/color][color=DarkCyan]=[/color][color=Navy]48 [/color][color=Blue]then  [/color][color=Black]char_2
      [/color][color=Blue]goto [/color][color=Black]char_3
char_1:
      [/color][color=Purple]dig1 [/color][color=DarkCyan]= [/color][color=Navy]32[/color][color=Black]:[/color][color=Purple]dig2 [/color][color=DarkCyan]= [/color][color=Navy]32 [/color][color=Black]:[/color][color=Blue]pause [/color][color=Navy]10
      [/color][color=Purple]pinsB[/color][color=DarkCyan]=[/color][color=Purple]b1    [/color][color=Green]'Watch data on pinsB.
      [/color][color=Blue]return
      goto [/color][color=Black]main
char_2: 
      [/color][color=Purple]dig1 [/color][color=DarkCyan]= [/color][color=Navy]32[/color][color=Black]:[/color][color=Blue]pause [/color][color=Navy]10
      [/color][color=Purple]pinsB[/color][color=DarkCyan]=[/color][color=Purple]b1    [/color][color=Green]'Watch data on pinsB.
      [/color][color=Blue]return
      goto [/color][color=Black]main
char_3:
      [/color][color=Purple]pinsB[/color][color=DarkCyan]=[/color][color=Purple]b1    [/color][color=Green]'Watch data on pinsB.
      [/color][color=Blue]return
      [/color]
[color=Black]see_data:
      [/color][color=Blue]serout oled[/color][color=Black],[/color][color=Blue]n2400[/color][color=Black],[/color][color=Blue]([/color][color=Navy]254[/color][color=Black],[/color][color=Navy]1[/color][color=Blue])
      [/color][color=Purple]b0[/color][color=DarkCyan]=[/color][color=Navy]30
      [/color][color=Blue]for [/color][color=Purple]b21[/color][color=DarkCyan]=[/color][color=Navy]1 [/color][color=Blue]to [/color][color=Navy]32
      [/color][color=Blue]peek [/color][color=Purple]b0[/color][color=Black],[/color][color=Purple]b19[/color][color=Green]',254,128,76,49,58 
      [/color][color=Blue]serout oled[/color][color=Black],[/color][color=Blue]n2400[/color][color=Black],[/color][color=Blue]([/color][color=Purple]b19[/color][color=Blue])
      inc [/color][color=Purple]b0
      [/color][color=Blue]next [/color][color=Purple]b21
      [/color][color=Blue]return
      [/color]
 

westaust55

Moderator
My understanding was/is that jims was/is trying to move the code from the 20X2 (the current "Terminal" B chip) into the AXE133Y micro-controller (18M2).
This included tests to determine if the lights are on or off and extra formating and test that the current "Terminal" B chip passes to the AXE133Y display.

If these tests were moved to the "Terminal A" chip (20M2) then there is no need for any changes to the AXE133Y firmware as hippy indicates.
.
But if jims desires not to change Terminal A" (the sending program) then the program for the 18M2 in on-board the AXE133Y needs to be changed to accept the base 4 bytes of data and perform the BINTOASCII for the temp values, and then pass all the resulting data to the OLED display.
Hence my idea of storing a series of bytes with the desired test, values and formatting in RAM with the @bptrinc command which subsequently can be the passed to the OLED display by resetting the @ptr pointer and then retrieving one byte at a time with @bptrinc.

As indicated at post 13 there are many ways to achieve the same end result.
 
Top