PICAXE40X2 Nixie Clock

Dicky Mint

Senior Member
Hi, I'm in the process of designing a PICAXE40X2, Nixie Tube clock.

Instead of driving the Nixie Tubes with a dedicated IC, I am using the CD4028 BCD to decimal converter and utilising high voltage SMD transistors.

I am planning on multiplexing the display which involves switching the high voltage anode of the Nixie Tubes, as well as pulling cathodes to earth.

I am not familiar with the RTC module I'm wanting to use so have designed a small test circuit PCB to experiment with this and an OLED, using I2C commands.

Looking forward to hearing what you think about the practicality of my proposed method.



Senior Member
I think it's very practicable !.

RTCs, OLEDs, I2C etc are all easily handled by PICAXE, especially the X2 versions.

However, my plan would be to get the high voltage Nixie circuits and multiplexing working first, as this is the most critical part of the project.

There are plenty designs on line for Nixie driver circuits, it should be easy to use one as a guide.

Adding RTC and OLED later will be simple.



Dicky Mint

Senior Member
OK cool.

I've produced a 'proof of concept' to drive the Nixie's, admittedly with a couple of CD4017's but it works as designed.

So that's the HV side out of the way, except switching the Anode, which I didn't test!

I think I'll test the multiplexing on the first prototype of the clock, which is probably not ideal but its all a work in progress, learning as I go.

If its designed well it 'should' work well, leaving room for a couple of bugs and fixes.

I've designed a PCB for the Nixie Tubes, their driving CD4028's and the interface wiring.

And another one for the second layer, the PICAXE40X2 and its associated connectors.

They're designed to mate together.

A crash course on the I2C protocol would be useful.

As would one on interfacing a RTC, specifically the DS1302 module with a PICAXE, specifically the PICAXE40X2!

Don't know about the availability of those?

So I'm trying to do it my own way, after scanning quite a few other designs I decided on my approach.

I'm thinking the hard part will be the conversion of the data from the RTC to the format required by the Nixie board?

And of course the multiplexing?



Technical Support
Staff member
A crash course on the I2C protocol would be useful.

As would one on interfacing a RTC, specifically the DS1302 module with a PICAXE, specifically the PICAXE40X2!
That should be fairly easy and you don't really need to know much about I2C.

Don't know about the availability of those?
That's always a difficult one to answer in current times. It should be easy enough to use any RTC chip which is available. So mostly a matter of scoring retailers to see what they have in stock.

I'm thinking the hard part will be the conversion of the data from the RTC to the format required by the Nixie board?
Extracting the decimal digits for time and date is easy enough and then it's converting those digits to whatever format is needed to drive the Nixies which should be, you guessed it, easy enough, especially if using a BCD driver; you may not need even to convert the digit data.

And of course the multiplexing?
Again should be easy enough.

So a whole lot of "easy enough" there, or at least certainly doable with help if you need it. It is probably best to settle on an RTC chip or module to use, and provide a circuit diagram showing how the Nixie drivers are connected.

Dicky Mint

Senior Member
Hi Hippy,

Well that was a pleasant experience perhaps can do, can do, can do or perhaps could do, could do, could do?

I could provide the schematic but as you know its on a strictly need-to-know basis and I don't need to know so can't provide it!

I could provide the PCB design though.

I can imagine the field-day your going to have with my data bus arrangements?

I had limited space and was running on hope that crosstalk between data lines would be at an acceptable level, i.e. below the acceptable threshold!

I appeal to the generosity of PICAXEITES with a wealth more experience than I to give me more feedback.

Rick Capture of Nixie Clock PCB 01.PNG


Can I suggest you use the DS3232 RTC, Its ultra accurate and stable only losing seconds a year unless of course your updating via a network each day. Easily integrated via IC2...


Technical Support
Staff member
I can imagine the field-day your going to have with my data bus arrangements?
Looks okay. You can probably multiples using something lie below. You would need to change the pins and polarities to suit what you have -
#Picaxe 20X2

Symbol DATA_A_PIN     = pinC.0 : Symbol DATA_A_DIR = dirC.0
Symbol DATA_B_PIN     = pinC.1 : Symbol DATA_B_DIR = dirC.1
Symbol DATA_C_PIN     = pinC.2 : Symbol DATA_C_DIR = dirC.2
Symbol DATA_D_PIN     = pinC.3 : Symbol DATA_D_DIR = dirC.3

Symbol STROBE_DIGIT_1 = B.0
Symbol STROBE_DIGIT_2 = B.1
Symbol STROBE_DIGIT_3 = B.2
Symbol STROBE_DIGIT_4 = B.3
Symbol STROBE_DIGIT_5 = B.4
Symbol STROBE_DIGIT_6 = B.5

Symbol reserveB0      = b0

Symbol DATA_A_BIT     = bit0
Symbol DATA_B_BIT     = bit1
Symbol DATA_C_BIT     = bit2
Symbol DATA_D_BIT     = bit3

Symbol digit1         = b11
Symbol digit2         = b12
Symbol digit3         = b13
Symbol digit4         = b14
Symbol digit5         = b15
Symbol digit6         = b16

#Macro OutDigit(STROBE, digit)
  b0 = digit
  High  STROBE
  Pause 10
  Low   STROBE
  Pause 1

  DATA_A_DIR = 1
  DATA_B_DIR = 1
  DATA_C_DIR = 1
  DATA_D_DIR = 1

  digit1 = 1
  digit2 = 2
  digit3 = 3
  digit4 = 4
  digit5 = 5
  digit6 = 6

    OutDigit( STROBE_DIGIT_1, digit1 )
    OutDigit( STROBE_DIGIT_2, digit2 )
    OutDigit( STROBE_DIGIT_3, digit3 )
    OutDigit( STROBE_DIGIT_4, digit4 )
    OutDigit( STROBE_DIGIT_5, digit5 )
    OutDigit( STROBE_DIGIT_6, digit6 )
One thing I might suggest is increasing the spacing between pairs of digits on your PCB. One thing I have found using 7-seg displays is "111321" is a lot less easily interpreted than "11 13 21".

Dicky Mint

Senior Member
Thanks John,

I did have a look at that RTC module and I think I've got one hanging around, but it has slightly different pin-outs so I couldn't just substitute it in my PCBs.

Thinking about it though it wouldn't be a major job to change the wiring...

I'll have a think?

Hippy...There seems to be an awful lot of code for me to 'crunch' there it might take me a few days to digest it?

Thank you though you're help is very much appreciated.

As for spacing the digits, yup I agree a really good idea but I've already chosen the enclosure and its tight as it is, so perhaps I could add alphanumeric labels above the relative pairs of digits on the front of the case?

I was worried about the data bus on my PCB. I pulled a number out of my hat and guessed that the consecutive bus lines would possibly exhibit an additional 10pF in capacitance. I don't know if that's even ballpark, or if it would make much difference anyway at suitable multiplexing frequencies?

Looking forward to trawling the code you provided.


Dicky Mint

Senior Member
Hi Hippy,

I've looked through your code and I'm kinda confused.

There are concepts which I am not at all familiar with!

Like the #Macro, I haven't used the dir command before and neither have I used the STROBE command, nor the do/loop.

That said perhaps you could help me turn my idea into real code?

The Idea

1. Set the RTC time with my PICAXE08M2 project board, I mentioned earlier.
2. Read RTC on PICAXE40X2 (C.3 (CL) and C.4 (DA))
3. Send packet 1 with BCD number for first seconds digit
4. Pause a while
41/2. Increment 'on/off' on Nixie board i.e. select second seconds digit
5. Read RTC on C.3 and C.4 for BCD number for 2nd seconds digit
6. Send packet 2 in BCD to Nixie board
Remember D.5 - D.0 are one output only
7. Read RTC into PICAXE40X2 (C.3 & C.4)
8. Send packet 3 with BCD number to 3rd digit (1st minute digit)
9. Repeat
BCD is B.0 to B.3 (A>B.0, B.>B.1, C>B.2, D>B.3)

I'm thinking what I need above all else is a description of how to read the RTC clock module and what format that's in?

I think the rest I could, maybe, cobble together?



Technical Support
Staff member
Hippy...There seems to be an awful lot of code for me to 'crunch' there it might take me a few days to digest it?
Most of it is just to make things easier to change if your hardware doesn't easily suit the code or you end up with a crossed wire. It's much easier to change code than have to resolder things, though one can always do that towards the end of a project once one knows it works.

The key is "#Macro OutDigit". That takes a digit value 0-9 and converts its bits to go on the right lines for the BCD-to-10 driver. Then it strobes the 'anode enable' line to make that digit light. Pauses for persistence of vision to kick in, turns off, waits a little to ensure it has, then on to the next.

Using "dirX.Y" and "pinX.Y" allows direct setting of a pin level, rather than a slower "If bit set Then High Else Low" construct.

The "MultiplexLoop" Just repeats that cycle for all digits, values and and associated strobes.

"Test" just pre-loads some digit values so it should show "123456".

I wouldn't worry about reading or setting the RTC for now, just get things working with a "123456", then "098765" or similar to ensure all digits are fine.

It's best to get the multiplex concept working first, ensure it does, before adding more. With multiplexing it can sometimes be hard to keep it working without flickering or glitching, so best to get that sorted, work out what timing and constraints we have before deciding on the best way to read RTC.

Dicky Mint

Senior Member
Hi Still trying to sus out your code Hippy.

Another aside though, I'm using optoisolators to switch the high voltage anodes for multiplexing but I'm having doubts about them?

I'm wondering if I would be better off using a PNP driven by a NPN transistor for each digit?

This would take up more space but I think I could squeeze them in!

The optoisolator is the TLP627 and I'm worried about using it as a high side switch?

Thanks in advance


Dicky Mint

Senior Member
I'm sorry Hippy but I'm just not up to understanding your code!

Perhaps you could talk me through the use of the DIR command I just don't seem to get it?

In fact if you could talk me through all of it that would help?

I've tried googling it but without joy.

Sorry to bother you but I think I need a little guidance?