Best way to handle 3-4 PWM outputs on PICAXE

#1
So, I want to control 3 or 4 (I'm thinking of supporting 4, but need 3) 4-pin fans (like new CPU fans), and I find that the 28X and 40X only have 2 actual separate PWM outputs! Oh no! But, I've been itching to pick up a PICAXE to play with for awhile, but have not had a good enough excuse...until now!

The idea:

1x knob, 1x SPST momentary button (to handle a simple menu system), 1xLCD display (probably a 20x4 from phanderson), 1x 28X or 40X PICAXE. Must input 3-4 tach signals (knowing approximate RPMs, I should be able to get them recorded right, even if things get weird), output 3-4 PWM signals at 25kHz, must read the knob (probably just a pot) and button. The software in general I have ideas of how to do in my head. Setting up interrupts from input pins should make it even easier to handle, though I'm sure there will be some challenges.

I can test with a single fan and get the general kinks out, but working with several independently that I'm not sure on.

So, I was looking at ways to handle this, and I thought of two possibilities:

1. Some IC that can be set to output multiple PWM signals at 25kHz. I can handle a soldering iron OK, but am otherwise a total n00b. This idea would likely be simpler, but is scary to my n00bish mind :). Simpler to wire up, and cheaper. What might such an chip be?

2. Using multiple 08M (continuous PWM outputs) units attached to a 28X or 40X, using serial outs to each 08M.

#2 would seem to me (recall, n00b here) to be easier, as it should be easier to debug. I could have a 28X or 40X starter or proto kit and 08 one to play with, then simply connect the final one to a small PCB with DIP sockets for the 08M units. The 28X or 40X would do the main bits of controlling, and deal with a display.

But, the manual isn't quite clear here...can the 28X and 40X use serial output on any output pins? Nowhere is it said it can't, and the command reference makes it seem that way, but there's a clear set of serial connection pins, too. Also, I'm not really sure how to deal with possible clock differences, if that would be a likely problem (with 28/40 devices, I could probably parallel them to the same resonator, right?).

I'm not necessarily sure that, if an IC that's easy to interface with could be found, that it wouldn't be an easier way to go...both ways seem to have their challenges.

Advice?
 

hippy

Technical Support
Staff member
#2
SEROUT can be used on any output pin and SERIN on any input pin ( excluding PORTC pins for those PICAXE's which ahve that port ). There are also the two, somehwat confusingly named, 'Serial In' and 'Serial Out' pins which are used solely for downloading ( although SERTXD can use the Serial Out pin to send data back up the downlaod cable ).

The controlling PICAXE can control its own PWMOUT, so three additional 08M's would give you control over four fans and you could connect via serial; a single output can fan-out to each of the three chips.

The 14M has two PWMOUT's so, if the program fits, you could use just two 14M's to control four fans. That would be a fairly cheap solution.
 
#3
The 14M has two PWMOUT's so, if the program fits, you could use just two 14M's to control four fans. That would be a fairly cheap solution.
The 14M has 2 PWMOUT's? I could only find 1 reading through the manuals (manual 1, appendix C, and manual 2's description of pwmout). It can do hpwm but as far as I can tell, it can't drive independent pwm on 2 pins simultaneously. I'd love to hear otherwise :)
 
#6
Well, that's all nice to read. Looks it may be much simpler than I thought in terms of wiring them all together, and possibly testing them with initial skeleton programs.

The controlling PICAXE can control its own PWMOUT, so three additional 08M's would give you control over four fans and you could connect via serial; a single output can fan-out to each of the three chips.
How so? Set them all up to the same pin, in parallel, and use part of the data sent over it to tell which one is the proper one to address?
 

hippy

Technical Support
Staff member
#7
How so? Set them all up to the same pin, in parallel, and use part of the data sent over it to tell which one is the proper one to address?
The easiest way would be for the master to send out four bytes of PWM value, and have all slaves read those four bytes. Each would be programmed differently ( or read input pins to determine which it was ) and only use the byte which was directed at it.
 
#8
I'm just questioning the 25KHz. Does it really need to be so high? Afterall we're talking fans.

If it could be a lot lower, then I'd say a single picaxe could be used to output all PWM signals using 'bit banging'. i.e you generate the outputs in code.

You'd just have a for-next loop 0 to 255. At the start of the loop set all outputs high. Each output would have a duty value in the range 0 to 255. In the loop check all these values and if any have been reached set the corresponding output low. Then repeat the for-next loop. Add in feedback from tacho.
 
#9
Also, what sort of resolution of control is required. Taking Jeremy's solution further, use a lower number than 255. For fans, a value of say 16 might well be good enough and could be 'clocked' through very quickly.
 

premelec

Senior Member
#11
My preferance has been to use a serially set digital to analog converter -[12 channel from analog.com or 8 channel from ti.com] - however al-williams.com has a co-processor 8 channel pwm unit the "PAK V" unit. It's a bit expensive and draws a fair amount of power but should do the job fine...
 
#13
Note that the fan is not required to take the PWM input and pass it along to the motor
Well I don't understand this - doesn't the PWM signal directly drive the motor ? or is there more electronics in the unit that receives the PWM signal and then drives the motor ?

I wonder - is the 25KHz deliberately at the extreme of hearing to make it quieter? I'm not any expert on this stuff, but I bet, apart from this, you could drive a fan ok at 20Hz (I'm sure I'll now be told why not ....).
 
#14
According to the .pdf, the PWM is required as an RPM demand signal and is NOT used to directly the motor. It is also quite clear about the frequency requirements. So, this is not a question about how to drive a fan motor with PWM but how to generate a PWM signal that meets the requirements of the fan motor controller.
Taking that into consideration, IMHO code generation is not the way to go and multiple PICAXE solution with background PWMout is the best option.
 

hippy

Technical Support
Staff member
#15
Some two-wire 12V PC chassis fans also contain electronics so cannot easily be driven by directly PWM'd on-off pulses, but need that RC integrated to give a varying voltage.
 
#16
(snip answered bits)
I wonder - is the 25KHz deliberately at the extreme of hearing to make it quieter? I'm not any expert on this stuff, but I bet, apart from this, you could drive a fan ok at 20Hz (I'm sure I'll now be told why not ....).
Likely it is that high for that reason, so that a fan's electronics could easily pass it over to amp then buffer (just one transistor would probably do) if the fan is running OK (since keeping it from stalling is part of the fan's functionality), without noise. Using PWM at least up to 1kHz can cause audible humming/growling, especially at low duty cycles. Some fans are worse than others, but it seems that the best quiet fans have a greater tendency to make such noises from normal PWM control.

The key reason for not driving the fan with the signal, I imagine, is so that RPM monitoring can be done with relative ease. While linear regulation still makes for easier RPM reading, it's not foolproof, and may, depending on fan and sensor, not read properly [at low voltages].

P.S. (not worth adding a reply, but I guess will help paint a full picture) I've already previously looked into a PICAXE and then some up/down DCPs. This new 4-pin design fixes prior annoyances (lack of full range with linear, less of the lower-RPM range with linear than RPM, PWM noise, PWM and low-voltage RPM reading problems), and the fans currently out offer a wide range of operating duty cycles, being generally equivalent to having a 3.5v or so to 12v range, with no drawbacks. I've had just enough experience trying to get the lowest performance possible to gratefully welcome this new stuff (the clear temperature sensitivity when trying to answer "will it stall at this voltage, which I can't get decent RPM readings at?" was kind of a last straw with good old linear regulation).

But, the only large scale commercial controller using these fans, Zalman's ZM-MFC-2, offers only 1 of these outputs, with the power reading being the only truly redeeming feature.

On further reading, as well, I think 2x40X1 may be the best way to go. 4 PWMs, and plenty of other I/O. Given I need one to regularly be polling for pot movement and button pressing, commands like count sort of force extra units. Multiple 08M can work, and even 2x28X1, but a 40X1 is cheap enough, and allows all non-user (me) inputs and outputs to go on the 'worker' unit, with only the PWM outs shared, and a simple single serial connection between the two chips. I might be able cut it down a bit with more knowledge of how to interface these kinds of things, but that's a chicken and egg problem, right now.
 
Last edited:
Top