Hi,
This project is primarily a Hardware design to offer most of the features of the AXE033 Serial (RS232) LCD Display Driver and the more recent AXE131 to 134 OLED variants. However, I have used the 033 as a "Headline" because it includes an I2C bus and an optional Real-Time Clock. The design contains so many "options" that I don't expect to ever offer a "definitive" implementation program, but nearly all the features have been separately documented on this forum, sometimes in the Code Snippets section (often in considerable detail), so I will include Hot-Links where appropriate.
The I2C bus is the heart of the concept, with its on-chip "silicon hardware" virtually essential to achieve an acceptable display (update) speed. Also, many sensors are available with an I2C interface, (for example Temperature, Humidity, Barometric Pressure, Light level, LIDAR, ADC, DAC, etc.), usually mounted on breakout boards, so the project has also a Data Logging capability. The (RAM/EPROM) memory inside the 08M2 is quite limited, but an optional element of the design is a 24{L}Cxx I2C EEPROM, offering up to 128 MBytes. The circuit design and components have been selected such that the entire functionality can be achieved on a circuit board the size and profile (almost) of a single AA battery, using only through-hole techniques. Thus it can employ a switched and/or lidded AA battery box as an "Enclosure", but the physical construction will not be discussed in this first post of the thread.
The Display
The design is particularly intended to drive a low cost 0.91 inch (diagonal) 32 x 128 pixels OLED Graphics display (with a SSD13xx driver), but other sizes are available up to 2+ inches. The 1.3 inch (64 x 128 pixels) and 1.5 inch (128 x 128 pixels) versions might be also of interest because they often employ the SH11xx driver which offers a benefit of the graphics RAM being READable via the I2C bus (the SSD13xx chips are Write Only), more details HERE. A full 96 characters ASCII font set can be stored in about half of the Program Memory of the 08M2 as described HERE with relatively simple subroutines to convert to "Double-Height", "Double-Width" and "Quadruple-Height" characters.
The 32 x 128 pixels display format is particularly flexible because it can be configured as 4 rows of 20 characters (5 x 7 font in a 6 x 8 pixels cell), or two rows of 20 or 16 (more widely spaced) Double Height characters, or a single row of Quadruple Height characters, optionally using a "Character Rounding" (Diagonal Interpolation) algorithm, to give higher quality characters. This could give up to 10 characters across the width, which may be sufficient particularly for numerical presentations. Or post #6 in the previous link includes an average 3-pixels wide (6 pixels Rounded) "Proportional" ASCII font (varying in width from 1 to 5 core pixels), particularly appropriate for "soft" (individual pixels) side-scrolling.
Of course the 08M2 does not have sufficient pins to drive the normal "Parallel" LCD or OLED Character displays (like the 1602 or 2004), but these are often supplied with an "I2C Bus Expander" Backpack, or they can be obtained separately at modest cost. A further advantage of the backpacks is that they generally include the necessary "Contrast" Potentiometer, and control of the Backlight LED (including the possibility of backlight PWM dimming), for LCD modules.
Schematic Diagram

Above is a Schematic Circuit Diagram of the project (click to view). It might look rather complicated, particularly all the "Switches", but these are intended only to indicate some of the available "Options", in practice they might be 0.1 inch "pin headers" with bridging links as appropriate, but in most cases they will be embedded within the basic "PCB" layout. Similarly, a few connections are labelled as "Flyleads", a single flexible wire, with a Solder Tag that can be sandwiched between a spring and the body of one of the batteries in an AA battery holder, or perhaps terminated elsewhere on the PCB (e.g. for a LED).
Most of the PICaxe's pin functions are "fixed" by the application, i.e. Programming I/O (C.5 and C.0) and I2C hardware SCL and SDA (C.1 and C.2) leaving only C.3 ("Input Only") and C.4, but these definitions can be misleading, particularly with the 08M2. Pin C.3 (and even C.5) can be used for low power Output control via their internal "Weak Pullup" resistors (available on all 08M2 signal pins). Also, the "Output Only" Programming pin C.0 has a secondary function as a "DAC output", which has such a high source impedance (up to 160k) that it can be used as an Analogue (ADC) input via the READDAC{10} instruction.
RS232 Serial Input
Perhaps the greatest feature of the design is that ALL of PICaxe's "RS232" serial protocols are supported. Contrary to some "generic" descriptions, both SERTXD and SEROUT can be used on pin C.0, and also the HSEROUT hardware is allocated to that pin on the 08M2. Similarly, SERRXD and SERIN can be input on pin C.5, but the default HSERIN connection is pin C.1, already reserved for the I2C SCL signal. However, the base PIC (08)M2 chip has an "Alternative Pin Function" SFR which allows HSERIN to be swapped to pin C.5. This allows the Programming connector (3.5 mm coaxial or the "Legacy" 0.1 inch pin-header) to become a "Universal" serial interface port. There are a few issues, because the base M2 chips' hardware does not support the Idle Low ("RS232") signal polarity, only the Idle-High "TTL" or "True" format. Thus the design includes an optional inverter (Q1), which is activated by the Weak Pullup resistor on pin C.3. My original investigation was discussed HERE but the switching/interrupt arrangement has been improved for this thread.
The normal (Idle Low) Programming is coupled via R3, to be decoded by the internal firmware (pin C.3 is Tri-stated, so Q1 is off), but C.5 can be released (from the programming task) by a DISCONNECT instruction at the start of the User Program. The HSERIN module is then connected by a POKESFR to APFCON, after the external inverter has been activated by the pullups on C.3 (base bias) and C.5 (Collector/Drain load). PICaxe Basic does not permit directly enabling the Pullup on C.5, but this can be overcome by a direct POKESFR command, or by using a variable in the PULLUP instruction (having set the variable to %101000). Alternatively, (with R3 disconnected) D1 blocks any positive input voltage attempting to Program the chip, but allows a High to {H}SERIN after the Input Pullup has been activated.
Interrupts
The M2 family supports interrupts only on specific pins (of a single internal port), so the 08M2 actually has more interrupt-capable pins than the 14M2. However, unfortunately C.5 is not one of those pins, so another must be found (generally C.3) for the "RS232" to activate an interrupt. That is the reason for the resistor (R1) between pin C.3 and the base of the inverter transistor (Q1). The base of a bipolar transistor is effectively a forward diode to its emitter (ground) so clamps at about 0.6 volt; R1 allows the voltage on C.3 to rise high enough to generate an Interrupt. If the transistor is replaced by a MOSFET (e.g. 2N7000) then the pullup resistor can be omitted (zero ohms link). If neither an Interrupt nor signal inversion is required, then Q1 (bipolar or FET) can be used as a (Pull-down) External Power controller.
Another "Interrupt" possibility can use the base PIC's "Interrupt on Change" FLAGS, available on ALL of the 08M2's signal pins, including C.5. This cannot achieve a "genuine" interrupt (i.e. be transparent to the main program), but for a 2400 baud serial input stream with the PE Terminal Emulator's "5ms inter-character gap" (Serial Terminal > Settings) there is a period of more than 20ms between the start pulse of a first character and the completion of a third character (when the Internal Hardware Buffer would overflow). Thus a 20ms Polling Loop could be sufficient to catch any serial input, and to PWM-dim a LED, such as a LCD backlight.
Port.pin C.4
No specific function is required of pin C.4, so it is generally free for the User to employ as required. On the schematic diagram it is connected to a 4-pin header footprint, together with Supply, Ground and the Programming Input. Applications could be to drive a Model-making Servo, or to connect to a DS18B20 Temperature sensor (which requires a pin with combined Input and Output capability). The Programming Interface alone cannot directly accommodate a DS18B20, but Earth is available and C.0 can be set High to emulate a Power Supply rail. Then C.4 can be bridged to the Programming Input to allow a wired external sensor to be linked via the Programming Socket. Like for the I2C, the Weak Pullup resistors (on C.4 and C.5) may be sufficient for the DS18B20, but it's probably necessary to increase the pulldown resistance R4 (which allows the PICaxe to bootup without a Programming Cable) and/or to make use of the "Normally Closed" switches (when no plug is inserted) on the 3.5 mm socket.
Well, the forum's 10,000 characters-per-post limit is here again. Not yet discussed is the LED array at the top of the diagram, which represents only 4 "holes" at the corners of a 0.1 inch square on the PCB (for a vertical resistor and possibly a bi-colour LED). Also, the current-sensing capability of the resistor (R5) between the separated "Earth" rails, which can be read by a READDAC{10} instruction (on pin C.0).
Cheers, Alan.
This project is primarily a Hardware design to offer most of the features of the AXE033 Serial (RS232) LCD Display Driver and the more recent AXE131 to 134 OLED variants. However, I have used the 033 as a "Headline" because it includes an I2C bus and an optional Real-Time Clock. The design contains so many "options" that I don't expect to ever offer a "definitive" implementation program, but nearly all the features have been separately documented on this forum, sometimes in the Code Snippets section (often in considerable detail), so I will include Hot-Links where appropriate.
The I2C bus is the heart of the concept, with its on-chip "silicon hardware" virtually essential to achieve an acceptable display (update) speed. Also, many sensors are available with an I2C interface, (for example Temperature, Humidity, Barometric Pressure, Light level, LIDAR, ADC, DAC, etc.), usually mounted on breakout boards, so the project has also a Data Logging capability. The (RAM/EPROM) memory inside the 08M2 is quite limited, but an optional element of the design is a 24{L}Cxx I2C EEPROM, offering up to 128 MBytes. The circuit design and components have been selected such that the entire functionality can be achieved on a circuit board the size and profile (almost) of a single AA battery, using only through-hole techniques. Thus it can employ a switched and/or lidded AA battery box as an "Enclosure", but the physical construction will not be discussed in this first post of the thread.
The Display
The design is particularly intended to drive a low cost 0.91 inch (diagonal) 32 x 128 pixels OLED Graphics display (with a SSD13xx driver), but other sizes are available up to 2+ inches. The 1.3 inch (64 x 128 pixels) and 1.5 inch (128 x 128 pixels) versions might be also of interest because they often employ the SH11xx driver which offers a benefit of the graphics RAM being READable via the I2C bus (the SSD13xx chips are Write Only), more details HERE. A full 96 characters ASCII font set can be stored in about half of the Program Memory of the 08M2 as described HERE with relatively simple subroutines to convert to "Double-Height", "Double-Width" and "Quadruple-Height" characters.
The 32 x 128 pixels display format is particularly flexible because it can be configured as 4 rows of 20 characters (5 x 7 font in a 6 x 8 pixels cell), or two rows of 20 or 16 (more widely spaced) Double Height characters, or a single row of Quadruple Height characters, optionally using a "Character Rounding" (Diagonal Interpolation) algorithm, to give higher quality characters. This could give up to 10 characters across the width, which may be sufficient particularly for numerical presentations. Or post #6 in the previous link includes an average 3-pixels wide (6 pixels Rounded) "Proportional" ASCII font (varying in width from 1 to 5 core pixels), particularly appropriate for "soft" (individual pixels) side-scrolling.
Of course the 08M2 does not have sufficient pins to drive the normal "Parallel" LCD or OLED Character displays (like the 1602 or 2004), but these are often supplied with an "I2C Bus Expander" Backpack, or they can be obtained separately at modest cost. A further advantage of the backpacks is that they generally include the necessary "Contrast" Potentiometer, and control of the Backlight LED (including the possibility of backlight PWM dimming), for LCD modules.
Schematic Diagram

Above is a Schematic Circuit Diagram of the project (click to view). It might look rather complicated, particularly all the "Switches", but these are intended only to indicate some of the available "Options", in practice they might be 0.1 inch "pin headers" with bridging links as appropriate, but in most cases they will be embedded within the basic "PCB" layout. Similarly, a few connections are labelled as "Flyleads", a single flexible wire, with a Solder Tag that can be sandwiched between a spring and the body of one of the batteries in an AA battery holder, or perhaps terminated elsewhere on the PCB (e.g. for a LED).
Most of the PICaxe's pin functions are "fixed" by the application, i.e. Programming I/O (C.5 and C.0) and I2C hardware SCL and SDA (C.1 and C.2) leaving only C.3 ("Input Only") and C.4, but these definitions can be misleading, particularly with the 08M2. Pin C.3 (and even C.5) can be used for low power Output control via their internal "Weak Pullup" resistors (available on all 08M2 signal pins). Also, the "Output Only" Programming pin C.0 has a secondary function as a "DAC output", which has such a high source impedance (up to 160k) that it can be used as an Analogue (ADC) input via the READDAC{10} instruction.
RS232 Serial Input
Perhaps the greatest feature of the design is that ALL of PICaxe's "RS232" serial protocols are supported. Contrary to some "generic" descriptions, both SERTXD and SEROUT can be used on pin C.0, and also the HSEROUT hardware is allocated to that pin on the 08M2. Similarly, SERRXD and SERIN can be input on pin C.5, but the default HSERIN connection is pin C.1, already reserved for the I2C SCL signal. However, the base PIC (08)M2 chip has an "Alternative Pin Function" SFR which allows HSERIN to be swapped to pin C.5. This allows the Programming connector (3.5 mm coaxial or the "Legacy" 0.1 inch pin-header) to become a "Universal" serial interface port. There are a few issues, because the base M2 chips' hardware does not support the Idle Low ("RS232") signal polarity, only the Idle-High "TTL" or "True" format. Thus the design includes an optional inverter (Q1), which is activated by the Weak Pullup resistor on pin C.3. My original investigation was discussed HERE but the switching/interrupt arrangement has been improved for this thread.
The normal (Idle Low) Programming is coupled via R3, to be decoded by the internal firmware (pin C.3 is Tri-stated, so Q1 is off), but C.5 can be released (from the programming task) by a DISCONNECT instruction at the start of the User Program. The HSERIN module is then connected by a POKESFR to APFCON, after the external inverter has been activated by the pullups on C.3 (base bias) and C.5 (Collector/Drain load). PICaxe Basic does not permit directly enabling the Pullup on C.5, but this can be overcome by a direct POKESFR command, or by using a variable in the PULLUP instruction (having set the variable to %101000). Alternatively, (with R3 disconnected) D1 blocks any positive input voltage attempting to Program the chip, but allows a High to {H}SERIN after the Input Pullup has been activated.
Interrupts
The M2 family supports interrupts only on specific pins (of a single internal port), so the 08M2 actually has more interrupt-capable pins than the 14M2. However, unfortunately C.5 is not one of those pins, so another must be found (generally C.3) for the "RS232" to activate an interrupt. That is the reason for the resistor (R1) between pin C.3 and the base of the inverter transistor (Q1). The base of a bipolar transistor is effectively a forward diode to its emitter (ground) so clamps at about 0.6 volt; R1 allows the voltage on C.3 to rise high enough to generate an Interrupt. If the transistor is replaced by a MOSFET (e.g. 2N7000) then the pullup resistor can be omitted (zero ohms link). If neither an Interrupt nor signal inversion is required, then Q1 (bipolar or FET) can be used as a (Pull-down) External Power controller.
Another "Interrupt" possibility can use the base PIC's "Interrupt on Change" FLAGS, available on ALL of the 08M2's signal pins, including C.5. This cannot achieve a "genuine" interrupt (i.e. be transparent to the main program), but for a 2400 baud serial input stream with the PE Terminal Emulator's "5ms inter-character gap" (Serial Terminal > Settings) there is a period of more than 20ms between the start pulse of a first character and the completion of a third character (when the Internal Hardware Buffer would overflow). Thus a 20ms Polling Loop could be sufficient to catch any serial input, and to PWM-dim a LED, such as a LCD backlight.
Port.pin C.4
No specific function is required of pin C.4, so it is generally free for the User to employ as required. On the schematic diagram it is connected to a 4-pin header footprint, together with Supply, Ground and the Programming Input. Applications could be to drive a Model-making Servo, or to connect to a DS18B20 Temperature sensor (which requires a pin with combined Input and Output capability). The Programming Interface alone cannot directly accommodate a DS18B20, but Earth is available and C.0 can be set High to emulate a Power Supply rail. Then C.4 can be bridged to the Programming Input to allow a wired external sensor to be linked via the Programming Socket. Like for the I2C, the Weak Pullup resistors (on C.4 and C.5) may be sufficient for the DS18B20, but it's probably necessary to increase the pulldown resistance R4 (which allows the PICaxe to bootup without a Programming Cable) and/or to make use of the "Normally Closed" switches (when no plug is inserted) on the 3.5 mm socket.
Well, the forum's 10,000 characters-per-post limit is here again. Not yet discussed is the LED array at the top of the diagram, which represents only 4 "holes" at the corners of a 0.1 inch square on the PCB (for a vertical resistor and possibly a bi-colour LED). Also, the current-sensing capability of the resistor (R5) between the separated "Earth" rails, which can be read by a READDAC{10} instruction (on pin C.0).
Cheers, Alan.