[TUT] [HARD] [SOFT] How to build a Nixie Clock

Go To Last Post
79 posts / 0 new

Pages

Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Build a Nixie Clock – 1 – Introduction

In this tutorial I’m going to show you step by step how to build a clock with a nixie tube display, based on the ATmega48. All the functions, including timekeeping and high voltage generation, are controlled by the mega48 and it only needs a few additional components. It has power-cut backup, an alarm and a snooze function. I’ll explain the hardware and software in detail and give some guidance about component selection and physical construction. Some of the tips and tricks are applicable to other projects besides clocks.

First, why a nixie clock? Well, because nixie tubes are pretty. For people who haven’t seen equipment that uses them, which is practically everyone under the age of 40, they consist of a glass tube similar to a vacuum tube containing electrodes in the shape of numbers that light up with a soft orange glow. They were introduced in the 1960s as readout devices for the emerging digital technology and were pretty common into the early 1970s, when more complex ICs and LEDs offered a cheaper and more convenient alternative. Then they practically disappeared for a quarter century. Presently they are experiencing something of a revival thanks to the availability of large quantities from Russia, where (so I’m told) a factory was forgotten by the central planning authorities and continued producing them long after demand had ceased. But once these stocks are gone there will never be any more made, so if you want to build a nixie clock the time is now. Go on, do it – leave your grandchildren something to fight over. (If you don’t care to use nixies you can use LEDs or other alternative displays – I’ll cover that later.)

The first problem is getting hold of some nixie tubes. You can’t buy these at Digikey. Ebay is the best source, though all the sellers are in Russia or Ukraine and this makes some people nervous. I’ve done business with four of these vendors and can say they’ve all been honest, helpful and quick. Here are their Ebay IDs – EXLAND, FUTURGLAS, UBITDRAPOM, NIXIESTORE. They all have different stuff, so you have to know what you want and find the appropriate seller. If you don’t care to use Ebay, and in connection with deciding what kind you want, there is a good selection (with pictures) for sale at Jan Wusten’s store in Germany. Jan’s prices are higher because he’s a retailer, but they’re not unreasonable.

I have some recommendations. All these are Russian. “IN” presumably stands for “indicator neon”.

First, smallest and cheapest, is the IN-17. This is an end view tube with about 0.4 inch (9mm) digits. The current market price on Ebay is about $10 for twenty. It isn’t the prettiest nixie but surely they don’t come any cheaper. With these you can afford to take chances and make mistakes.

Next, going up a size, is the IN-16. This is a slender upright tube, half an inch in diameter, with nicely formed digits about 0.5 inches (13mm) high. You’ll pay around $1 to $1.50 each for IN-16s on Ebay, depending how many you buy at once.

Going up in size again, the IN-8 is fatter than the IN-16 with larger digits, 0.75 inch, 18mm. This is a pleasing size and quite sought-after - you’ll pay at least $2 on Ebay. Look for the IN-8-2 version, which has wire leads. This is about the same size as the cheaper IN-14, but the IN-14 doesn’t have a proper “5” digit.

For plutocrats, consider the IN-18. This guy is huge and extremely beautiful with 1.6 inch, 40mm digits. They cost $20 to $30 each at present so you have to be rich, or really really confident, to pick them for a first project. These tubes have a base with pins, which presents some problems for prototyping. All the others I mentioned have solderable wire leads.

There are many other kinds available from time to time, at prices ranging from a dollar or two up to hundreds of dollars each for the rarest types. You can use anything you can get your hands on, but for a construction project like this I need to base it on what’s available in quantity – I’d hate to see a bunch of motivated AVR Freaks all bidding against each other for the same set of rare tubes. Here are some pictures. In the next section I’ll post the schematic and software, and then I’ll get down to the business of how it works and how to make it.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Build a Nixie Clock – 2 – Hardware

I’ll briefly go over the schematic here, and cover the sections in more detail later together with the software that drives them. As a reminder, this design is based on the ATmega48, though other kinds of AVR are equally suitable so long as they have three timers - one of which can run asynchronously - and an ADC. Your backup mileage will vary with other devices.

A nixie needs about 175 volts to light up. This presents two problems – generating the 175 volts, and switching it to where it’s needed. I generate the 175V with a switching power supply, using the AVR's Timer0 in PWM mode to drive the switching transistor, and regulating it by reading the output with the AVR's ADC. The converter circuit I show here works much better than the one most people have seen based on the MAX771. It runs icy cool and can easily supply 20mA at 180V. I’ll explain the design philosophy and component selection in detail later. If you put your finger across the output capacitor it will sting you, so be careful.

I can’t switch the nixie cathodes directly with the AVR because the ports can’t stand the voltage, so it needs some help in the form of high voltage ICs and switching transistors. There are various ways to do this, which I’ll discuss later. For this clock I chose to multiplex the tubes using an HV5812 serial high voltage driver chip running on SPI. The cathodes are connected in parallel across all six tubes - only two are shown in the diagram - and directly driven by the HV5812. This chip can’t drive the anodes directly but it does control what at first glance looks like a horrifying number of transistors to put the 175V where it will do the most good. The NPN transistors are connected in an unconventional way, common base, which I’ll explain later. There are other ways to do it, but this turned out to have the smallest parts count.

The AVR has a 32.768kHz watch crystal for time keeping. Internally it runs off its RC clock at 8MHz – the crystal is running Timer2, which can keep going in power-save mode when everything else is shut down. There’s a trimmer capacitor, C13, on the crystal. You can use this to adjust the clock to better than one part in a million, a couple of seconds a month. Of course in order to do so, you need an accurate way of measuring it, so the AVR outputs a 1 Hz clock on PORTC.5 (test point 1). This is of little use without a precision counter-timer, so if you don’t happen to have one you can forget the trimmer and use a fixed capacitor. It still won’t be worse than about 1 second a day.

I mentioned power save mode. The AVR has its supply isolated from the main 5V by diode D3, and backed up by a 0.22 Farad supercap C4. It keeps an eye on the main 5V via PINC.1 and when it sees this pin drop, it shuts everything down and goes to sleep, waking briefly for the 1 second interrupt from Timer 2. When it sees that PINC.1 is back up, it restores everything and carries on as before. You get about a day’s backup using the “V” version of the Mega48. The supercap can be disconnected by jumper J2, which you’ll find convenient when you’re troubleshooting.

I use the AVR’s analog to digital converter to control the high voltage. This requires some decoupling of AVCC and VREF. L2 is a ferrite bead, which together with C9 keeps the AVCC pin quiet without dropping any DC voltage. C11 decouples VREF, which is the AVR’s internal 1.1V reference.

The alarm sounder deserves a mention. I drive this push-pull between PORTB.0 and PORTB.1, and it’s very loud. The sounder has a DC resistance of about 35 ohms, which sounds alarmingly low (puns intended) for AVR ports to drive, but doesn’t cause any overheating or other difficulties in practice. There’s a 22uF ceramic capacitor in series to block DC. The waveform for the alarm is generated from the only remaining timer, Timer1, which also has other jobs to do like multiplexing the tubes, so Timer1 is run at 12kHz and everything else is divided down from that.

Everything else is straightforward. The switches use internal pullup resistors, and there are 3 LED drivers provided for such things as PM indicator and Alarm reminder. The external reset switch is necessary, unless you don’t mind opening the case to remove jumper J2 when you really need a reset.

EDIT: I redrew the schematic (showing all the tubes this time) because I realized I showed the cathodes connected in the reverse order (0 for 9) the first time. It was no big deal, it could be easily corrected in software, but I should get it right if I aspire to run a tutorial. :oops:

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Build a Nixie Clock – 3 – High Voltage Generator part 1

Let’s review from first principles how a boost circuit works.

You will recall that passing a current through a wire causes a magnetic field. It’s also true that passing a magnetic field through a wire causes a current (the magnetic field has to be changing – a steady field has no effect). So if we take a wire, tightly coiled up around a piece of iron to enhance the effect, and apply a voltage from a power supply across it, a current starts to flow. This current causes a magnetic field to appear. The rising magnetic field causes a current to flow in the wire, and by one of those coincidences that makes the Universe possible, this “induced” current is in the opposite direction to the one from the power supply and is effectively subtracted from it. If everything was perfect, they would exactly balance and no current at all would flow, but if no current flowed there would be no magnetic field … In practice a much smaller than expected current flows and slowly increases at a rate determined by the coil inductance and the losses. The bigger the inductance, the slower the rise; the bigger the losses (resistance), the faster the rise. The current carries on rising at some rate until the iron core becomes so strongly magnetized that it can’t take any more. If the field can’t rise any more it can’t generate any more opposing current; so the supply current rapidly rises out of control to the power supply’s limit. This is called saturation and is generally undesirable.

In our circuit, we turn on the FET Q13. A voltage appears across L1, positive at the top and negative at the bottom, and a current starts to flow. A magnetic field forms and opposes the current, so it rises fairly gradually. After a short period of time, before the current has time to reach the saturation point, we turn off the FET. Now an interesting thing happens. There’s a magnetic field in the coil, but suddenly no current to maintain it. The field starts to collapse, and as it does, it induces a current in the wire. Now when the field was rising, the induced current tried to flow against the incoming current (upwards, in the schematic). But now it’s falling, so instead of flowing against the incoming current, it flows with it, trying to stop it changing. As a result an opposite voltage appears across the coil, positive at the bottom and negative at the top. But the FET is turned off - there’s no way out for the current except through the diode D1, so that’s where it goes. Initially capacitor C2 is discharged, but the current charges it and makes its voltage rise. Now the induced current has something to work against and starts to fall, which makes the magnetic field fall faster, which redoubles its efforts to maintain the current – which makes the positive voltage at the bottom of the coil grow bigger until it can overcome the capacitor voltage. This goes on until the coil finally runs out of magnetic field. The voltage on the capacitor can’t escape because of D1, so it just stays there.

On the next cycle, the same thing happens, but this time there’s an initial voltage on the capacitor that needs to be overcome, so the coil has to work harder and produce a higher voltage to keep the current flowing. So the capacitor voltage pumps up again, and as before, it just stays there. If this goes on, in theory there is no limit to how high the voltage will go – by hook or by crook, the coil is going to unload the energy in its magnetic field, even if it has to produce ten million volts to do it. In practice, that’s where our control circuit comes in.

Time to look at some code. The FET is turned on and off by Timer0, working in Fast PWM mode, and regulated by the analog to digital convertor. Here’s how Timer0 is set up. You may want to refer to section 13.8 of the Mega48 manual to follow this.

; Set up timer 0 as fast PWM
; With OCR0A at 0xFF, frequency will be 31.25kHz
; Note: “acc” is .DEF’d as r24 earlier in the program
; and “zero” is a register preloaded with 0x00
setup_timer0:
		cbi		PORTD,5				; PORTD.5 will be OC0B
		cbi		DDRD,5					; leave output off for now
		sts		TIMSK0,zero				; no timer 0 interrupts
		ldi		acc,top_value				; a constant
		out		OCR0A,acc				; set top
		lsr		acc
		lsr		acc					; initial setpoint 12%
		lsr		acc
		out		OCR0B,acc
		ldi		acc,0b00100011				; fast PWM to OCB
		out		TCCR0A,acc
		ldi		acc,0b00001001				; OCRA top, prescale 1
		out		TCCR0B,acc
		ret

The timer has been set up to count at the full clock speed (8MHz). It starts at zero and counts up until it matches Output Compare Register A, which has been set to some constant, then clears to zero and starts again. The constant top_value sets the repetition rate of the counter. With a value of 255, this is about 31kHz. Setting a smaller value speeds it up. The chosen rate depends on the inductor – we don’t want a pulse long enough to saturate it.

Now in this mode, when the counter resets to 0 it takes pin OC0B high. This is the pin connected to the FET gate and will turn the FET on when it goes high. When the count matches Output Compare Register B, OC0B goes low and turns the FET off. By changing the value in OCR0B we can vary the width of the pulse, which varies the “on” time of the FET, which varies the amount of energy stored in the coil. The more energy, the larger the amount it will pump up the capacitor each cycle. That’s how we regulate the voltage. Initially we set OCR0B to one eighth of top_value, giving a duty cycle of 12.5%. Actually, initially we have a duty cycle of zero, because the OC0B pin is left set as an input, so the external resistor holds the FET turned off. There’s no interrupt routine associated with Timer0. Once it starts, it can be left entirely to its own devices.

Next we set up the ADC – refer to section 22.6 of the Mega48 manual.

; set up ADC for channel 0, internal reference
setup_adc:
		lds		acc,PRR
		cbr		acc,(1<<PRADC)				; enable ADC
		sts		PRR,acc
		ldi		acc,0b00000001
		sts		DIDR0,acc				; disable input PC.0
		ldi		acc,0b11100000
		sts		ADMUX,acc				; int ref, left, ch 0
		ldi		acc,0b11011110
		sts		ADCSRA,acc				; enable/int/ps64/start
		sts		ADCSRB,zero
		ret

The first operation is to turn on the ADC reference in PRR, the power reduction register. We have to do this because during the power save operation we’re going to turn it off. The next operation disconnects the digital input of PORTC.0, which is the analog input pin. If we don’t do this, leakage and noise from the digital input circuit will mess up our readings. Next, we select the internal reference, left-justified (8 bit) result, and multiplexer channel 0. Finally we enable the ADC, turn on its interrupt, select a clock prescaler of 64 and tell it to get to work. Nothing happens right away. The ADC samples the input pin and starts converting. When it’s finished it generates an interrupt, and that’s when things start happening.

; ADC interrupt service routine
; Note: “sreg_save” and “setpoint” are registers .DEF’d earlier
ADCCisr:
		in  		sreg_save,SREG				; save sreg
		push		acc
		lds 		acc,ADCH				; get adc reading
		cp  		acc,setpoint				; compare to setpoint
		breq		adc04					; same
		in  		acc,OCR0B				; get current pwm val
		brcs		adc02					; lower, increase
		tst 		acc					; higher, decrease
		breq		adc04					; but not below 0
		dec 		acc
		brne		adc03
; if OCR0B is zero, turn off output
		cbi 		DDRD,5
		rjmp		adc03
; if OCR0B is increasing, turn on output
adc02:
		sbi 		DDRD,5					; output on
		cpi 		acc,(top_value*4)/5			; lower, increase
		brcc		adc04					; up to 80% of top
		inc 		acc
adc03:
		out 		OCR0B,acc				; out to counter
adc04:
		ldi 		acc,0b11011110
		sts 		ADCSRA,acc				; enable/int/ps64/start
		pop 		acc
		out 		SREG,sreg_save
		reti

The ISR starts by saving the flags register SREG, and pushing any registers it needs to use – only one in this case. Then it reads the conversion value from the high register, which is the top 8 bits of a 10 bit value because we told the AVR to left-justify the result during the setup. We compare it to the setpoint, which is conveniently stored in a register to make this quick and easy. If it matches exactly we do nothing and exit right away at label adc04. It probably won’t match, so next we read the contents of Output Compare Register B, which we’re going to change. If the ADC reading is less than the setpoint we need to make the pulse longer by increasing OCR0B. We know to do this because the “cp” instruction will have set the carry flag, causing a jump to label adc04. If the carry is not set, we know we need to shorten the pulse by reducing OCR0B. But we must be careful not to decrement from 0x00 to 0xFF or we’ll be in a world of trouble because the FET will never turn off, so first we test it for zero, and if it is in fact already 0x00 we leave it alone and exit at adc04. Assuming it’s not already zero, we reduce it. If the value is now zero, we disable the OC0B output. If we don’t do this we give the FET a 60 nanosecond pulse every cycle, which is unnecessary and possibly harmful.

If we need to increase OCR0B to get more power, we first turn on the OC0B output in case it was turned off before, then increment the value, but we don’t let it increase all the way to top_value because we always need some off time to discharge the coil. I arbitrarily set the limit at 80% of top_value, giving a minimum off time of about 6us in this case. Because it’s calculated from the top_value constant it stays proportional to the switching period if you change this value.

Finally we write back the new value of OCR0B, restart the ADC, restore the register and flags, and exit. Timer0 is double-buffered so the new value won’t affect the current cycle, but will be loaded next time it reaches a cycle end.

Now an ADC conversion takes 13 cycles, and we set a prescaler of 64 on the clock, so the ADC is running at 125kHz and we execute this routine every 104us. During this time, Timer0 issues at least three pulses to the FET. Further, if an adjustment needs to be made, this routine only changes the OCR0B register by one each 104us. So the transient response is pretty poor. Where this matters most is when the nixie display changes from all-on to all-off, as happens when the display flashes. The sudden change from full load to no load sends the output voltage soaring, and as mentioned above, if something isn’t done smartly to limit it, the voltage will carry on rising until something breaks. In this particular application we get away with it, but it’s marginal. A possible enhancement, which I’m working on but haven’t tested, is to subtract the ADC’s measured value from the setpoint and if it’s substantially higher, disable the pulse output until the measured voltage falls below the setpoint. Most commercial switching regulator chips do this. It still isn’t ideal, because the ADC interrupt will step down the OCR0B value until the voltage matches the setpoint. When the load comes back on the setting will be too low and will take a while to ramp up. A proportional system would be better still. There’s probably an Atmel application note about this somewhere.

Component Selection
This is already a long section but I need to say something about component selection here. The critical piece is the power FET. We need three qualities – the lowest possible on resistance, the ability to turn fully on with about 4 volts on the gate, and the ability to withstand at least 200V. There is not a big selection of parts that meet all three requirements. So-called “logic level” FETs, those which can turn on at 4V, generally don’t have a very high voltage rating – 200V is about as high as they go. Further, to get a low “on” resistance we need a large piece of silicon, so even though we don’t need the power dissipation, we’re going to be stuck with a large power package. I used a Fairchild IRLS640A, which is currently $1.67 from Mouser Electronics. You may find alternatives, but don’t waste your time playing with anything in a smaller package than TO-220. They work for a few minutes, then they turn brown and the solder melts.

For the inductor, I used a Talema (Alfa Mag) TE2058. I like these inductors because they’re quite small and they have an iron permalloy core, which doesn’t saturate easily and works well at this frequency. The TE2058 is 248 microhenrys and the high inductance keeps the current quite low, though it does limit the available output. I tested it by watching the FET pulse width vary under increasing loads and found it maxed out close to 20mA at 180V. You can squeeze a bit more out by increasing the maximum width to 90% of the Timer0 period, or by turning the input voltage up, but to get a substantial increase the inductance needs to be smaller, like about 125uH. Then you’d have to be careful the core didn’t saturate, so you would probably select a physically larger one – size matters. This clock using multiplexed tubes only needs a few mA so it isn’t an issue.

Concerning the voltage setpoint, the ADC measures it off the voltage divider R4/R5, 1M and 4.7k, and compares it to the internal voltage reference of 1.1V. You can do the math on this and calculate what the readings should be for various voltages, but everything has a tolerance. My IN16 clock was wildly out, and I had to use the value I calculated for 145V to get 175V. In contrast, the IN17 clock was spot on. So when you get to this stage, have a meter handy, measure the high voltage and be prepared to tweak the setpoint constant in software. You could always use a variable resistor in the feedback chain, but it’s much easier to tweak the software.

I was going to explain why the AVR circuit works better than the normal MAX771 circuit but that will have to be another section.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Build a Nixie Clock – 4 – High Voltage Generator, part 2

You may have looked at my schematic and said to yourself, wait a minute – that looks exactly the same as the MAX771 circuit! Well yes, I suppose it does. But the difference is where you can’t see it, inside the MAX and the AVR.

Refer to my diagram below. On the left is a MAX771, on the right an AVR, showing the internal output stage. Now you’ll see that the MAX has only one transistor, driving the gate of the FET high. When the MAX wants to turn the FET off it turns off this transistor, and the gate is pulled to ground by a resistor. On the right is an AVR, which has a 2 transistor push-pull output stage driving the FET gate. This also has a resistor to ground, but its purpose is only to keep the FET turned off when the port pin is floating. When the AVR wants to turn off the FET, it turns on its lower transistor and clamps the gate directly to ground.

The resistor on the MAX771 is its great weakness. The FET gate has some capacitance, charged up to the turn-on voltage, and the device can’t turn off until that capacitance is discharged – which, through a resistor, takes some time. Putting numbers on it, if the resistor is 330 ohms and the capacitance is 1500pF, the time constant is 0.5 microseconds. This is the time it takes the gate voltage to fall by 67% of its original value. Since with the MAX771 the original value is something like 12V, then after 1us the FET still has about 4 volts on its gate. In the next 0.5us this falls to about 1.5V, and after 1.5us, to 0.5V. Now FETs don’t turn off hard and fast – over some voltage range they have a more or less linear relationship of on-resistance to gate voltage. At some point in that 1.5 microseconds the gate voltage will fall enough so that the FET presents some small resistance, and the current will fall slightly. The inductor responds by cranking up the drain voltage to maintain the current, but nowhere near high enough to overcome the capacitor voltage, so power is dissipated in the resistance of the FET. As the gate voltage continues to fall this goes on and on, with the drain voltage and the FET resistance both getting higher, until at some point the voltage matches the capacitor voltage and the remaining power goes into the capacitor. But before it reaches this point a substantial amount of the inductor’s stored power is wasted in the FET, which can get quite hot, and there’s correspondingly less of it available to charge the capacitor.

If that was all, it would be bad enough, but now meet the Miller effect. There is a small capacitance between the FET gate and drain, and as the drain voltage climbs, this capacitance feeds extra charge to the gate, keeping the FET turned on and slowing the rate of rise of the drain voltage. The capacitance doesn’t have to be very big because it’s effectively multiplied by the gain of the FET, and the effect is serious enough to get a mention in the FET data sheet. In the MAX771 circuit this about doubles the turnoff time and wastes a lot more power. If you look at the drain of the FET with a scope, you’ll see that the high voltage rising edge has a distinct slope to it. The area under that slope represents wasted power.

Now referring to the AVR half of the diagram, I’m sure you can see why that transistor pulling the FET gate directly to ground makes all the difference. It not only gets the initial charge out of the gate very quickly, but it grounds out the Miller charge too. The result, if you look at it on a scope, is that the FET turns off very fast and the high voltage rising edge is nearly vertical, so there is very little area underneath it and correspondingly little wasted power.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Build a Nixie Clock – 5 – Driving the Tubes part 1

Cold cathode discharge tubes like nixies need a high voltage to strike – start the discharge – but once the discharge is going, the voltage across the tube falls to a lower level that stays fairly constant over a wide range of current. You can think of them as kind of a high voltage zener diode, and in fact in the days of vacuum tubes, neons were used as voltage regulators. Nixies are designed to strike at around 170 volts and once struck, maintain a voltage of about 140-150V. You would think, then, that with a 175V supply the cathode drivers would only need to withstand 175 minus the voltage across the tube, or about 40 volts. It’s not quite that simple, because when the tube is dark stray ions can make the cathodes float to very nearly the full supply voltage, but with a few precautions (like high value resistors to an intermediate voltage, or making sure the tube never goes out) a 75 volt driver is quite adequate.

There is some selection of devices that can do the job. The original nixie driver was the TTL 74141 decade decoder driver, which took four TTL inputs and decoded them to ten high voltage outputs. These have been out of production for many years, but large quantities of Russian equivalents are available at present. In the good old days they would have been connected to individual 4-bit counter chips, one counter and one decoder per tube. These days we’d drive the inputs from four port lines on a micro. There are nixie kits around that do it that way. It’s necessary to multiplex the tubes, unless you’re able to provide four port lines and a decoder for each digit. We could bring the decoder logic inside the micro and drive the cathodes with individual transistors. Again, we need to multiplex, otherwise we need ten port pins and transistors for each digit. Even multiplexed, a six digit clock is going to need sixteen port pins – too many for a Mega48, though one of the 40 pin AVRs could handle it.

Then there’s serial driving, which I like because it saves a lot of work and parts. Here there are a couple of choices. The company Supertex makes a good range. Favorite would be the HV5522 series, which are serial drivers with 32 open-collector 300V outputs, except that the spec says they need to run off 12V Vcc. I have it on good authority that they run quite nicely at 5V, but who wants to take chances when there’s something else available. This is the HV5812 which is what we use here. There’s another source for this chip, or something nearly identical anyway – the MAX6921. (A nod here to Freaks member Barnacle, who first brought these chips to my attention). The HV5812 has a slightly better spec. Prototypers will be overjoyed to learn the HV5812 comes in a 28 pin DIP package, $2.70 from Mouser. Otherwise there’s PLCC, for which there are sockets with pins on a 0.1 grid. Serial drivers only need three or four port lines to do the whole job, and we have a choice – cascade as many chips as we need to run the tubes un-multiplexed, or drive the multiplexing transistors from the serial chip itself. A glance at the schematic reveals I’ve chosen to do it the second (hard) way, but that’s easily changed if you want to do it un-multiplexed. Each HV5812 has 20 outputs and can drive two nixies, and running un-multiplexed simplifies the software quite a lot, though it does increase the tube wiring by a factor of about four.

These chips are designed to drive vacuum fluorescent displays, so I’ll digress a bit to talk about them. VFDs are opposite to nixies in many ways. They’re a bit like an old vacuum tube triode, with a heated cathode, a control grid and many anodes, which can be in any shape. There may be one in a tube, like a 7 segment display, or many in the same tube, like the display on a typical DVD player or car radio. The light in a VFD comes from the anodes, not the cathode, and can be any color depending on the phosphor used. They run at about 60 volts. A chip like the HV5812 is designed to drive VFD anodes, so it needs to source current from a 60V supply. To turn off a VFD anode it needs to be taken to a low voltage, ie ground, but it doesn’t need any current. Hence the highly asymmetric characteristic of the HV5812 outputs, which can source 40mA but only sink a couple of mA.

The HV5812 needs a high voltage supply around 60V, which in my schematic is obtained from the voltage divider R1/R2. We don’t want to waste too much of the hard-to-get high voltage on this intermediate supply, so the resistor values are quite high – 100k/47k – and the current drain has to be kept as low as possible, 10uA or so. That presents a slight problem for the transistors driving the tube anodes, as they get their turn-on current from this supply.

If you look at the schematic you’ll see each anode has two transistors, an NPN and a PNP. The PNP transistor delivers the high voltage to the tube anode. To turn it on its base needs to be pulled low, and to turn it off, pulled up to the 180V supply. Unfortunately, if we connect these transistor bases directly to the HV5812, they’ll think the high of 60V isn’t much different from the low of 0V, compared to 180V, and they’ll never turn off. So we need NPN transistors to make sure the PNP bases go all the way up to the 180V level. Driving the NPN transistors is another problem. If we do it the conventional way, with a resistor from the HV5812 output to the transistor base, I have my doubts that the HV5812 output would go low enough to turn them off. Connecting them common base is the answer because it’s very forgiving of poor logic levels.

On the schematic you’ll see that all the NPN bases are connected to the 60V supply, and the emitters to the HV5812 outputs through 100k resistors. The collectors go directly – no series resistors – to the PNP bases, and there are 10k resistors from the PNP bases to the 180V supply. When the HV5812 output is off (high), the NPN emitter is at or close to 60V, the same potential as its base. That means it should be turned off. If it’s turned on just a little, say it has 1V from base to emitter, it will pass a small current – 1V less the 0.6V Vbe, or 0.4V, across 100k. That’s 4uA. This current will develop a voltage of 40mV across the 10k collector resistor, well short of what’s needed to turn on the PNP. In fact we can handle a leakage current of 60uA without accidentally turning on a PNP, which corresponds to a Vbe on the NPN of about 6 volts, or the HV5812 output being 6 volts below its specified high level. That’s plenty of margin. In order to turn on a PNP anode transistor we need to take the HV5812 output low, which takes the NPN emitter low. Now the transistor starts to act like an emitter follower, holding the top of its 100k resistor just below its base voltage of 60V. If the HV5812 takes the bottom end of the resistor to 0V, a current of 600uA results, which would develop 6V across the 10k resistor if there weren’t a PNP transistor in parallel. In fact, most of the 600uA flows out of the PNP base and the transistor turns on. The fact that there’s no series resistor doesn’t matter, because the current will never exceed 600uA. The transistors in this project have a minimum gain of 40, so the PNP will deliver at least (40*0.6) or 24mA to the nixie anode if needed. Down at the bottom end, there’s another useful characteristic of a common base connection. However many volts are applied to it, the NPN transistor will only draw just enough base current to hold its emitter voltage steady. That means if it’s passing 600uA, and it has a gain of 40, it will only draw (600/40) or 15uA from the 60V supply and thus not pull it down too much.

The nixie cathodes are connected directly to the HV5812 outputs. To turn one on, the output goes low. This takes all the same-number cathodes low. Simultaneously one of the tube driver transistors is turned on, applying 180V across that tube and its anode resistor. This tube strikes and the grounded cathode lights up. The other cathodes are connected, via their HV5812 outputs, to the 60V supply. They only have at most 120V across them, which is neither enough to strike them nor keep them lit, so they stay dark. It’s the AVR’s job to match cathodes with digits and drive the data out of its SPI port into the HV5812 in a steady stream, fast enough to give the illusion that all the tubes are lit all the time.

There’s one slight nuisance about VFD drivers, in that their blanking input takes all the outputs low. This does the job for VFDs, but in a nixie circuit it turns on all the cathodes on all the tubes at once. We would rather that didn’t happen, so the blanking input (pin 13) is permanently and securely connected to ground.

That’s it for the nixie driver hardware. Setting up the SPI, decoding the digits and driving the multiplexer comes next.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Fascinating stuff. Our family friends have an OLD electronic calculator which uses Nixies, and if it wasn't so interesting and if I wasn't so afraid of electrocuting myself (damn you, original iMacs!) I would have opened it up and "borrowed" them.

Always wondered - well, at least since mid last year when I learned what Nixies are - about the lifespan of the tubes. Do they last as long as an incandescent globe, or longer?

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Dean - with the Russian tubes so plentiful and cheap at the moment, there's no need to wreck a valuable antique! I once bought a nixie DVM for the tubes, and two years later I'm still using it for its original purpose. The tube life is very long, decades. They eventually fade away when the cathode metal erodes, which makes them hard to strike. I've never known this happen with a well-made industrial tube, but I had a cheap alarm clock once with a neon seven-segment display that wore out and started flickering like a bad fluorescent light.

This proj is moving along a little slower during the week because of the unfortunate necessity of going to work, but I'll pick up the pace again soon. I did the hardware first because the software isn't much use without it. I'd be interested in hearing from anyone planning on building one - PM me to avoid messing up the thread. If enough people are interested I'll start a discussion thread.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The mega48 cpu is more than enough for this application, but
I wonder (actually I'm sure I could) substitute the mega16 cpu
for this application. Why? Well it's the smallest megaavr that
will work with the jtag-ice mark-I (and all it's clones). Also
I have quite a few of them left over from prototyping work
we did for a now shipping product. Come think of it, with the extra
IO lines available on the mega16 I could replace the HV5812 with an 8 bit
latch, and two 4 line to 10 line decoders. (I hate I2C)

I'm waiting for you to post the software
(though it's something I could design myself). One suggestion, why not
add a power line interrupt to synchronize the clock against the power
line (when available)? I'd use a 9v battery to keep the unit alive during
power outages and only run the timebase off the 32khz crystal when
the unit stays alive off the battery.

There sure is quite a selection of nixie tubes available on ebay
at the moment. And most of those russian sources even take
paypal. I'm tempted to build SOMETHING using those Nixe tubes
(remember the ORIGINAL CX7 ham transceiver?) BTW some years
back most of the surplus houses were selling these really GIANT
14 segment alpha numeric nixies (2 or 3 inch high characters).
Has anybody seen any of these lately? Now that would make for a nice
Clock.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Of course you can use a Mega16, and parallel decoders, but parallel decoders are kind of hard to get. You can get them the same place you get tubes, but the supply is limited and once they're gone, they're gone for good, so I hope you don't blow one up. The HV5812 is available and it isn't I2C, it's straight serial running on the SPI port. I already wrote up that section but didn't get round to posting it yet, because (ahem) when I was checking my source code I noticed I didn't actually use the SPI hardware - I was bit-banging the port. I had to rewrite it for SPI and test it again.

If you have a crystal, why would you time it off the power line? Of course you could, I just don't see why you would.

I apologize for the delay in adding to the project - I'll pick it up again this weekend.

Quote:
really GIANT 14 segment alpha numeric nixies (2 or 3 inch high characters). Has anybody seen any of these lately?

I had quite a few and I've got about ten left. You still see them occasionally, though the price these days is getting rather high to waste them on a clock. I posted pictures of my B7971 project here: http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=206892&highlight=#206892. My state-of-the-art has advanced quite a lot since I made that unit and I should post pictures of the new and improved version.The tubes are two inches (50mm) in diameter, for scale.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
If you have a crystal, why would you time it off the power line? Of course you could, I just don't see why you would.

I was under the impression that the power line 60Hz (or 50Hz where I come from) was extremely accurate long term. Indeed, when I was a kid everyone had mains driven synchronous clocks. Maybe that situation has changed?

Quebracho seems to be the hardest wood.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

VERY interesting stuff, i never found the basics of inductors explained that well...

By the way..., just days ago i stumbled over this nixie clock project:
http://www.jogis-roehrenbude.de/Leserbriefe/Nixie-Clock/nixie-clock.htm

-- Thilo

Einstein was right: "Two things are unlimited: the universe and the human stupidity. But i'm not quite sure about the former..."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
i never found the basics of inductors explained that well...

Me either !!! Usually the textbooks have to have page after page of math expressions, which is necessary, but an explanation behorehand like the one above would be SO HELPFUL in understanding the math...in my opinion of course :-) . Very nice job Peret !!!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
Of course you can use a Mega16, and parallel decoders, but parallel decoders are kind of hard to get. You can get them the same place you get tubes, but the supply is limited and once they're gone, they're gone for good, so I hope you don't blow one up.

High voltage 4 to 10 line decoders are hard to get, but I think the ttl
level kind are not. You could also cascade two 74138's or a 74138 and
a 74139 to create one. I would then use the ttl level to drive HV transistors.

In any case I see that the hv5812 is listed in Mouser's catalog and the price is right. The serial SPI interface in the AVR isn't a problem
to deal with and it looks like you don't have to bit bang it, just simple 8 bit writes. I can deal with that. BTW if you use the 40 pin package there is a version of the hv5812 family that will drive 3 digits and a 64 pin package that will drive all 6. Some family members look like they could drive the nixies without the transistors as they can handle more voltage.

Over time the 60hz power line is very accurate and it makes good sense to use it as a time base. Many clocks do this switching to the crystal time base only when running off batteries. The only rub...if you have an emergency back up generator you DON'T want to run the clock off the powerline with that! My emergency generator (Hurricane country here in South Florida) actually puts out about 64-66 hz and the clocks run almost 10% fast!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Build a Nixie Clock – 6 – the Code

Other events have pushed this project aside for a while, sorry about that. I’ll put the whole code up now and then cover the important bits a section at a time. It’s written for AVRasm version 2.

Some notes on the structure. I have a boilerplate header that I use for all my assembler programs. It starts like this:

	.NOLIST
		.INCLUDE "m48def.inc"
		.LIST

.equ		false	 		=0
.equ		true 			=~(false)

The particular AVR definition file always needs to be there. I put it in a “nolist” section because I don’t care to wade through pages of definitions in the listing file when I’m debugging. Next come “true” and “false” definitions, for use with conditional assembly switches. There is one such switch in this program –

.equ		alarm			=false		; build option switch

What this does is turn off or on the section of code related to alarm setting, so that if you aren’t using the alarm, you never get the option to set it.

I like to put all my other .equ statements next, so they’re easy to find. Principal among these are bit definitions for my “flag” registers, like so:

; bits and masks in status_flags
.equ		sf_halfsec		=0
.equ		sf_mod			=1
.equ		sf_mux			=2
.equ		sf_altsec			=3
.equ		sf_setdata		=4
.equ		sf_set1ms		=5
.equ		sf_setmode		=6
.equ		sf_invalid		=7

.equ		sm_halfsec		=0x01
.equ		sm_mod			=0x02
.equ		sm_mux			=0x04
.equ		sm_altsec		=0x08
.equ		sm_setdata		=0x10
.equ		sm_set1ms		=0x20
.equ		sm_setmode		=0x40
.equ		sm_invalid		=0x80

What I’ve done here is first define the bits, then bit masks with similar names, because I hate this kind of construction:

		sbr		status_flags,(1<<sf_halfsec)

I much prefer this:

		sbr		status_flags,sm_halfsec

A little further down are my register definitions. I have some conventions here too. I always list every register, whether I use it or not, but I comment out the ones I don’t use. I never define symbolic names for r0 or r1, as these are used by the MUL instruction. I always define a register as “zero” and set it to 0x00, and another as “one” and set it to 0x01. These come in very useful. Starting at r16, the first register that allows LDI and SBR, I have a group of registers reserved for bit flags. I use two of them here, status_flags and t_flags. All their bits are defined in equate statements above. Registers r24 and r25 are my “accumulator”, general purpose registers, designated as “acc” and “acchi”. I always use this pair because they can use the ADIW and SBIW instructions, like the X, Y and Z pairs, which comes in useful occasionally. The rest of the registers are named as required. Here I keep binary counters for seconds, minutes and hours in r8, r9 and r10 respectively.

; Register equates
;.def			=r0
;.def			=r1
;.def			=r2
.def	sreg_save	=r3
.def	zero		=r4
.def	one		=r5
.def	twelve		=r6
.def	alarm_mod	=r7
.def	s_bin		=r8
.def	m_bin		=r9
.def	h_bin		=r10
.def	tb12		=r11
;.def			=r12
;.def			=r13
.def	setpoint	=r14		; voltage setpoint
.def	pind_img	=r15		; last state of PIND

.def	status_flags	=r16		; bit 0: 1/2 sec toggle
					; bit 1: modulator toggle
					; bit 2: multiplex flag
					; bit 3: alternate seconds
					; bit 4: set data changed
					; bit 5: T1 1ms flag
					; bit 6: set mode
					; bit 7: time invalid flag

.def	t_flags		=r17		; bit 0: old snooze state
					; bit 1: new snooze
					; bit 2: alarm
					; bit 3: snoozing
					; bit 4: 12 hour flag
					; bit 5: minute flag
					; bit 6: second flag
					; bit 7: half flag
.def	LED_image	=r18
.def	set_detect	=r19
.def	set_mode	=r20
.def	buttons		=r21
.def	mux_time	=r22
.def	scratch		=r23
.def	acc		=r24
.def	acchi		=r25
; X (r26/r27) used only by multiplexer
; Y r28/r29
; Z r30/r31

After the register definition comes the RAM definition. There’s not much here.

	.DSEG
		.org		SRAM_START		; 0x0100

r_prefs:   		.byte		2		; options copy
r_snooze:  		.byte		1		; snooze timer copy
r_alarm: 		.byte		2		; alarm set time copy
cancel:    		.byte		1		; alarm cancel timer
alarm_frq: 		.byte		1		; current frequency
alarm_tb:  		.byte		1		; modulate timer

; debounce stack for set mode
k_debounce:		.byte		8

; Binary values to run through the display convertor
s_disp:    		.byte		1		; values for display
m_disp:    		.byte		1
h_disp:    		.byte		1

; Decoded bitfields for direct multiplexing, 16 bits per digit
m_sec:     		.byte		2		; mux unit sec
					.byte		2		; mux ten sec
m_min:     		.byte		2		; mux unit min
					.byte		2		; mux ten min
m_hrs:     		.byte		2		; mux unit hrs
					.byte		2		; mux ten hrs

.equ				stack		=RAMEND		; 0x02FF

		.ESEG
		.org		0
			.byte	4
e_prefs: 		.byte	2
e_alarm: 		.byte	2		; mm:hh
e_snooze:		.byte	1

Note the .DSEG switch, to tell the assembler we’re in the RAM address space, and the .ORG statement to set the address. SRAM_START is a predefined constant in the m48def.inc file, as is RAMEND. Notable here are the second, minute and hour display values s_disp, m_disp and h_disp, which are not always the same as the actual time during setting, for example. Below that is a group of six bytes which are the decoded anode and cathode bitfields used by the multiplexer. The multiplexer just clocks these bytes out in turn, and doesn’t have to recalculate them every time.

Lower down I define some space in EEPROM using the .ESEG directive. Here are a few setup semi-constants – preferences, alarm time and snooze period – that can be changed but need to be retained permanently otherwise. These are mirrored in RAM for ease of access.

Next: I start into code section

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Build a Nixie Clock – 7 – the Code, continued

The code proper starts with a .CSEG statement to tell the assembler this is code, not data, with an origin (start address) of 0x0000. The first instruction is a jump to the beginning of code, followed by the interrupt vector table. All the interrupt vectors are here, together with the service routine labels, most of which just run to a single RETI instruction. Interrupt routines that are actually used are commented out of the list. These routines are provided elsewhere. Leaving them in the list, but commented, helps me keep track of what I’m using. It’s a habit I got into by about the tenth or twelfth time I reused this startup sequence.

At the “start” label, we begin by setting up constants and the stack, then turn off the watchdog timer (in case it’s on; it shouldn’t be). Next we set the clock prescaler to 1. This isn’t something you come across very frequently, but I’ll explain later. Amongst other things, this cancels the “Clock Div 8” fuse if it happens to be set, and cranks the CPU up to full speed. Next, the IO ports are set up. Note, we leave PORTD.5 as an input for now without pullup. This is the Timer 0 OCB pin that drives the high voltage FET switch. As long as it’s an input, it can’t turn the FET on. This is to avoid accidents. The ADC interrupt routine will change it to an output once everything else is ready. PORTC.1 is also set to input without pullup. This is the power fail detect pin; pulling it up internally to the AVR’s VCC would defeat its purpose.

Next some registers are set up, including initializing the time to midnight, and the flag bit sf_invalid is set. This bit makes the display flash to warn you that the time needs setting. Next, the timers, ADC and SPI are set up. They have subroutines, rather than inline code, because we need to set them up again after waking from power down. The multiplexer is set up – this is the only user of register pair XL:XH – and the display blanked. Then we copy the 12 hour mode flag and the alarm set time from EEPROM to RAM, where they’re easier to access. Finally we enable interrupts and enter the main loop. We will not go back through the preceding setup code again until either the power is off long enough for the voltage to drop to power-on reset level, or we get an external reset.

The very first thing we check in main_loop is PINC.1, which is hooked up to the main 5V supply. Normally this will be high. If the power goes off, it will be low, and we execute the jump to power_save. What happens there merits a bit of detailed explanation.

power_save:
		cli
		out		TCCR0B,zero		; kill counter 0/pwm
		out		TCCR0A,zero
		sts		TCCR1B,zero		; kill counter 1/ctc	
		sts		TIMSK1,zero		; kill timer 1 ints
		out		PORTB,zero		; port B pins low
		out		DDRC,zero		; port C float
		out		PORTC,zero
		out		PORTD,zero
		ldi		acc,(1<<PUD)
		out		MCUCR,acc		; disable pullups
		cbr		t_flags,tm_snooze	; cancel snooze
		sts		r_snooze,zero
		rcall		eas_off			; stop alarm
		sts		ADMUX,zero		; shut down ADC
		sts		ADCSRA,zero
		ldi		acc,(1<<PRTWI | 1<<PRSPI | 1<<PRADC)
		sts		PRR,acc			; power-off TWI SPI and ADC
		ldi		acc,(1<<ACD)
		out		ACSR,acc		; power-off comparator
		ldi		acc,0x01
		sts		TIMSK2,acc		; enable OVF2 only
; prescale system clock down to 64kHz
		ldi		acc,1<<CLKPCE		; change enable bit
		ldi		acchi,0x07
		sts		CLKPR,acc		; prescale change enable
		sts		CLKPR,acchi		; prescale 128
power_stay:
		sei
		ldi		acc,0b00000111		; select power-save mode
		out		SMCR,acc
		sleep

First we disable interrupts, then stop timers 0 and 1, then put all the ports in a state where they can’t drain power from the AVR. Those that remain outputs are driven low, and pullups are disabled on all inputs. If the alarm is sounding it’s cancelled, and if the clock is “snoozing” that’s cancelled too. The ADC is shut down and as many things as possible turned off in the Power Reduction Register, PRR. The Timer 2 compare match interrupt, which has been used to generate a half-second tick, is disabled, leaving only the Timer 2 overflow interrupt active. This will continue to go off once a second to keep time. Next, we prescale the main system clock by 128 to slow down the AVR speed from 8MHz to about 62kHz. Finally we enable interrupts again – very important! – select power-save mode which leaves Timer 2 running, and go to sleep. At this point the AVR draws about 6 microamps, which will drain the supercap by one volt in about eight to ten hours.

The next thing that happens is we get an overflow interrupt from Timer 2. The CPU wakes up, vectors to the Timer 2 overflow ISR and counts one second. It does this very slowly, because we turned the clock down to 62kHz, but speed isn’t important here – power saving is. After the ISR we resume here:

		nop
		out		SMCR,zero		; clear SE bit
		cbr		t_flags,tm_tick
		sbic		PINC,1			; power back on?
		rjmp		power_back		; yes
; power still off
		sbrs		t_flags,tf_min		; minute flag set?
		rjmp		power_stay		; no
		cbr		t_flags,tm_min
; we can't actually sound the alarm, but we can trip it
		sbrc		pind_img,4		; alarm 1 enabled?
		rcall		check_alarm		; yes, compare alarm 1
		rjmp		power_stay		; go back to sleep

Something often overlooked when using Timer 2 with a low speed crystal is that its interrupt logic is clocked by the external crystal, not by the system clock. That means it takes a minimum of 32 microseconds after the initial interrupt before the flag clears. If we hurry through the ISR at full speed and go back to sleep, we may get woken again by the same interrupt, which not only wastes precious power but causes the clock to run fast during sleep. There’s a procedure in the Mega48 manual for avoiding this, by writing a value to one of the timer registers and waiting for it to finish updating. You’ll find that procedure commented out in the main code. We don't need it because with a system clock speed of 62kHz, the Timer 2 logic is certain to finish its job long before we get out of the ISR. I don’t know how much power we save by cutting the clock speed, because I’ve never been able to measure it accurately without resetting the AVR, but I can tell you that at full speed a current meter “kicks” once a second, and at low speed it doesn’t. Besides, it stands to reason that doing the minimum number of instructions necessary at low speed is more efficient than hurrying through and sitting in a loop at 8MHz uselessly waiting for a flag to clear. Prescaling the clock by 128 is slowing it much more than necessary and if I had the means to measure the current accurately I could probably find an optimum. I leave this as an exercise for the reader. Not all AVRs have a clock prescaler. If you use one that doesn’t have it, you’ll need the commented-out section of code.

The wake-up routine checks to see if the power’s back up and if so, jumps to power_back to restore full-speed functioning. Otherwise, once a minute, it checks the alarm and then goes back to sleep. If your alarm is set for 7:00 and you get a brief power-out from 6:58 to 7:01, you’ll appreciate it if the alarm goes off when the power comes back on. To do this check we need to know if the alarm switch is turned on, but in sleep we can’t read the switches without enabling the ports and wasting power, so we check against an image of the switches (pind_img) that we took last time we ran the main loop with power on.

The power_back section cranks the system clock back up to full speed, resets the ports the way they should be, restarts the timers, ADC, SPI and anything else that needs doing, and then after the next 1 second interrupt restarts the multiplexer and returns to normal operation.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I too am building a nixie clock, i'll probadly use german z560 or z573
http://daqq.ic.cz/nixie_clock1.html

I was thinking (and even done) of a power supply where I would use a 230V/6V transformer (the box on the picture) and switch 6V into the secondary winding. I found out that this is a realy bad way of doing it. Would you mind if I used your HV power supply for it?

BTW: There is a lot of nixies here in Slovakia, my teacher has 600 pieces of Z560 (the old tesla company left them and they have been lieing there ever since)

Thank you, daqq

There are pointy haired bald people.
Time flies when you have a bad prescaler selected.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

daqq wrote:
Would you mind if I used your HV power supply for it?

Of course I don't mind! Use any part of thos project you like - that's why I'm posting it here. Good luck with your clock.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Congratulations [peret], an excellent tutorial and very well written. I haven't designed with Nixie tubes for some years (yes I am that old!) but looking at all those devices on eBay sure makes it tempting. I have been playing with an atmega48 creating a CRT clock and that has been fun but is far from finished. I have got a couple of the Russian 6LO1i CRT's which are rather nice and small for the application.

Thanks for all your effort, it is also nice to see it so well appreciated.

John

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi,
I am going to be making some nixie clocks soon and I have a few questions.
Is this circuit able to fade the digits like the one on this page http://www.webx.dk/oz2cpu/clock/... ?
also, I will be using 74141's, will it be hard to adapt this circuit to use these?
I have had some experience using a atmega8 but dont really know how to design circuits.
Thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Is this circuit able to fade the digits like the one on this page http://www.webx.dk/oz2cpu/clock/... ?

There's nothing difficult about doing a cross-fade. Basically you construct a sub-multiplexer with two states and (say) 16 stages. To fade a '0' into a '1' you start with '0' in the first state and '1' in the second, then start with all 16 stages as '0' and none as '1' and run through all 16 stages at hugh speed for some time period. Then set 15 stages as '0' and one as '1' and run through for some time period; then 14 as '0' and 2 as '1' for some period; and so on, until you end up with zero stages as '0' and all 16 as '1'. The '0' will appear to dim down and go out, and the '1' to brighten up. You'd want the process complete in about 0.5 seconds, say 512ms for round figures, then each of 16 fade steps takes 32ms, so you could run through the 16 stages of each step twice at a rate of 1ms per multiplex operation. It seems for me it's a lot harder to describe it than to do it.
Quote:
I will be using 74141's, will it be hard to adapt this circuit to use these?

I presume this is because you've already got some? The problem is driving the 74141s. If you don't multiplex, you need 4 port pins per digit, total 24 for a 6 digit clock. That's way too many for a Mega8 or Mega48. If you do multiplex, you need 4 port pins plus one per digit, total 10 for a 6 digit clock (or 8+3, 13, for a 3x2 multiplex system). You could possibly save port pins by driving the 141(s) and/or mux transistors with a shift register and latch, effectively making a HV5812 the hard way with lots of parts. There's another issue with 74141s - their output is only rated for about 80 volts so there may be problems if you blank all the digits, when the outputs will rise up towards the anode voltage. You may need to connect all the cathodes through 1 meg resistors to some intermediate voltage, 75V or so, for reliable blanking.

Maybe there's some discussion of the design philosophy on these other nixie clock sites? Everyone has particular reasons for doing things the way they do. My design philosophy was minimum amount of wiring, minimum overall cost, and using only parts currently available from distributors. Even if I had some 74141s, I would probably still have used the HV5812 for the last reason.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for your reply, I will probably now just follow your circuit exactly to avoid complications.
I've been looking for some of the parts for your circuit and can't seem to find the inductor (TE2058).
I am from New Zealand and some parts are hard to find so will probably just import them all from a usa online store, do you know any that carry most of the parts I will need?
Also, are the resistors used just regular 1/4watt ones?
Sorry for all the questions.
Thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
I've been looking for some of the parts for your circuit and can't seem to find the inductor (TE2058).
I am from New Zealand and some parts are hard to find so will probably just import them all from a usa online store, do you know any that carry most of the parts I will need?

You should be able to find everything between Digi-Key and Mouser. Mouser has the HV5812 and Digikey has the AVR and the inductor. Everything else comes from either. You can compare prices between them and save a little, but note Digikey's small order surcharge will probably make it cheaper to give them most of the order.

The HV5812 comes in three packages - 28 pin 0.6" wide DIP, 28 pin 0.3" wide surface mount SO-28, and 28 pin square J-lead, your choice. The chips in my photos are the square J-lead package, which is quite compact and for which you can get a socket. (Memo to self: post a diagram of the pinout for this socket).

For the inductor, you'll find the TE2058 listed as an Alfa-Mag part - that's the Digikey stock number. As an alternative, I've also used the Coilcraft DO3316P-224, which is smaller. It's a surface mount part but not hard to solder to a couple of wires on a breadboard. You have a local distributor for Coilcraft, but they're generous with samples so you may get one free if you ask. The TE2058 is also a surface mount part but it's easy to unhook the wire ends from the base and thread them through holes, or else the TE2103 is the same thing designed for through-hole.

Quarter watt resistors are fine, everywhere. Be sure and use a UF4007 (ultra fast) diode for the HV rectifier, as a standard IN4007 will be very inefficient.

What tubes are you planning to use? Different tubes take different amounts of current. Let me know what you have and I'll work out the tweaks for high voltage and anode resistors.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here is a TOP VIEW of the PLCC-28 socket, for the J-lead version of the HV5812. The pins are on a 0.1" grid for easy prototyping but note that they don't come out in the order you intuitively think they should.

Again, this is a TOP VIEW. For wiring up from underneath, draw yourself a mirror image, or risk being horribly confused.

Also, once the chip goes in this socket it's darn near impossible to get it out again without a special tool. For this reason, the socket has a hole in the bottom. Drill a matching hole through your board, before you wire it up, so that you can push the chip out from underneath if you need to.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I should have mentioned that you can also use the Maxim MAX6921 in place of the HV5812 - it's practically identical with the same pinout. I don't know where to get it, though. It's not listed at Digikey. Also, it doesn't come in 28 pin DIP, only in SO28 and PLCC.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi
The tubes I have are in-12s
For the inductor would this one work? http://www.mouser.com/search/Pro... (data sheet - http://www.pulseeng.com/products... )
I found this one by searching the DO3316P-224 on Mouser. I would prefer to get everything from mouser as I can get the avr's somewhere else for alot cheaper.
Would the atmega48 be able to handle a temperature sensor as well if I wanted to add one later?
Also, would a programmer like this http://cgi.ebay.com/ATMEL-AVR-IS...
be suitable for programming this circuit?
Thanks Again for all your help.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That Pulse Engineering inductor should work fine. It surprises me how inductors from different companies look so similar ... I suspect they are, in fact, the same, made in the same factory, just with a different name on the packet.

For IN-12 you should use 22k anode resistors and 180V.

For a temperature sensor, I'd use something like a TMP100 ($2.13 from Mouser) as an I2C device on PC4/PC5. In my schematic PC4 is used as an LED driver and PC5 is a 1Hz test point, but both can easily be moved to spare pins. The TMP100 delivers a 12-bit temperature directly in sixteenth-degrees C, so 25.5 degrees C comes in as 0x198. I might add a little code to the project to include that function.

I'd ask in the general AVR forum about that programmer. I've never used one but many other people will have, and will give you a fair opinion.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Peret

Thank you verry much for this brilliant article!

I recently built a dekatron clock and had a problem
with the hv coil, the cory wasn't powerfull enough.
Altough everything worked it drew 1.8Amps and the poor
fet got so hot you could get burned if touching too long (in fact i got burned,...).
Then I took a slightly bigger core and made another coil.
Altough both had 1miliHenry the circuit just drew 100mA and
the fet stayed cold.

Cheers
Michael

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am also working on a nixie clock. if using an external 60hz pulse (mains freq) would it be possible to use AVRGCC instead of ASM? It seems to me, the way you do things the only section of code that requires the code to be in assembly for a tightly timed loop is the HV section.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You could use GCC whether you use the 60Hz or the crystal - it's a matter of personal choice, and what you're comfortable with. If you do it in GCC, why not post your code?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sure. I will post my code when I am done, It might be a while though :P. I was more concerned with the ability to have very tightly timed loops with assembly that I would not be able to reproduce with C. That and I only know assembly for the 6502 processor. By the way, Is there any thing I need to know about IN-8 tubes?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There are no tightly timed loops in my code, really. The voltage regulator is an interrupt routine and although I took care to keep it short, the ADC conversion that triggers it takes 100 times longer than the code. The 1 sec timing interrupt isn't critical either, as long as you don't miss one. What does become noticeable is if the multiplex rate varies, which shows up as digits flickering. To avoid this you absolutely positively must not miss a 2 millisec timing slot. In a simple design like mine there's nothing that could take long enough, but if you have (for example) an I2C clock chip, reading the clock by I2C can delay things by a millisec and believe it or not, the eye will notice the flicker caused by a single 1ms change in the mux rate.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
By the way, Is there any thing I need to know about IN-8 tubes?
Not much really. Except that the 5 is made with an upside down 2. The IN8-2 has a decent 5 ;)

My Nixiepages are most in Dutch, but you may find something interesting there: http://www.aplomb.nl/TechStuff/NixNies/NixNies.html
There are three pages, but to switch pages, you have to go back to the top of a page .... sorry for that

Nard

A GIF is worth a thousend words   She is called Rosa, lives at Mint17.3 https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Plons wrote:
Except that the 5 is made with an upside down 2. The IN8-2 has a decent 5 ;)

Nope either its the other way around, or they both have good 5s. http://www.flickr.com/photos/mmm_linux/2210199391/ Sorry that its a cell phone pic. I was more wondering what resistor value I should use.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Tubes of that size generally specify 2 or 2.5mA typical average cathode current, but that will be rather bright. The minimum current is the value where the cathode flickers, or isn't lit over its whole area. For multiplexing 4 or 6 tubes you can use more current, up to about 10mA. You can use considerably less, for longer life, as long as the peak current is enough to light the cathodes properly. More current will just make them brighter. To work out a suitable resistor value, subtract the sustaining voltage (usually about 120V) from the supply voltage (usually about 170V), divide by the desired current in mA, and the result is the resistance in kilohms. EG for 5mA, (170-120)/5 = 50/5 = 10k.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ah, that's what I wanted to know. If I may ask, why do you use the difference between the supply from the sustain voltage?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mmmlinux wrote:
Plons wrote:
Except that the 5 is made with an upside down 2. The IN8-2 has a decent 5 ;)

Nope either its the other way around, or they both have good 5s. http://www.flickr.com/photos/mmm_linux/2210199391/ Sorry that its a cell phone pic. I was more wondering what resistor value I should use.
I apologize for the confusion: the IN14 has an upside-down 2 as 5. IN8 and IN8-2 are OK.

Nard

A GIF is worth a thousend words   She is called Rosa, lives at Mint17.3 https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
why do you use the difference between the supply from the sustain voltage?

A neon tube behaves something like a zener diode - in fact, they were used as voltage regulators in the days of tubes. Once it strikes, it maintains a relatively constant voltage across it (the "sustaining" voltage). So the voltage across the resistor is the difference between the supply voltage and the sustaining voltage, and it's this difference voltage that pushes the current through.

Here are the characteristics of the IN8. The translation leaves something to be desired. The line "from the supplier of pulse voltage ... 1mA" means the average multiplexed current should be 1mA, eg 6 multiplexed tubes get 6mA peak. I tried to attach an ancient Burroughs data sheet from the 1960s, but the server said it's too big. Maybe I can screen-capture a section out of it.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

peret wrote:
There are no tightly timed loops in my code, really.
...
What does become noticeable is if the multiplex rate varies, which shows up as digits flickering.
Well, so far, I have the HV regulation and multiplexing implemented entirely in C (GCC, WinAVR) on my prototype.


My Second Nixie Tube Clock Protoboard - on Flickr

Don

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are those IN-8-2 tubes? If not what are you using for sockets?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mmmlinux wrote:
Are those IN-8-2 tubes? If not what are you using for sockets?
Yes, those are IN-8-2 tubes - soldered directly to PCB but with a slight space between the PCB and the bottom of the tube.

I'd be very interested if someone has come up with a good scheme for mounting IN-8 nixie tubes on a PCB.

Don

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Don, I use the IN8-2 too. Soldering them on the PCB is not so much the problem, but to put all straight ;) (see picture)

I modified the nose of a paint-heatgun, and managed to put the tube straight: http://www.aplomb.nl/TechStuff/NixNies/Nixnies2.html

Nard

PS There is a problem with uploading attachments ....
The Pisatube is can be found here, about halfway down the loooong page: http://www.aplomb.nl/TechStuff/NixNies/NixNies.html

Edit: upload seems to be OK again .... so let's give it a try

Attachment(s): 

A GIF is worth a thousend words   She is called Rosa, lives at Mint17.3 https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

Last Edited: Tue. Jan 29, 2008 - 05:37 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

http://www.electricstuff.co.uk/o...

Everything you wanted to know about discharge tubes, and were not afraid to ask, but never got an answer.

There are pointy haired bald people.
Time flies when you have a bad prescaler selected.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am now one step away from my clock, But i hit a snag with my 74141 chips. If I pull all the data pins low witch should make the 0 pin active. It still lets the other cathodes light. Maybe I am missing something. For testing I have all the data pins wired to ground, and the +5 voltage applied. But if I take attach the cathode wire from one of the digits of the Nixie to the outputs. All of the outputs cause the Nixie to light, how ever all the wrong output pins are dimmer (then the one that is selected.) Any one have any ideas what I am doing wrong?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What is the anode-supply-voltage ? If more than 185 ... 190V, then it's too much for the 74141

A GIF is worth a thousend words   She is called Rosa, lives at Mint17.3 https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
But if I take attach the cathode wire from one of the digits of the Nixie to the outputs. All of the outputs cause the Nixie to light

The answer lies in these words above. The 74141 can only hold off about 80V. With only one cathode connected, the voltage across the tube will be enough to break down the 74141 and light it up even on the "off" outputs. If ALL the cathodes were connected though, the one which is selected would strike first and pull down the voltage (by the anode resistor) enough that there isn't enough voltage on the other cathodes to break down the 74141. Note, though, that you will never be able to blank a whole digit.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Don wrote:
I'd be very interested if someone has come up with a good scheme for mounting IN-8 nixie tubes on a PCB.

Unfortunately, the Mil-Max sockets to fit those pins are too wide externally - a ring of them touch each other. I presume there's some kind of molded tube socket, but they probably cost more than the tubes.

On the subject of sockets, there's a widely available Russian socket for the IN12 oval end-view tube which looks as if it should fit the American B5991/NL8422 tubes. It does not. The pin circle is microscopically too large. You can work the B5991 in with a bit of effort, but after a brief pause (long enough to lull you into a false sense of security) the base of the tube cracks under the strain. I have a whole row of casualties to prove it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Plons wrote:
What is the anode-supply-voltage ? If more than 185 ... 190V, then it's too much for the 74141

Un-fortionally I don't have the power supply in front of me. If I remember correctly its ~~175V.
peret wrote:
Quote:
But if I take attach the cathode wire from one of the digits of the Nixie to the outputs. All of the outputs cause the Nixie to light

The answer lies in these words above. The 74141 can only hold off about 80V. With only one cathode connected, the voltage across the tube will be enough to break down the 74141 and light it up even on the "off" outputs. If ALL the cathodes were connected though, the one which is selected would strike first and pull down the voltage (by the anode resistor) enough that there isn't enough voltage on the other cathodes to break down the 74141. Note, though, that you will never be able to blank a whole digit.
So, the 74141s only work if I actually connect all of the cathodes? not just the one.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mmmlinux, I think you really need to measure the high voltage. Guessing will not bring you closer to good results.
If it's 175V (not on the anode of the nixie, but as supplyvoltage for the nixie), then you should be fine. I found that my 74141's started to turn all segments on @ 190~~195V.

Quote:
So, the 74141s only work if I actually connect all of the cathodes? not just the one.
I never tried that ....

What resistor-value do you use for the anode ?

Nard

A GIF is worth a thousend words   She is called Rosa, lives at Mint17.3 https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I believe it will be ok if you connect all the cathodes - let me put that another way - I believe the "off" cathodes will not light as long as at least one cathode is near ground potential. I don't know the exact physics of a nixie but I know that as long as there's an anode resistor and at least one cathode is struck, the anode voltage will be pulled down to the sustaining voltage, so the total supply voltage is immaterial.

One thing I do know about nixie physics is that almost all the voltage is dropped across a microscopically thin dark layer at the cathode surface, under the glow. If you could somehow probe the glow and measure its potential, it would be close to the anode voltage, not to ground. Electrons are accelerated up the steep potential gradient of the dark space and the glow happens when they collide with neutral neon atoms at the top.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Peret,

Congratulations on an excellent thread!

The HV5812 appears just the ticket for my nixie clock for which I'm aiming at lowest part count so the serial interface is the way to go.
However, the part count on the anode drive circuit is bugging me so I'm looking for an alternative:-

I was considering using a bleed resistor connected from the anode resistor via a transitor to ground. Turning on this transistor would pull the anode voltage down below striking/ voltage and thus blank the display.
So the component count is reduced but at the expense of increased current (blanked tubes would would still draw current thorugh the bleed resistor)

Any thoughts on why this might not work?

Jonathan

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Any thoughts on why this might not work?

Well, let's run some numbers. If the anode resistors are 33k and the voltage is 170V ... and let's suppose you don't pull the anodes to ground, but to half supply with another 33k resistor (see drawing) ... Then to blank a tube you will be pulling 2.6mA out of the high voltage supply, To blank five tubes takes 13mA. That is a dissipation of 2.2W, which would require a much bigger voltage converter and make the whole thing run uncomfortably hot. And 33k resistors will only do for the smallest tubes - if you use larger tubes they'll need smaller resistors for more current, which increases the losses proportionally.

So yes, it would work; but is it a good way to do it? I don't think so. You're trading six cheap transistors for a lot more cost and complication in the voltage step-up circuit - which, I should point out, is already the most stressed part of the system, and the usual failure point - and more heat than you really want to deal with in a closed box that runs 24/7. Those six PNPs buy you a lot of reliability.

Attachment(s): 

Pages