# Using microcontroller as oscillator for high voltage power suppy?

MightyOhm has designed a geiger counter which is here. I am not very clear but I think he is using the 555 timer as an oscillator in the high voltage power supply section. I've attached his schematic below.

My question is can the design be changed to use an output from the micro-controller to generate an oscillating signal instead of the 555. The first question is that would such a design work? If it works, is there a particular reason why a 555 timer is used in the design?

Read what the others said :-).

The original circuit diagram is here

This is the 555 based high voltage power supply section:

The HV via diode D1 is fed to the Geiger Muller tube to the right of this diagram.

There are 3 aspects of this circuit which a MC (microcontroller) would need to emulate to replicate it (as opposed to doing it differently).

• An output high level on pin 3 starts a delay whose on-time is controlled by charging C3 using R6, D2, C3, and whose off-time is controlled by the decay of the voltage on C3 which is timed by R9 and C3. This delay could be completely replaced by software.

• L1 is turned on by a high on 555_OUT turning on Q1. An MC would still need Q1.

• Q1 remains on until the current through R8 + VR1 turns on Q3 thus ending the cycle. This sensing still needs to be done either by still using R8, Vr1, R1 & Q3 or by using an onboard comparator with level set either on chip or with a 2 resistor divider.

SO replacing the 555 based supply with a MC based design directly would eliminate very little of the hardware.

The 555 design "just works" whereas a MC based design needs to be failsafe against software crash. eg if Q1 is turned on an left on L1 may be destroyed.

A MC based design could do this more simply and probably just as well. Adjusting on time based on L1 current is not needed if Vcc is well controlled or can be varied open loop if Vcc varies widely and is known. Then -

• ALL that is needed to make HC is a microcontroller plus R5, Q1, L1, D1. C1.

Pulse Q1 on via R5 with some duty cycle and "HV appears". Adding a 2 resistor divider from HV would allow the MC to monitor and even control HV. The top resistor in the divider which drops most of the HV must be rated to max Vout. eg

Diagram may appear familiar :-). HV regulation could be eg 2 x resistors with onboard comparator or 2 x resistors to drive a resistor and a digital input pin or an HV zener and a resistor etc. OR eg a neon or HV zener could be used as a "constant voltage" load with maximum energy being designed to be within their dissipation capability.

Once HV is available, here is their complete Geiger Counter proper:

HV is applied at left. When the GM tube is ionised by a radioactive event (nature depends on tube used) a pulse of current turns Q2 on and produces an output pulse at GM_pulse. In the existing circuit this is the sole connection between the actual Geiger Counter (as described above) and the MC. The MC is effectively an "intelligent meter". There are enough spare pins to allow the above change to be made without excessive effort but it changes the whole nature of the MC program from that of a pulse processor to a real time controller (albeit a simple one).

• @endolith Indeedle - thanks. I found a few more typos while correcting it. 6.5 years ago. Wow. And 1 upvote, for what should be quite a useful answer to a number of people. That's life :-). – Russell McMahon Feb 9 '18 at 9:17

Analog purists may scoff at you if you want to do this with a microcontroller, but then a 555 may be beneath them as well :-). Yet a microcontroller may be a good choice for an oscillator application.

First, your circuit can be Damn Small™. A PIC10F200 requires zero external components and is even available in a 2mm x 3mm DFN package if you want.
It's still a few cents more expensive than an LM555, but the price difference gets ever smaller; prices for the LM555 aren't lowering anymore, while those for small microcontrollers are.

The PIC10F200 has an accurate internal oscillator, which will give a much more predictable signal (frequency and duty cycle) than you'll get with standard precision chicken feed around the LM555.

And of course, if you're already using a microcontroller with a spare I/O pin you get the oscillator virtually for free, possibly even with crystal precision timing.

Only possible drawbacks:
- you have to provide a programming interface on your board, or program it before assembly,
- an LM555 can work at higher supply voltages than a microcontroller; up to 16V vs 3.3V or 5V for a $\mu$C. This doesn't seem to be an issue here since the circuit works on 2 AAA batteries.

This 555 circuit looks like it is having some over-current protection (using Q3). With a μC it may be difficult to respond to this over-current event fast enough to save the transistor from damaging itself.

In general 555 timers also have the nice property of working at higher voltages which simplifies MOSFET (and BJT) driving in > 12V circuits. But since (I guess that) everything is 5V here there is no use in that.

• Some micros also operate a higher voltages. (e.g. ww1.microchip.com/downloads/en/DeviceDoc/41294a.pdf) – kenny Aug 20 '11 at 10:35
• @Kenny - Hadn't heard of those - Thanks for the link! However, you linked to one of those two-page sales brochures, which I abhor. One reason is that the brochure doesn't even mention what "High Voltage VDD Support" means. The datasheet is here: ww1.microchip.com/downloads/en/DeviceDoc/41396A.pdf, which indicates that they have an internal shunt regulator that allows them to work at up to 12V (and run logic at this level) when protected by a current limiting resistor. Neat! – Kevin Vermeer Aug 20 '11 at 15:09

Q3 resets the 555 when the voltage over R8 + UR1 ~ 20Ω rises above ca 0.7V, which corresponds to a current of 35mA through L1 and Q1.

The supply voltage seems to be a nominal 3V (2 AAA batteries), so for L1 = 10mH we get dI/dt = 3V / 10mH = 300A/s = 300 mA/ms. So to reach 35mA after being switched on Q1 remains on for a little more than 100µs.

So the microcontroller needs to generate pulses on the order of 100µs, which it can easily do. It just needs to drive Q1, the 555, Q3 and R8 + UR1 could be removed. But you have to make sure you don't turn on the output for too long, or you could possibly destroy L1 and Q1.

I would add some feedback from the high voltage via a voltage divider and an opamp to an A/D input of the microcontroller (this kind of feedback is missing in this circuit, so the high voltage is not regulated w.r.t. load).

I'm tempted to try it. :-)

Yes, you can emulate a 555 with a microcontroller, but why would you? Unless you already have a micro in the circuit with a free pin and CPU cycles. A 555 is cheaper and simpler and doesn't require programming.

• I remember seeing on a PIC processor that came with 555 emulation software. Oh and I would be so confident about the price difference check out the PIC10F200T-I/OT. – kenny Aug 20 '11 at 10:28
• I could think of many reasons why going for uC vs a 555 is a good idea when we're talking about Geiger counting. Anyone can get a 555 to spit out the right pulses, but you can't exactly slap on an LCD if still talking in 555 terms. You can't calibrate the thing either. Perhaps if making the power supply modular or putting distance between the HV and brains, then maybe a 555 makes sense, but uControl is quite succinct and elegant if you want more than just clicking. – Hoets Feb 8 '18 at 8:35

A microcontroller will do the job fine also, there are often many ways of doing something like this.

The 555 timer is cheaper than a uC as mentioned but in the above design, since a uC is involved anyway I think it would make sense to generate the necessary signal from it also, since it would result in a lower parts count and smaller overall footprint. The timing would be more accurate also as the uC is driven from a crystal (or it might be a resonator) although this is probably not an issue for the design.

I suspect he didn't have enough pins available (or maybe the timers were used already or no PWM peripheral on board - I haven't used the ATTiny so not sure) so the choice was easy. Maybe he had a pile of 555 timers needing to be used :-) With a larger uC (or perhaps altering the existing design and freeing a pin/peripheral), I'm sure it could do the job of the 555 timer also.

I've been thinking of Geiger counters for about a year now. Since I use PICs for other tasks, i could see using perhaps a 16F628A with a PWM. Then, trigger an opto transistor (just for the sake of isolation) to drive the inductor circuit above or a transformer + voltage doublers. If duty cycle is an issue, an adc could be used to change the duty cycle on the PWM. Lastly, the output of the geiger tube could be tied to whichever pin acts as a counter for TMR0 (or TMR1) while the other timer supplies the time base. Then, display the rate on an LCD or even store a certain number of values in the onboard EEPROM. I like the idea so much i think I'll build one. I got a SI-180G from Russia, last year and i hear it's a nice, sensitive tube.