Problem using AXE133 spare outputs

I'm playing with a little project to open a door under manual or timed control using an 08M2 for the main control and an AXE133 board with a simple 2 x 16 LCD to show what's happening. The 08M2 doesn't have quite enough I/Os by the time I've used two (SCL & SDA) for the RTC, one for the serial out to the display, another for the servo and two for push buttons.

This is because I want to use a USB Power Bank as the PSU. These things come in a variety of capacities and at supermarket prices are a very cheap way of getting a high capacity 5V power source. They have one disadvantage though, if supplying only a few mA they switch off after about 30 seconds.

To get around this while still using as little average current as possible I've found that if I pulse about 500mA for a few tens of milliseconds every 20 seconds, it keeps the Power Bank turned on.

Unfortunately I've used all the I/Os on the 08M2 but, there are three unused outputs on the nicely designed AXE133 board (see pic) and the standard REV ED software conveniently shows how to use them:
Code:
; 255, X    control outputs C.2, C.1, C.0 (via lower 3 bits of X)
;        So, if using a backlit LCD with the active low transistor driver
;        on output C.2, then 255,%000 switches backlight on and 255,%100 switches off
So I thought it wouldn't be too difficult to use one of these outputs to pulse the current as required, but it doesn't seem to work as I'd expect. After various experiments I got rid of all my other code and just tried to switch the relevant output on and off with an LED to show what's happening (see circuit diagram).
Code:
; Display tester.
#picaxe 08M2
; 82/2048 bytes
#NO_DATA
;
; Outputs
; C.4 - serial line to LCD (AXE133 board with 18M2 & 16 chr x 2-line display).
;
; Three outputs also available on the 18M2+ (LCD board):
; 255, X    control outputs C.2, C.1, C.0 (via lower 3 bits of X)
; So, if using a backlit LCD with the active low transistor driver
; on output C.2, then 255,%000 switches backlight on and 255,%100 switches off
; C.2 has an 11.5 R load to be pulsed on briefly to keep the 5V USB Power Bank
; alive, otherwise it turns off because the circuit uses too little current.
;
init:
;
PAUSE 2000
SEROUT c.4,N2400,(254,1)      ; Clear display
PAUSE 100
main:
    SEROUT c.4,N2400,(255,%010)             ; Turn on LED
    PAUSE 100
    SEROUT c.4,N2400,(254,128)   
    ; Move to start of first line.
    SEROUT c.4,N2400,("LED on")   
    PAUSE 5000
    SEROUT c.4,N2400,(255,%000)           ; Turn off LED
    PAUSE 100
    SEROUT c.4,N2400,(254,128)   
    ; Move to start of first line.
    SEROUT c.4,N2400,("LED off")   
    PAUSE 5000
    SEROUT c.4,N2400,(254,1)      ; Clear display
    PAUSE 1000
;
GOTO main
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Note: the code is using C.1 as is the actual circuit where the schematic shows C.2. I've tried both with the same results.

What actually happens after power up is:
  1. Welcome display shows
  2. Screen clears
  3. "LED on" message appears, LED stays off.
  4. "LED off" message appended to the "LED on" on the top line (i.e. the SEROUT c.4,N2400,(254,128) is ignored, and the LED turns on.
  5. The screen clears again and the LED turns off with the "LED on" message appearing again.
So there are two issues here, the polarity of the output is the opposite of what I'd expect from the code, and the second command to move the insertion point to the start of the line is ignored.

Note that although writing "010" nominally to the C.2, C.1 & C.0 pins, the C.2 & C.0 pins never go high, so it's not as simple as the inverse of what's been written to that port.

Can anyone help please?

Door opener.PNGAXE133stacked_s.JPG
 

neiltechspec

Senior Member
You need %100 for C.2, not %010 which is C.1

You can also do, for example

Code:
main:
    do
    serout c.4,N2400,(255,%100) ;Turn on LED
    pause 100
    serout c.4,N2400,(254,128,"LED on")   
    pause 5000
    serout c.4,N2400,(255,%000) ;Turn off LED
    pause 100
    serout c.4,N2400,(254,128,"LED off")   
    pause 5000
    serout c.4,N2400,(254,1) ;Clear display
    pause 1000
    loop
Neil.
 
Last edited:
You need %100 for C.2, not %010 which is C.1
Thanks for the quick reply Neil. Yes, I did add the note in red that contrary to the schematic, I do have the LED on C.1 with the "SEROUT c.4,N2400,(255,%010)", but whichever output I use, I get the same problem.

Thanks for the second note - usefully concise.
 

neiltechspec

Senior Member
Would seem to suggest a wiring problem then.

I also use those pins for all sorts of things, never had any issues.
All my OLED displays have the contrast pin connected to C.2
(with jumper JV moved to JV0 on the OLED PCB) for dimming & low power consumption.

Neil.
 

AllyCat

Senior Member
Hi,

Normally one would put a SERTXD("Booting",cr,lf) at the top of the program to check for an "unexpected" Hardware Reset, but it's probably not going to work with that architecture. I think I would have connected the AXE133 to the SerOut pin (C.0) and the Servo on C.4. However, a spurious Reset is unlikely to occur when just lighting a LED, .... but it might when you start pulsing 0.5 amp or driving the Servo.

Also, there might be a few "tricks" to drive the FET directly from the 08M2, perhaps moving the "Close" button to "another pin" and using C.3 (and C.5, or another) as "output(s)", by activating the internal "Weak Pullup" resistors.

But to solve your present problem, I would first split the SEROUT control commands into individual bytes (i.e. two SEROUTs) in case the AXE133 is not responding fast enough. And are you sure you have the correct/unmodified version of the firmware in the AXE133 chip?

Cheers, Alan.
 

neiltechspec

Senior Member
I run all my oled axe133's at 4800 baud (32mhz clock).
All of them are using c.0 to c.2 outputs (mostly c.2), two of them are using all 3.
None have any response issues.

Not saying it's definitely not an axe133 speed problem, but unlikely I would have thought.

Worth mentioning, most of my oled projects are on the serout pin - using sertxd for
sending commands/data to the display, only if running at default clock though, for
sertxd @ 4800.

Neil
 
Last edited:
Normally one would put a SERTXD("Booting",cr,lf) at the top of the program to check for an "unexpected" Hardware Reset, but it's probably not going to work with that architecture. I think I would have connected the AXE133 to the SerOut pin (C.0) and the Servo on C.4. However, a spurious Reset is unlikely to occur when just lighting a LED, .... but it might when you start pulsing 0.5 amp or driving the Servo.
Thanks for the reply. My choice of which pin to use for each function was partly determined by just happening to pick up a partly populated AXE092 board with a switch (SW1) already in place on C.3; C.1 & C.2 are predetermined for the I²C and of course C.5 has to be an input so the other switch goes there. Because the AXE092 board doesn't have a link option to disconnect the programming pins while downloading new firmware, it was marginally easier to disconnect the servo than the LCD, but I doubt it would make any difference because even with the servo working, the LCD was rock solid even without a separated supply. It's only this control pin function that's misbehaving.
 
Also, there might be a few "tricks" to drive the FET directly from the 08M2, perhaps moving the "Close" button to "another pin" and using C.3 (and C.5, or another) as "output(s)", by activating the internal "Weak Pullup" resistors.
Yes, I did wonder about having a long press on SW1 for open and a short press for close to free up C.5, but I hadn't realised it might be feasible to use that (or C.3) as an output. An interesting and useful idea, thanks.

But I'd still like to understand why the (apparently) simple route via the outputs on the 18M2+ isn't working as it should.
 
But to solve your present problem, I would first split the SEROUT control commands into individual bytes (i.e. two SEROUTs) in case the AXE133 is not responding fast enough. And are you sure you have the correct/unmodified version of the firmware in the AXE133 chip?
I don't think there's any problem with the AXE133 responding fast enough. The rest of the software to display a real-time clock, calendar and other data works absolutely perfectly.

The AXE133 firmware I started with was a self-modified version so I got another copy from https://picaxe.com/downloads/axe133y.bas.txt and used it without further changes apart from the definition as to which type of display is to be used:
Code:
; AXE133 Serial LCD/OLED using PICAXE-18M2
; Emulates basic serial operation of the popular AXE033 module
; CPS, May 2011
; v2 18/01/2012

#picaxe 18M2

; ********************************************
; Note you must uncomment just one of these two options
; depending on whether you have an LCD or OLED module
;#define use_OLED
#define use_LCD
; ********************************************
This is the (unchanged) main routine which looks very logical and makes perfect sense as to what happens with the data when a "255" code is received:
Code:
; main program loop, runs at 16MHz

main:

    serin RX,baud,b1            ; wait for the next byte

    ; NB keep character mode test as first item in this list to optimise speed
    if b1 < 253 then
        let pinsB = b1         ; output the data
        pulsout enable,1      ; pulse the enable pin to send data.
        goto main            ; quickly loop back to top
    else if b1 = 254 then
        low rs                  ; change to command mode for next character
        serin RX,baud,b1        ; wait for the command byte
        let pinsB = b1         ; output the data
        pulsout enable,1      ; pulse the enable pin to send data.
        high rs            ; back to character mode
        goto main            ; quickly loop back to top
    else if b1 = 253 then
        serin RX,baud,b1        ; wait for the next byte
        gosub msg            ; do the 16 character message
        goto main            ; back to top
    else ; must be 255
        serin RX,baud,b1        ; wait for the next byte
        let pinsC = b1 & %00000111 | %10000000
                        ; output the data on C.0 to C.1, keep RS high
        goto main            ; back to top
    end if
I did find that a "PAUSE 100" after sending the "SEROUT c.4,N2400,(255,%010)" helped, but it doesn't change the weird polarity swap.
 

neiltechspec

Senior Member
Looking through my very early project type stuff, I found I did have an issue with this.
It was on an LCD with the backlight on c.2.

The solution was to separate out the command like this :-

serout lcd,baud, (255)
serout lcd,baud, (%100)

or with
(%000)

Not seen it with any OLED's driven at 4800 though.

Neil.
 
Running Neil's code as above but using C.0 on the 8M2 instead of C.4 to output the serial data to the AXE133 board doesn't change anything, it does exactly the same.

Short video:
 

neiltechspec

Senior Member
I have just tried again, only change for me was to a baudrate of 4800.

It worked fine with my code & yours.

Led comes on & display shows "LED on".
Led goes off & display shows "LED off"

So I have no idea what's going on for you.

Edit: I assume you have the LED+Resistor between Gnd & C.1, not +ve & C.1 ?????. That'll make it work backwards.

Neil.
 
Last edited:

AllyCat

Senior Member
Hi,

The timing in the AXE133 software is quite critical because the 255 is the last control code to be tested (after 3 ELSEs). Some time ago, I did post a "snippet" suggesting how it might be improved.

And yes, I also suspected the LED might be wired (with anode) to Vdd, but the diagram seemed quite clear. ;)

Cheers, Alan.
 
I have just tried again, only change for me was to a baudrate of 4800.

It worked fine with my code & yours.

Led comes on & display shows "LED on".
Led goes off & display shows "LED off"

So I have no idea what's going on for you.

Edit: I assume you have the LED+Resistor between Gnd & C.1, not +ve & C.1 ?????. That'll make it work backwards.

Neil.
Thanks Neil, it does appear that something might be wrong with the hardware but it's certainly not as simple as the LED wrongly connected:
IMG_20201028_095837_0_1e.JPG
The green wire goes to the black lead of the LED/resistor black lead and the red to the red.

I have a new AXE131 board ready to solder the pins into (& displays) as well as an old AXE133 board without 18M2+ so the next thing to try is a bit of hardware swapping I think and see what happens.
 
Looking through my very early project type stuff, I found I did have an issue with this.
It was on an LCD with the backlight on c.2.

The solution was to separate out the command like this :-

serout lcd,baud, (255)
serout lcd,baud, (%100)

or with
(%000)

Not seen it with any OLED's driven at 4800 though.

Neil.
Oooh!

That's interesting. I hadn't seen this suggestion of yours due to only looking at the latest replies.

I'll give that a try as it's quicker than making new hardware and it does look very much like the sort of thing that could be causing my problem.

Thanks Neil trying that now.
 
Oooh!

That's interesting. I hadn't seen this suggestion of yours due to only looking at the latest replies.

I'll give that a try as it's quicker than making new hardware and it does look very much like the sort of thing that could be causing my problem.

Thanks Neil trying that now.
GENIUS!

Thanks Neil, it now works perfectly using your code slightly modified:
Code:
main:
    do
    serout c.0,N2400,(255)
    serout c.0,N2400,(%100) ;Turn on LED
    pause 100
    serout c.0,N2400,(254,128,"LED on")   
    pause 5000
    serout c.0,N2400,(255)
    serout c.0,N2400,(%000) ;Turn off LED
    pause 100
    serout c.0,N2400,(254,128,"LED off")   
    pause 5000
    serout c.0,N2400,(254,1) ;Clear display
    pause 1000
    loop

Now to see if it switches half an amp happily!

Many thanks Neil and Alan, it's really satisfying to get to the bottom of a niggling little problem like that.
 
Note to Rev Ed people - maybe the documentation for AXE131 and AXE133 should be updated as the commands shown on, for instance, p.4 of AXE131.pdf don't work as published?

24266
 

neiltechspec

Senior Member
Glad to help with suggestions etc...

I never really understood why that was needed & I have never come across the issue since.

I think generally, the command in the AXE133 PDF does work.
Otherwise there would be a lot more issues raised, unless of course nobody uses the facility, I certainly do use it.


Neil.
 

AllyCat

Senior Member
Post #7 ... to solve your present problem, I would first split the SEROUT control commands into individual bytes (i.e. two SEROUTs) in case the AXE133 is not responding fast enough. ;)
BTW, HERE is the thread where I discussed the execution speed of the AXE133 firmware; Maybe one day I'll "finish" it, but my preference is to use HSERIN and finally solve the issue. But that's another story..... :)

Cheers, Alan.
 

neiltechspec

Senior Member
Why not just drop the 'else if b1 = 253 then' test and change the 'if b1 < 253 then' to
'if b1 < 254' . That will speed things up a bit.

How many people use the predfined messages anyway ??
 
BTW, HERE is the thread where I discussed the execution speed of the AXE133 firmware; Maybe one day I'll "finish" it, but my preference is to use HSERIN and finally solve the issue. But that's another story..... :)

Cheers, Alan.
I'm not sure why I missed this previous note of yours Alan - I'd have sorted the problem a little sooner if I had - but I'm most grateful to both of you for your time spent helping with this.
 

neiltechspec

Senior Member
It seems this was more of an issue than I thought.

Looking at one of my larger projects from 7 years ago, Classic Car Alarm /
Central Locking Unit, which originally had a 20x4 LCD display at 2400 baud,
I had done the same serout separation for the backlight & alarm LED driven
off AXE133 C.1 & C.2.

This was removed when I did a complete re-write of the S/W which included changing
to an OLED clocked at 32Mhz with serial at 4800 (instead of 16Mhz clock & 2400).
This was 5 years ago, since that point, all my AXE133 type displays have been at 4800 baud
& 32Mhz clock. , at 32Mhz it no longer seems to be an issue for me.
Hence I have not seen it since.

Neil.
 
Top