Shop OBEX P1 Docs P2 Docs Learn Events
Question about I/O and configuring — Parallax Forums

Question about I/O and configuring

James LongJames Long Posts: 1,181
edited 2008-03-08 03:25 in Propeller 1
Ok....I have a major project I'm working on.....and need to know something.

I'm working on a system that will use n channel mosfets.· I want to control the mosfets with the propeller.

I do not want the propeller to prematurely initiate the mosfet to the "on" condition.

What is the best method of doing this?

Is it possible the Prop could possibly do this on power up?· During the change of direction(input to output)? any other situation (other than incorrect programming)?

Chip.....Chris....anyone else?

James L

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
James L

Partner/Designer
Lil Brother LLC (SMT Assembly Services)

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2008-03-08 01:06
    Hi James, to inhibit undesired behavior the gate of the NMOS should be strapped to ground through a resistor, this way a Hi-Z situation (pin set to input) will result in the NMOS being off.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-03-08 01:20
    Along these lines is there any particular reason that the propeller doesn't have programmable pull up or pull down resistors on the output pins like the AVR chips? Is this so that you can play around with the outx registers without worrying about what you are doing with the pins?
  • James LongJames Long Posts: 1,181
    edited 2008-03-08 01:29
    Paul Baker (Parallax) said...
    Hi James, to inhibit undesired behavior the gate of the NMOS should be strapped to ground through a resistor, this way a Hi-Z situation (pin set to input) will result in the NMOS being off.

    Paul,

    Ok....so a pull up/down resistor should be on the gate of the NMOS. Which I already have in the design.

    I was thinking a pull up with a NMOS in a sink situation, but my logic may be backwards......it does happen with my age gettin up there.

    What about the time when I go (DIRA, and OUTA right after another)? How fast does this transition take......

    What condition does an output start in? (High or Low). I know I have read this somewhere....but I can't seem to find it in the manual.

    EDIT.....I didn't change the post....because someone else may have the same question. But I think I have found my answer. Because I/O is configured during boot.......there would be no transition from input to output. The pin would just become output high (or low depending on the setting) when the propeller is put into motion.

    If I am wrong.....just let me know.......this is an issue I haven't thought of before. /EDIT

    James L

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    James L

    Partner/Designer
    Lil Brother LLC (SMT Assembly Services)

    Post Edited (James Long) : 3/8/2008 1:36:32 AM GMT
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-03-08 01:38
    Initially everything is set to zero. This means that DIRA and OUTA for all cogs will be zero which means all pins will be inputs. When a pin is an input it is tristated which just means that it has a very high impedance and is basically floating. This is obviously not good when it is connected to something and is why you must use a pullup resistor. If you change a pin to an output using DIRA without changing OUTA it will change to an output with an initial value of zero because OUTA is still zero. If you are using assembler and use consecutive instructions to set DIRA and OUTA than you will have a 4 cycle difference which at 80MHz is 50ns.
  • James LongJames Long Posts: 1,181
    edited 2008-03-08 01:44
    stevenmess2004 said...
    Initially everything is set to zero. This means that DIRA and OUTA for all cogs will be zero which means all pins will be inputs. When a pin is an input it is tristated which just means that it has a very high impedance and is basically floating. This is obviously not good when it is connected to something and is why you must use a pullup resistor. If you change a pin to an output using DIRA without changing OUTA it will change to an output with an initial value of zero because OUTA is still zero. If you are using assembler and use consecutive instructions to set DIRA and OUTA than you will have a 4 cycle difference which at 80MHz is 50ns.
    OK .........would it be possible to use OUTA before DIRA. I don't see how this would work.......but I'm not the versed Prop user either.

    I can't do 50 ns.....that could be a bad thing.

    James L

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    James L

    Partner/Designer
    Lil Brother LLC (SMT Assembly Services)
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-03-08 01:56
    Yes, you can set OUTA before DIRA. The OUTA doesn't affect anything until you set DIRA. for example

    'if you do
    mov dira,#1
    mov outa,#1
    'dira will set the pin to an output and you will get a 0 for 50ns when you will get a 1
    
    'if you do
    mov outa,#1
    mov dira,#1
    'than you are first setting up the pin to be a 1 and it will be a one as soon as you do the dira instruction.
    
    
  • James LongJames Long Posts: 1,181
    edited 2008-03-08 02:07
    stevenmess2004 said...
    Yes, you can set OUTA before DIRA. The OUTA doesn't affect anything until you set DIRA. for example

    'if you do
    mov dira,#1
    mov outa,#1
    'dira will set the pin to an output and you will get a 0 for 50ns when you will get a 1
    
    'if you do
    mov outa,#1
    mov dira,#1
    'than you are first setting up the pin to be a 1 and it will be a one as soon as you do the dira instruction.
    
    

    Steven,

    Since you are the one I've been talking with......can this be done as well in Spin?

    Thanks,

    James L

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    James L

    Partner/Designer
    Lil Brother LLC (SMT Assembly Services)
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-03-08 02:13
    Yes, you could do exactly the same thing in spin
    outa[noparse][[/noparse]pinNum]:=1
    dira[noparse][[/noparse]pinNum]:=1
    
    


    Adjusting for appropriate pins of course. In fact you could do
    outa[noparse][[/noparse]pinNum]~~
    dira[noparse][[/noparse]pinNum]~~
    
    


    If you want to do it the other way around in spin than the delay will be longer than 50ns.
  • James LongJames Long Posts: 1,181
    edited 2008-03-08 02:16
    stevenmess2004 said...
    Yes, you could do exactly the same thing in spin
    outa[noparse][[/noparse]pinNum]:=1
    dira[noparse][[/noparse]pinNum]:=1
    
    


    Adjusting for appropriate pins of course. In fact you could do
    outa[noparse][[/noparse]pinNum]~~
    dira[noparse][[/noparse]pinNum]~~
    
    


    If you want to do it the other way around in spin than the delay will be longer than 50ns.
    Thanks Steve,

    That helps a lot........I will stick with spin on the part of the project....and will make sure I set the pin high before I set it to an output.

    James L

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    James L

    Partner/Designer
    Lil Brother LLC (SMT Assembly Services)
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-03-08 02:22
    Do you want the pin to be high? If you have a pulldown resistor than it won't make any difference (because the pin is being pulled low by the resistor to ground) if you set the pin to an output low and than tell it to output high except it will take longer the first time you do it.
  • James LongJames Long Posts: 1,181
    edited 2008-03-08 02:30
    stevenmess2004 said...
    Do you want the pin to be high? If you have a pulldown resistor than it won't make any difference (because the pin is being pulled low by the resistor to ground) if you set the pin to an output low and than tell it to output high except it will take longer the first time you do it.
    Steve (or Steven......don't know which one),

    The mosfet is an N channel in·sink mode. My logic states (can be wrong), that I need the pin high to prevent the mosfet from conducting.

    So I will put a pull up resistor on the base (already done actually) and set the pin high before making it an output.

    So when I want the NMOS to conduct,·it will actually be reverse logic. Take the output low to turn the NMOS on.

    It is confusing.....that is why I always want a second, third, fourth pair of eyes to make sure I'm not confused.

    James L

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    James L

    Partner/Designer
    Lil Brother LLC (SMT Assembly Services)
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-03-08 02:43
    Its Steven but call me anything you like except latefordinner smile.gif

    I think that you are getting NMOS and PMOS confused. Don't PMOS conduct with a low and stop conducting with a high? In the attached picture the top mosfet is a PMOS and the bottom is NMOS. As shown, the bottom mosfet (NMOS) is conducting with a high on the gate.
  • James LongJames Long Posts: 1,181
    edited 2008-03-08 03:17
    stevenmess2004 said...
    Its Steven but call me anything you like except latefordinner smile.gif

    I think that you are getting NMOS and PMOS confused. Don't PMOS conduct with a low and stop conducting with a high? In the attached picture the top mosfet is a PMOS and the bottom is NMOS. As shown, the bottom mosfet (NMOS) is conducting with a high on the gate.
    I can't see the TIFF image....don't have a viewer I guess.

    But this does depend of if we are soucing or sinking current.....correct?

    I don't remember....it's been many moons since I did transistor theory....and the propeller makes it too easy to mostly not have to think about.

    EDIT:Steven after going back and looking....you are right.....I was thinking a N channel was like a PNP. It is not....it is like·a NPN.

    This website cleared it up: http://hades.mech.northwestern.edu/wiki/index.php?title=Driving_using_a_single_MOSFET&printable=yes

    But thanks for the information anyway......that information will come in handy at some point. (changing logic level, before changing to output)

    James L

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    James L

    Partner/Designer
    Lil Brother LLC (SMT Assembly Services)

    Post Edited (James Long) : 3/8/2008 3:27:01 AM GMT
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-03-08 03:25
    Try this one. It is just a java applet that does some nice things. Just go to the website in the picture to find it.
    800 x 640 - 37K
Sign In or Register to comment.