PDA

View Full Version : 12V Fan and bs2



computer guy
01-24-2007, 07:51 PM
Hi

I want to control the speed of a 12V fan from the BS2.

Any ideas on what i can do. http://forums.parallax.com/images/smilies/confused.gif


Thanks.

allanlane5
01-24-2007, 10:05 PM
Use a transistor to switch the 12 volts on and off, using a control signal from the BS2. Put a reverse-biased diode across the fan, to absorb the switch-off transients. Then 'pulse' the fan control line -- 1 mSec on, 1 mSec off for a 50% speed setting.

computer guy
01-25-2007, 06:47 AM
What like this?

http://forums.parallax.com/attachment.php?attachmentid=45161

Chris Savage
01-25-2007, 06:53 AM
Try the attached schematic instead...There are a few·small issues·in the one you posted.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support

computer guy
01-25-2007, 07:00 AM
Thank you Chris, will do that. Just one question what value would R1 be or would that depend on what transistor i end up using.

Thanks

Chris Savage
01-25-2007, 07:44 AM
Hello,

Correct…R1 will depend somewhat on the transistor, but also on the voltage running the fan. At 12V I would use 470 ohms minimum and 1K nominal on a 2N2222 or 2N3904 transistor. I hope this helps. Take care.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support

computer guy
01-25-2007, 08:25 AM
How would i measure the temperature with the BS2.

Martin Hebel
01-25-2007, 08:32 AM
You may want to check out the Process Control text from Parallax. It covers PWM control of a fan and temperature monitoring and other things.

-Martin

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Martin Hebel
StampPlot - Graphical Data Acquisition and Control (http://www.stampplot.com/)
AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers (http://www.selmaware.com/appbee)·

computer guy
01-25-2007, 08:43 AM
Martin said...

You may want to check out the Process Control text from Parallax



What is that? Could you please post a link.

Martin Hebel
01-25-2007, 09:20 AM
Process Control Text:

www.parallax.com/detail.asp?product_id=122-28176 (http://www.parallax.com/detail.asp?product_id=122-28176)

-Martin

computer guy
01-25-2007, 02:48 PM
Is there a way i can do this without taking up that many i/o pins?

http://forums.parallax.com/attachment.php?attachmentid=45170

computer guy
01-26-2007, 11:06 AM
Bump

Not to be rude but this is urgent. http://forums.parallax.com/images/smilies/smile.gif

Martin Hebel
01-26-2007, 11:10 AM
Thanks for the Bump :)
You can tie the /CS line low, it SHOULD keep it running OK I think (can't remember if it NEEDs to be cycled once or not), the P8 is not necessary either, it simply allows the user to see when the threshold was crossed. So, 2 I/O, P14 and P15 or whichever you wish to use.

-Martin

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Martin Hebel
StampPlot - Graphical Data Acquisition and Control (http://www.stampplot.com/)
AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers (http://www.selmaware.com/appbee)·

computer guy
01-26-2007, 12:25 PM
What comes in pins 14 and 15? i am asuming it is a number (Word) in length.

So i would say:

temp VAR Word
in14/15 .....?

Or some thing like that.

Martin Hebel
01-26-2007, 12:33 PM
No, it is a byte of data that needs to be shifted in. There is a clock and data line. Take a look at the examples in the text.

SHIFTIN etc

-Martin

computer guy
01-26-2007, 01:09 PM
Ok thanks.

computer guy
01-27-2007, 07:00 AM
Can i use the LM335H or the LM35DZ temperature sensor instead of the LM34.

LM35DZ www.radioparts.com.au/ProdView.aspx?popup=1&Category=SX091616&Product=LM35DZ (http://www.radioparts.com.au/ProdView.aspx?popup=1&Category=SX091616&Product=LM35DZ)

Thanks

Post Edited (computer guy) : 1/27/2007 12:42:28 AM GMT

computer guy
01-27-2007, 09:43 AM
I like to bump http://forums.parallax.com/images/smilies/yeah.gif

As i said urgent.

Sorry need the fan controller part of my project urgently as my parts tend to overheat and the fans are really noisy at full power so i need to control them.


Thank you to everyone who has helped me so far.

Post Edited (computer guy) : 1/27/2007 1:47:19 AM GMT

Martin Hebel
01-27-2007, 10:01 AM
The 335 is a little different in that its output is a current proportional to C.· To read it, RCTime could be used to measure the charge time of a capacitor.· I haven't done this before, so not the best to answer.· But you can also drop it across a 10K resistor and measure the voltage it produces with the ADC0831.

-Martin




▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Martin Hebel
StampPlot - Graphical Data Acquisition and Control (http://www.stampplot.com/)
AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers (http://www.selmaware.com/appbee)·

computer guy
01-27-2007, 10:31 AM
Would the LM35DZ be a better choice then.

Martin Hebel
01-27-2007, 11:14 AM
Yes, it has a voltage output like the LM34, but is in C.
-Martin

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Martin Hebel
StampPlot - Graphical Data Acquisition and Control (http://www.stampplot.com/)
AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers (http://www.selmaware.com/appbee)·

PJ Allen
01-27-2007, 11:55 AM
Crikey -- the LM34 is Fahrenheit, the LM35 is Celsius (centigrade.)· Fahrenheit is 180 degrees between freezing and boiling and Celsius is 100 degrees.·

Catsup? ·Ketchup?

computer guy
01-27-2007, 12:23 PM
Yes but would that make a difference when it came to programming the code (i know obviously yes) but what would you change what maths would need to be done to convert the 9 bit reading from the input into celsius.

Thanks, but you came accros as a bit rude.

Martin Hebel
01-27-2007, 12:46 PM
Not to be rude, but the process control text you got the circuit from has some information on how the conversion is done. I spent 2 years writing it to answer questions such as yours, and instead of trying to talk you through it here, my recommendation is to look in the text for some answers. It's a free pdf. If you get stumped or can't figure something out then, please ask.

Around page number 186 is a good place to look (pdf page 196)

-Martin

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Martin Hebel
StampPlot - Graphical Data Acquisition and Control (http://www.stampplot.com/)
AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers (http://www.selmaware.com/appbee)·

computer guy
01-27-2007, 01:01 PM
Sorry i did apologise for bumping but i do need the information rather urgently.

Sorry. http://forums.parallax.com/images/smilies/smile.gif

PJ Allen
01-28-2007, 02:05 AM
OK, so with the LM34 you get 10mV per degree F and with the LM35 you get 10mV per degree C.·

I'm not sure what temperature range you're figuring on dealing with, but obviously you'll have a different range of voltages to deal with.· If you were to do a room temperature thermometer 65 - 85 degrees F, the LM34 would result in an output range of 650 - 850 mV (200mV difference.)· The equivalent range in Celsius would be 18 - 29 degrees C and an LM35 would result an output range of 180 - 290 mV (110mV difference.)

They made them this way so that you could read them directly·using a milli-voltmeter, not intending they should be interfaced with an ADC and all this.· It's cool to do that. ·I'm just trying to·shed some light on the subject, LM34/35-wise.

computer guy
01-28-2007, 08:00 AM
So could i just wire the output pin of the LM35 to an i/o pin of the BS2 and measure the reading.
If so what pbasic function would read the mv reading.

Thanks

P.S If not looks like i will just need to get an ADC0831 chip.

PJ Allen
01-28-2007, 09:23 AM
computer guy said...
So could i just wire the output pin of the LM35 to an i/o pin of the BS2 and measure the reading.
No.· The Stamp doesn't have an·analog input; it's a micro-controller, not a voltmeter.
Are you just going to turn a fan on/off?· Or are you trying to effect varying speed?
Stick with the Process Control example/s (Martin Hebel, etc.), knowing that you'll have to reckon with your data accordingly.· I guess it was written using a LM34 (Fahrenheit) and you want to go off the reservation and use a LM35.· One is not better than the other,·either is as usable as the other, but the resulting outputs aren't the same and therefore the ADC range and results between the two will be quite different.· To that end, I think you'll just have to be bold, daring and unafraid and experiment all that out.
Update -- The ADC0801 in the example·digitizes a span of 0 to 5V into 256 slices, because Vref = +5V.· So, that is approx. 20mV per step.· An LM35 in the range 18 to 29 degrees C will output 180 to 290mV and the ADC0801 should result counts, ideally,·between 0000 1001 ($09) and 0000 1110 ($0E), I suspect.· Not much resolution.
If you use a lower Vref, you'll have more resolution.· With 1V Vref, it's then 1V/256 = appx 4mV per step, yielding 0010 1101 ($2D) to 0100 0110 ($46), I think.


Post Edited (PJ Allen) : 1/28/2007 1:56:51 AM GMT

computer guy
01-28-2007, 10:44 AM
So you are suggesting putting a resistor between vdd and the vref pin on the ADC chip.
What resistor value would i need to turn 5V into 1V.

I have never been able to work out how you determin what resistor you need to use.

Thanks http://forums.parallax.com/images/smilies/smile.gif

PJ Allen
01-28-2007, 11:06 AM
Use a potentiometer.

computer guy
01-28-2007, 11:53 AM
Thanks will do that.

So if i was to read the temperature every 10 seconds (10000 milli seconds) and convert the 9 bit data into a celcius reading and then set the fans speed using the pulse out command.

How would i pulse the fan output without using up all the BS2 processing time. My robot also needs to roam with a ping))) and drive 2 motors.

Thanks http://forums.parallax.com/images/smilies/smile.gif

Martin Hebel
01-28-2007, 11:58 AM
Process control has a discussion how to maintain a fan running at a variable speed without tying up the BS2. Surprise! Though depending on the fan your results may vary. If you use PWM to the fan, and only read the temperature every few seconds, the fans inertia should keep it going while you read.


-Martin

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Martin Hebel
StampPlot - Graphical Data Acquisition and Control (http://www.stampplot.com/)
AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers (http://www.selmaware.com/appbee)·

computer guy
01-28-2007, 12:15 PM
If i were to read the temp every 10 seconds. And sent a pulse to the fan every 5 seconds if the pulse was 1ms on 1 ms off then the fan would run at half speed.
Will the fan keep it's speed over a 5 second gap.

Thanks http://forums.parallax.com/images/smilies/smile.gif

computer guy
01-28-2007, 01:03 PM
Could I connect a capacitor just before the fan and use it to keep the fan running for the 5 second gap between pulses.
If so what capacitor would you recomend for that job.

Please see picture.

Thanks http://forums.parallax.com/images/smilies/smile.gif

Post Edited (computer guy) : 1/28/2007 5:19:28 AM GMT

Desy2820
01-28-2007, 04:46 PM
I’d suggest simplifying this design.· Since you mentioned that this is part of a robot and the BS2 is a single-task processor, but you need the fan to run continuously and the BS2 can’t do that and run your robot too, I’d suggest trying some other ideas for the fan speed control.
·
Please forgive my crude Paint diagram, but I wanted to show you what I was talking about.· PLEASE breadboard, research and test extensively before you build.
·
My first idea is to forget the PWM stuff.· Just switch the fan between high and low speed as needed using a SPDT relay.· Most 12V fans when fed 5V power, spin slowly, about 1/3 to 1/2 as fast.· When needed, energize the relay, giving the fan full power and full speed.·
·
The fan constantly runs at low speed.· A sensor reads the temp and when it exceeds your set point, activates the transistor, which energizes the relay.· The relay now sends full power to the fan, allowing it to spin at full speed.· The BS2 is supervising the process, with the other temp sensor.· At the point marked “BS2 Override Input”, you can output a “high” from the Stamp to make the fan run at full speed.· Or make this pin an “input” and you can sense when the fan has been commanded to full power (relay energized).· If an emergency occurs, i.e. fan is at full power, but the temp is too high for an extended period, you can take action.· You need to decide and design that action.
·
In my diagram, I’m using two temp sensors on the heat sink.· One is the LMXXX part you’re already planning on using, the other is a Dallas ·DS1821.· The DS1821 is connected to the relay, the LMXXX is the one at the top.· The DS1821 is a one-wire programmable chip.· BEFORE using it, you need to create and load a program into the BS2 to program the set points and change it’s mode to “thermostat.”· Also, the settings CAN’T be changed on the fly, to change the switch points; you would need to repeat the initial programming procedure.· Here, I’m simply using it as a temp switch to control the low/high speed transition point.· This is a VERY crude sketch; you need to add resistors as needed, such as between the BS2 and the point marked “override input” and at the base of the NPN transistor.· You may not need the diode between the DS and the relay.· I added it because I’m not sure if the DS can take a reverse input (it may also be backwards).· Check the data sheet.
·
Use an SPDT relay with a 5V coil and 12V contacts.· Connect the fan’s positive lead to the COMMON of the relay.· Connect +5V to the NC (normally closed) connection of the relay.· Connect +12V to the NO (normally open) connection of the relay.· Use a diode across the coil to protect the transistor.·
·
My last idea is to off-load the PWM task onto a co-processor, such as the PWM Pal.· The co-processor would generate continuous PWM at whatever level you specify until told to change or stop.· The PWM co-processor can’t drive the fan directly, so you would still need to use a transistor, FET or H-bridge chip.· The BS2 would initialize the PWM co-processor, starting the fan.· BS2 could then read the temp sensor every X seconds or minutes, convert and process, decide, then as needed, send a new setting to the PWM co-processor.· An advantage is that most of these have two or more channels, allowing you to PWM another fan, motor, LED, etc.·
·
One last note, as I have stated, this is just a concept.· It should work, but research and test, especially your fan.· Some fans may not start at a low voltage, you may need to give it full power at first and then bring it down to where you want it.· Verify that the fan will run at 5V for my first idea; otherwise, you’ll need to figure out the lowest PWM value that the fan will spin at.· There are a lot of example programs to use the DS1821, this should get you started.
·
I hope this helped and good luck!

Post Edited (Desy2820) : 1/28/2007 8:51:15 AM GMT

computer guy
01-28-2007, 06:42 PM
Thanks i like your first suggestion.

Could i have a relay that when off would give the fan 5V and if the temperature sensor which will be read every 30 seconds or so reported that the temperature was high the BS2 would set an output High turning on a transistor that would switch the relay giving the fan 12V.

The diode is in there for protection from the switching relay.

Desy2820
01-28-2007, 07:06 PM
Yes,·that's why I specified a Single Pole Double Throw (SPDT) relay.·· When the relay is off, the NC contacts have continuity, allowing the 5V to the fan.· When energized, the NO contacts send 12V to the fan.· Please test to see if the fan will start at 5V.· One last note, as long as there is 5V, the fan will try to spin.· There is no "off" position in the design!

In your diagram, flip the voltages on the relay.·The 5V must be on the NC (Normally Closed).· Or you could leave it this way, and use the relay to put the fan in low speed mode.· This would use a little more power, but might work out better, becuase the fan would run full tilt until you told it to do otherwise.· As you have it, the fan will run at full speed until the relay closes.· You also need a resistor for the base of the transistor.· Follow the diagram previously posted for the BS2/relay wiring.·

It looks like you've combined the two ideas.· Overall, your concept looks good to me.· Remember, breadboard and test!· Divide and conquer, get one part working, then move on and later combine the pieces.· You can use a pushbutton instead of the BS2 to check the relay's operation.· And use·the debug screen and an LED to test the programming.· Then combine the two.

Just out of curiosty, what program are you using for your diagrams?· Trying to use Paint sucks!

Post Edited (Desy2820) : 1/28/2007 11:14:18 AM GMT

computer guy
01-28-2007, 07:19 PM
For the previous diagram i used Paint. For all the others i used Eagle Version 4.16r2 Lite edition.

Site: www.cadsoft.de (http://www.cadsoft.de)

(www.cadsoft.de)

Download: tp.cadsoft.de/eagle/program/4.16r2/eagle-win-eng-4.16r2.exe (ftp://ftp.cadsoft.de/eagle/program/4.16r2/eagle-win-eng-4.16r2.exe)

(ftp.cadsoft.de/eagle/program/4.16r2/eagle-win-eng-4.16r2.exe)

Thanks for your help http://forums.parallax.com/images/smilies/smile.gif

Post Edited (computer guy) : 1/28/2007 11:24:15 AM GMT

computer guy
01-29-2007, 05:38 PM
This is the final schematic could some one please check over it to make sure it has all the right parts and is wired properly.

Thank you all for your help. http://forums.parallax.com/images/smilies/smile.gif

Am jumping for joy at the fact that this project is going somewhere. http://forums.parallax.com/images/smilies/hop.gif

computer guy
02-02-2007, 06:58 AM
I'm sure i will regret this but, Bump! http://forums.parallax.com/images/smilies/wink.gif

PJ Allen
02-02-2007, 07:06 AM
Looks like it should "work": with regard to the relay contacts, you will have the fan connected to either +12 or +5 -- I don't know if that's desired or not.· Maybe that's how you're affecting "speed control" (+5 = Low speed, +12 = High speed)?

Update -- I don't know what your fan's current rating is, so I don't know if the/that transistor is appropriate (100mA.)




Post Edited (PJ Allen) : 2/1/2007 11:11:13 PM GMT

computer guy
02-02-2007, 07:13 AM
0.20A 12V Ball bearing I don't think 5V will be enough to power the fan but was hoping that 6V will.
If not i thought if i powered the fan on full (12V) for 5 seconds and then droped it to Low (6V) It should keep low speed momentum.

edit: I might also add another diode between the fan + and -.

P.S will a 1N4004 diode work instead of a 1N4001.
What is the difference?


Thanks http://forums.parallax.com/images/smilies/smile.gif

PJ Allen
02-02-2007, 07:20 AM
The 1N4001 has a lower Peak Inverse Voltage (the lowest of that series).· The PIV is the most voltage the diode can hold off when backward-biased.· The 1N4004, etc. will work fine, in that regard.

I think that you may find you will need to incorporate a power transistor, that guy will get pretty hot at 200mA, but give it a go (I don't want to be figured a Prophet of Doom.)

computer guy
02-02-2007, 07:28 AM
When you say a power transistor what do you mean.... Replacing the original transistor with a different type or adding another one somewhere in the circuit.

What transistor would you recomend?

Thank you http://forums.parallax.com/images/smilies/smile.gif

PJ Allen
02-02-2007, 09:18 AM
I say,·"run her up the flag-pole and see if anyone salutes."· Either way, it won't be the end of the world.

A good learning lesson here.· Keep the Stamp "out of the picture" and just touch the transistor's base resistor, using a jumper wire,·to +5V.· See how that works out.

computer guy
02-02-2007, 10:52 AM
Thanks will do so.

I just tested my fan and it runs from 5V so that looks good.
Now just have to get the components and test the transistor and relay switching circuit.

Thank you http://forums.parallax.com/images/smilies/smile.gif

Post Edited (computer guy) : 2/2/2007 3:21:40 AM GMT

Desy2820
02-02-2007, 04:42 PM
Just to clarify, the transistor DOES NOT conduct the current from the fan.· The relay's contacts conduct that current.· All the transistor has to worry about is the current thru the relay's 5 volt COIL, which shouldn't be that much.

I'm glad the fan works at·5 volts.· Step one complete!

computer guy
02-25-2007, 05:28 AM
Hi all

I have tested the circuit and all seams all right except one thing the 2n2222 transistor seams to be limiting the current to the relay therefore there is not enough current to switch it on.


Thank you http://forums.parallax.com/images/smilies/smile.gif

Computer guy

PJ Allen
02-25-2007, 09:37 AM
Everything seems all right, but it's not working, apparently.

I don't know what your relay coil resistance is (this is what collector current is all about.)· I don't know what value you're using for the base resistor either.· Hazarding a guess, I think that you may need to increase the base current (so try a lower value resistor.)

I looked at your drawing.· Is it really a 5V relay coil?· You're using a 1K base resistor.· If it is a 5V relay, then try a 470-ohm base resistor (you can use two 1K resistors in parallel.)

computer guy
02-25-2007, 01:22 PM
My relays coil resistance is 25Ω i am using a 6v relay that switches with 5 volts without the 2n2222 transistor but as soon as i add the transistor it won't work.


Thank you http://forums.parallax.com/images/smilies/smile.gif

P.S i managed to fryhttp://forums.parallax.com/images/smilies/skull.gif my transistor the other day playing around with my base resistor, guess i went to low. http://forums.parallax.com/images/smilies/cry.gif


Computer guy

PJ Allen
02-25-2007, 10:55 PM
Coil resistance = 24-ohms?· Odd that [super-atypical.]· The resistance should be (much) higher than 24-ohms.· Most unusual.· Relays are usually 100-300 ohms.· 5V / 24ohms = 210mA.· Where did you get this relay?

computer guy
04-02-2007, 05:08 PM
I got it from Jaycar Electronics - Albury NSW Australia.

It is a small relay (1cm X 1.5cm X 1cm) - W X L X H

Thank you http://forums.parallax.com/images/smilies/smile.gif

computer guy
04-09-2007, 09:01 AM
I pulled apart an old line following robot of mine the other day and found the exact same circuit. So i salvaged the parts.

Can someone tell me if it is alright to share a negative (-) terminal on 2 devices.
More specifically the power source to the relay (5v) and the propeller (i am using a Proto Board now).
Only the negative (-) terminal.

5v (+) -------------------------------------------(+)
(-) ------------------prop (-) -------------Relay (-)

Thank you http://forums.parallax.com/images/smilies/smile.gif

edit:
please look at the pic and tell me your thoughts on if this can be done.

Post Edited (computer guy) : 4/10/2007 2:43:00 AM GMT

computer guy
04-09-2007, 02:27 PM
Echo, echo...

Bump http://forums.parallax.com/images/smilies/smile.gif

Vern Graner
04-09-2007, 11:24 PM
computer guy said...
<snip>my parts tend to overheat and the fans are really noisy</snip>

Just an idea but, could it be that maybe the design of the circuit producing the heat should be reviewed with an eye towards reducing the current dissipation that is causing the heat?

Just an idea... http://forums.parallax.com/images/smilies/smile.gif

Vern

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔



Vern Graner CNE/CNA/SSE | "If the network is down, then you're
Senior Systems Engineer | obviously incompetent so why are we
Texas Information Services | paying you? Of course,if the network
http://www.txis.com | is up, then we obviously don't need
Austin Office 512 328-8947 | you, so why are we paying you?" ©VLG

computer guy
04-10-2007, 07:07 AM
I have a robot in a fully enclosed perspex case, with several components that need cooling.

Any thoughts on the sharing of negative (-) terminal?

Thank you http://forums.parallax.com/images/smilies/smile.gif

Skywalker49
04-10-2007, 07:16 PM
Hi CG,

Quote:
Can someone tell me if it is alright to share a negative (-) terminal on 2 devices.
More specifically the power source to the relay (5v) and the propeller (i am using a Proto Board now).
Only the negative (-) terminal.
End-Quote

Yes, connect the negative of the 5V power supply to the one of the propeller board

Check-out the "more sophisticated" responses in the Sandbox thread.

Post Edited (Skywalker49) : 4/10/2007 12:05:44 PM GMT