Switching PWM with photomos AQV212


Senior Member
Following on from Westaust55's thread;
"LED display for compass heading" http://www.picaxeforum.co.uk/showthread.php?t=9904
Have been investigating ways to effectively double the outputs of an I/O expander.

To recap, Westy came up with a nifty scheme to indicate 32 positions from 16 by showing combinations of 1 or 2 LEDs.

I would prefer to use 32 LEDs but don't want to install another I/O expander.

As the compass display will only ever light 1 LED at a time, I figured that if the 32 LEDS were split into 2 banks, then the supply could be switched from one bank to the other and utilise the same 16 I/O pins to achieve the 32 outputs.

As the LEDs are supplied with a PWM output rail (which is common to other displays and used to dim the LEDS) the I?O expander sinks current.

The PWM is provided to the loads via a P-Channel MosFet driven by the PICAXE pwm output.

Have only a single output available to control this switching.

So have some options to provide this switch;
1. a couple of transistors - not sure which or how to set up
2. a N-channel/P-Channel enhanced MOSFET pair - IRF7338PbF around NZ$3
3. DIL PCB relay - coil current issues
3. Photomos relay.

Have figured the photomos is probably simplest as it is very compact, next to no current required from the PICAXE port and the Panasonic AQV212 is configured equivalent to a single pole changeover relay in a 6pin DIP.
This will cost some NZ$9.00 however.

Any comments / alternatives / options appreciated.
Last edited:


Well, give it a go.
I'm not 100% with what you're trying to do - a rough schematic would be nice - but I'm sure you could achieve what you want with a couple of logic level MOSFETs or even Bipolars.
If you're just using normal LEDs and a decoder/demultiplexor I can't see what the problem is . Arn't you just toggling the supply? - therefore I assume I've missed something :(


Senior Member
Yes, just switching a PWM supply rail from one bank to another and back.
Seeking advice on the simplest setup to use.


Well, I'm still not 100% on the understanding front but would a variation of this suffice?
'Simpler' would be a single IC to me but 'simpler' may also mean what can be found in the back of the drawer.
Anyway, it's unchecked and just a suggestion... logic level stuff of course and values just a guess.
MOSFETs could be replaced by PNPs.



Senior Member
I hatye to bring up this topic, but, if you are driving 32 LEDs - one at a time - then charlieplexing is definitely the way to go.

Use one of the LEd driver chips, will be simpler, cheaper and use less board space.

Of course it isn't as much fun.


a member of the refusing to re-invent the wheel society



Senior Member
Sorry - been away - night time in NZ!

To recap,
Am looking to effectively reproduce a Form C relay - i.e. one pole changeover.

The AVQ212 is actually a Form A even though it has 2 MOS switches.
The best local price (RS) that I have found so far for a Form A plus Form B is close to NZ$40.

How would one charlieplex 32 LEDs off a single output port when the supply is a PWM supply - just can't figure it. If I used a fancy LED Driver chip I may just as well use the MCP23017s I'm already using (@US$1.20 ea).

At present the circuit uses an MCP23017 16 port I/O expander to drive the 16 LEDs. Could easily put in another to handle an additional 16 LEDs.

Thought it might be better/more cunning to switch the supply and save on the extra I/O expander.
However all the options looked at so far will cost more than another MCP23017 and add additional complications so will either leave the system the way it is or add another MCP23017.

Thanks to all who have provided input.


Senior Member
There is more than one way to re-invent the wheel.

Here is a cost effective way to expand an 08M picaxe to control 1 of 32 (or more) LEDs using two output pins, for example to display a compass heading. If a PWM signal is available then the brightness of the display can also be controlled with a third pin.

The circuit uses U1 and U2, which are two 74HC595 chips (0.60AUD each) to control the 32 LED matrix and provide 3 auxilary outputs to replace the 3 picaxe pins used to control this circuit. The maximum current for the active LED is a modest 30ma set by the four 100 ohm resistors. Turning on more than one LED, while not fatal, is not recommended.

The picaxe software sets up a 16 bit data word to be shifted into U1 and U2, MSB first. The least signicant byte contains the 1 of 8 active high anode column bits, the most significant byte has the 1 of 4 active low cathode row bits next, followed by 3 auxillary output bits and the MSB, bit 16, which is always set high.

The serial register of U1 and U2 are first cleared by pulsing the normally high CLOCK pin low for 2ms.

After that the 16 data bits are shifted into the DATA pin by pulsing the CLOCK pin low for 100us sixteen times. After the 16th 100us clock pulse, the leading always high MSB data bit arrives at the serial Qh' output pin of U2 and this automatically loads the 16 data bits into the output registers.

The eight output pins of U1, which control the columns of the LED matrix, are modulated by the PWM brightness signal with maximum average output current when the BRIGHTNESS signal is minimum duty cycle (mostly low).

The four outputs pins of U2 controlling the 4 rows of the LED matrix and the 3 auxilary outputs (and Qh always high) are not affected by the PWM signal.

All outputs of U1 and U2 are automatically reset on powerup.