Shop OBEX P1 Docs P2 Docs Learn Events
Am I breaking any rules when I do this? — Parallax Forums

Am I breaking any rules when I do this?

Jimbo30Jimbo30 Posts: 129
edited 2010-05-26 05:40 in BASIC Stamp
I have a 24V 2amp power supply hooked up to an inductive proximity sensor and I need to use pull down resistor·circuit as an·input into the Basic Stamp.· The power supply is 24V at 2 amps so 12ohms would be·the power supplies·resistance.· Would I break any rules if I included a 2K resistor to drop the wattage and amperage down and fed that same 24V @ 11.9mA·into a 7805, then into the Basic Stamp's input pin?·

Comments

  • Jimbo30Jimbo30 Posts: 129
    edited 2010-05-25 01:39
    Basically what I am trying to get at is, "Is this how the professionals usually do it when working with 24V sensors." The sensor will not work with 5 Volts -- already tried.
  • FranklinFranklin Posts: 4,747
    edited 2010-05-25 01:55
    Jimbo30 said...
    The power supply is 24V at 2 amps so 12ohms would be the power supplies resistance
    That's not how it works. 24v is the output but the 2a is just the maximum current the power supply can source. We need more information on the sensor. What is it's output (positive or negative, a variable voltage or something else? That's where you need to start, it's the output of the sensor you need to convert to something the stamp can use.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-05-25 02:15
    24V - 5V is a huge differential to manage with any kind of linear regulation. Most people who want to convert 24V to 5V use a switching converter. It's more efficient, thus generating less waste heat.

    -Phil
  • Jimbo30Jimbo30 Posts: 129
    edited 2010-05-25 02:22
    Franklin said...
    Jimbo30 said...
    The power supply is 24V at 2 amps so 12ohms would be the power supplies resistance
    That's not how it works. 24v is the output but the 2a is just the maximum current the power supply can source. We need more information on the sensor. What is it's output (positive or negative, a variable voltage or something else? That's where you need to start, it's the output of the sensor you need to convert to something the stamp can use.

    Franklin -- it is a NPN sensor (3-wire, normally open, NPN) Brown is the positive, blue is the negative and the black wire is the output.· I believe it is a negative output voltage.··The datasheet I have included at the bottom.· Furthermore, the datasheet is saying the output current is 150mA.· Something·tells me I am going to need a transistor at the output of the sensor·freaked.gif

    Post Edited (Jimbo30) : 5/25/2010 2:30:51 AM GMT
  • Jimbo30Jimbo30 Posts: 129
    edited 2010-05-25 02:24
    Phil Pilgrim (PhiPi) said...
    24V - 5V is a huge differential to manage with any kind of linear regulation. Most people who want to convert 24V to 5V use a switching converter. It's more efficient, thus generating less waste heat.

    -Phil
    Thanks phil I will look into that.·
  • Jimbo30Jimbo30 Posts: 129
    edited 2010-05-25 02:38
    Nevermind!!!· I could probably use a voltage divider and feed the 5 volts or so into the stamp input.· As long as I can get a safe current and not damage the Stamp I should be okay.
  • metron9metron9 Posts: 1,100
    edited 2010-05-25 05:34
    You are using the stamp pin as an input, there will be no current if the pin is set to input. What matters here is the voltage must not be higher than 5volts.

    The sensor uses from 10volts to 30 volts as input. If you use a 24 volt power supply that will work fine.

    The maximum load the device can tolerate is 150mA. This means you can't switch a relay for example that needs more than 150mA

    You can as you suggest switch a transistor or fet using the output.

    I have attached the diagram similar to that of the datasheet BU BN BK from top to bottom and show a 24 volt supply.

    By using a 1500ohm resistor from the positive side of the supply to the BK wire the device will use 16mA when it is switched on, that is 16mA will flow through the resistor (the LOAD shown in the datasheet as an empty rectangular box) well below the 150mA maximum.

    Add another resistor of 220 ohms from the BK wire to the BU wire (ground of supply) and you create a voltage divider. The maximum voltage shown is 3.07 Volts, enough to show a HIGH reading on the stamp pin. So when the sensor senses something it closes and you will read a LOW. When the sensor is open you will read a HIGH on your input pin. No current is going into the stamp but the voltage divider has reduced the voltage to what the stamp can handle.

    Smaller resistors could be used and a higher current flow would result or larger resistors could be used for a lower current for example you are using batteries. In that case you would want to use a fet or transistor to turn the device on and off so it would not consume power all the time.

    One note, the 220 ohm resistor must be connected to ground, if it is not you would have 24V on the stamp pin, it would only be 16mA though so not a big deal but do make sure you connect all resistors and check the output with a meter before you connect the stamp pin.

    One other note, your stamp ground must also be connected to the 24 volt supply ground or the stamp pin will not know what the voltage at the nod is just like trying to read the voltage at that node with a meter using just the one probe, you need both positive and negative to get a reading.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!

    Post Edited (metron9) : 5/25/2010 5:40:10 AM GMT
    353 x 310 - 4K
    331 x 284 - 10K
  • allanlane5allanlane5 Posts: 3,815
    edited 2010-05-25 12:49
    +1 Metron. The only problem with his analysis is that if you DO put 24 volts on a BS2 pin you will blow out the drivers on the BS2 chip behind that pin. So don't do that.

    You seem to misunderstand the current ratings. Usually in electronics, the Voltage is the independent variable -- you can change a 5 volt supply for a 7 volt supply for a 24 volt supply. The Current is the DEPENDENT variable -- given a certain voltage and resistance, only that much current will flow. The equation is I = V/R, so if you have 5 volts and 100 ohms in a 'branch', 0.05 amps (aka 50 milli-amps) will flow. It does not matter how much current the supply putting out 5 volts CAN supply, only 50 milli-amps will flow in that case.

    Now, the BS2 DOES have "clipping" diodes on its I/O pins, but they can take "a few milliamps" ( http://ww1.microchip.com/downloads/en/AppNotes/00521c.pdf ). This means there needs to be a lot of resistance in that 'branch'. If you use a 1 Meg-ohm resistor between your 24 volts and the BS2 pin, 24 volts across 1 Meg-ohm is .024 milliamps, which won't damage the pin.

    Now, you haven't said, but I suspect you're trying to read 24 volts AC, not DC, right? That makes things harder.
  • Jimbo30Jimbo30 Posts: 129
    edited 2010-05-25 14:49
    I kind of figured it was only the current the stamp, or anything else,·was worried about.· Thanks guys.
  • metron9metron9 Posts: 1,100
    edited 2010-05-25 15:30
    I am not understanding your post allanlane5 Who is talking about 24VAC? The sensor is 10 - 30 VDC

    I noted the voltage divider circuit had to be solid and 24VDC should not be applied to a pin. I see from your PDF link the 500uA is the maximum, much lower than I thought (and much lower than a few milliamp's as well) but I am not suggesting one directly connect 24VDC with a 1500ohm resistor. If you are worried the 220 hom half of the voltage divider fails I guess you could use a Zener diode, or an opto isolator using a pull up of 5V from the stamp power supply as well.

    Are you saying a voltage divider circuit like the one I posted won't work or is not advisable because it is not safe for the stamp pin?

    Perhaps just adding a 1 meg ohm resistor to the node would be sufficient to protect the pin but I would think smaller resistors in the voltage divider network would be necessary as I don't know the impedance of a stamp pin, perhaps you could define the minimum current necessary for a high low signal using a voltage divider with a 1 meg protection resistor, I would think at some point there would not be enough current to reliably get a high low signal but i don't know what point that would be.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
  • Jimbo30Jimbo30 Posts: 129
    edited 2010-05-25 19:36
    I went with the voltage divider circuit.· I had remembered reading something about it a while back.· Plus, I had to use a voltage divider for a previous project, but it was with a resistive type sensor and an AD2 IC.· Furthermore, I now know the difference between NPN and PNP sensors and how to apply them.

    ·········15.7mA·@ 27VDC······························· 1.5K·ohm···························· 220 ohm

    ·Sensor output
    BLK wire
    \/\/\/
    |
    /\/\/\/\
    BRN wire--- positive

    ······························|······················································220Ohm resistor
    ····················································································· on input
    ·····················································································|

    ······················································································ BS input
    ······························|···················································· around 3.5V
    ······························|·························································· |
    ······························|···························································|
    ······························
    ····················································································· ·BS VSS

    Post Edited (Jimbo30) : 5/25/2010 9:45:47 PM GMT
  • metron9metron9 Posts: 1,100
    edited 2010-05-25 20:12
    That is not correct. The positive is going directly to the 220 ohm, when your sensor is open circuit (black wire is OPEN) then you will have 27 volts on the pin!

    The black wire connects internally with the BU wire (neg) to complete the circuit when closed. The way you have it you will have 27V high and 3.5V when the sensor is closed.

    Look at the data sheet, the sensor shows the black wire and a switch symbol \ that connects with the BU wire. It is similar to a transistor NPN connecting a load to ground. Your 1500 ohm resistor gets connected to ground taking the black wire to ground when closed and the 220 ohm resistor keeps the voltage down to 3.5V when the black and BU wire is open circuit.

    The name sensor output may be confusing you as it sources the load to ground it outputs nothing. Think of the sensor as having the electronics that control the BASE of a transistor and you are connecting the BU wire to ground (transistor would be the emmiter) the 1500 ohm resistor is connected to the collector, when the sensor turns the transistor on the current flows to ground causing the collector to go to 0V. When the transistor base is off (sensor is open) the collector is at voltage in. This case 27Volts.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
  • Jimbo30Jimbo30 Posts: 129
    edited 2010-05-25 21:13
    I will have to check it again. I had the debug terminal checking my input. I was getting 0 when the sensor was open and 1 when it was closed, so I just went with what I had.
  • Jimbo30Jimbo30 Posts: 129
    edited 2010-05-25 21:47
    It seems to work, metron9. On the voltage divider I am getting 0 V when the sensor is open and around 3.5V when the switch is closed. Of course I am using the homework board so an additional 220ohm resistor included on each input pin. The Stamp hasn't gone up in smoke or nothing so I am just going to go with what I have.
  • metron9metron9 Posts: 1,100
    edited 2010-05-26 05:40
    Your schematic you posted looks like this attachment to me, perhaps I am reading it wrong.

    Open 27V and closed 23.55V at 27VDC so you may want to put a voltage meter on that node if indeed this is the way you have it connected.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
    488 x 322 - 4K
Sign In or Register to comment.