Shop OBEX P1 Docs P2 Docs Learn Events
12V Fan and bs2 — Parallax Forums

12V Fan and bs2

computer guycomputer guy Posts: 1,113
edited 2007-04-10 11:16 in BASIC Stamp
Hi

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

Any ideas on what i can do. confused.gif


Thanks.
«1

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2007-01-24 14:05
    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 guycomputer guy Posts: 1,113
    edited 2007-01-24 22:47
    What like this?

    attachment.php?attachmentid=45161
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-01-24 22:53
    Try the attached schematic instead...There are a few·small issues·in the one you posted.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    320 x 247 - 6K
  • computer guycomputer guy Posts: 1,113
    edited 2007-01-24 23:00
    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 SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-01-24 23:44
    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 guycomputer guy Posts: 1,113
    edited 2007-01-25 00:25
    How would i measure the temperature with the BS2.
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2007-01-25 00:32
    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
    AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers·
  • computer guycomputer guy Posts: 1,113
    edited 2007-01-25 00:43
    Martin said...

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

    What is that? Could you please post a link.
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2007-01-25 01:20
  • computer guycomputer guy Posts: 1,113
    edited 2007-01-25 06:48
    Is there a way i can do this without taking up that many i/o pins?

    attachment.php?attachmentid=45170
    temp.bmp 413.5K
  • computer guycomputer guy Posts: 1,113
    edited 2007-01-26 03:06
    Bump

    Not to be rude but this is urgent. smile.gif
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2007-01-26 03:10
    Thanks for the Bump [noparse]:)[/noparse]
    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
    AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers·
  • computer guycomputer guy Posts: 1,113
    edited 2007-01-26 04:25
    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 HebelMartin Hebel Posts: 1,239
    edited 2007-01-26 04:33
    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 guycomputer guy Posts: 1,113
    edited 2007-01-26 05:09
    Ok thanks.
  • computer guycomputer guy Posts: 1,113
    edited 2007-01-26 23:00
    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

    Thanks

    Post Edited (computer guy) : 1/27/2007 12:42:28 AM GMT
  • computer guycomputer guy Posts: 1,113
    edited 2007-01-27 01:43
    I like to bump 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 HebelMartin Hebel Posts: 1,239
    edited 2007-01-27 02:01
    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
    AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers·
  • computer guycomputer guy Posts: 1,113
    edited 2007-01-27 02:31
    Would the LM35DZ be a better choice then.
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2007-01-27 03:14
    Yes, it has a voltage output like the LM34, but is in C.
    -Martin

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Martin Hebel
    StampPlot - Graphical Data Acquisition and Control
    AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers·
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2007-01-27 03:55
    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 guycomputer guy Posts: 1,113
    edited 2007-01-27 04:23
    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 HebelMartin Hebel Posts: 1,239
    edited 2007-01-27 04:46
    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
    AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers·
  • computer guycomputer guy Posts: 1,113
    edited 2007-01-27 05:01
    Sorry i did apologise for bumping but i do need the information rather urgently.

    Sorry. smile.gif
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2007-01-27 18:05
    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 guycomputer guy Posts: 1,113
    edited 2007-01-28 00:00
    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.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2007-01-28 01:23
    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 guycomputer guy Posts: 1,113
    edited 2007-01-28 02:44
    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 smile.gif
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2007-01-28 03:06
    Use a potentiometer.
    219 x 125 - 3K
  • computer guycomputer guy Posts: 1,113
    edited 2007-01-28 03:53
    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 smile.gif
Sign In or Register to comment.