Shop OBEX P1 Docs P2 Docs Learn Events
Shortest ON time for an I/O pin? — Parallax Forums

Shortest ON time for an I/O pin?

HagenHagen Posts: 5
edited 2009-11-20 20:23 in Propeller 1
I'm having a hard time finding out the shortest "ON" time for an I/O·pin on the propeller chip.

I want to be able to do PWM, with a very short "ON" time and a much longer "OFF" time.

Any help would be appreciated.

Thank you,

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2009-11-19 21:20
    Guess we need more details for understanding your need for a very short on and a longer off time.

    PWM means that the digital value of the PWM - let's say it's 16 bit - is proportional to the voltage that you see on the output. So, value 0 for example means 0V, value 65535 means 3,3V, 32767 means 1,65V. When you say you want to have a very short ON versus a much longer OFF time, this means that your resolution will be much smaller. Instead you could directly decrease the voltage and keep the resolution of 16 bit.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-11-19 21:30
    The Propeller normally executes instructions in 50ns with an 80MHz system clock. Using one instruction to turn on an I/O pin and another to turn one off, the minimum on or off time is 50ns. If you use the internal cog counters to toggle an I/O pin, you can do it faster, well under 12.5ns and probably much shorter a time than you're prepared to handle.

    Again, how about providing more details about what you're trying to accomplish.

    Have you looked at the PWM object in the Propeller Object Exchange?
  • HagenHagen Posts: 5
    edited 2009-11-19 22:07
    Thank you Mike Green amd MagIO2 for your reply.

    I am trying to determine which Parallax chip will work best for me. The BS2px chip has a min on time of 0.81 micro seconds. I need to be in the range of 0.5 or less micro seconds, with a long programmable OFF time. I need to pulse multiple output pins and have accurate programmable phase relationship between the pins. I will be driving multiple inductors using MOSFETS. Sounds simple enough [noparse]:)[/noparse] I will look for the PWM object in the Propeller Object Exchange.

    Thanks for your help!
  • HarpritHarprit Posts: 539
    edited 2009-11-19 22:24
    This uses a counter
    Here is some code you can run from my soon to come out "book for beginners"
    This is so fast that if you make phsa much less than 100 you cant see it. Can be 1
    The wavelength can be as long as you want so it pretty flexible as a short PWM signal
    I'm running at 10 MHz by you can go to 80.
    Look at pin 2 with a scope, the signal is pretty weak.
    Play with it.

    CON
    _CLKMODE=XTAL1+ PLL2X 'The system clock spec
    _XINFREQ = 5_000_000 'crystal frequency

    VAR
    byte pin

    PUB Demo|WaveLength,period 'subroutine to toggle the output line 2
    pin:=2
    dira~~ 'gain access to line
    ctra[noparse][[/noparse]30..26]:=%00100 'Set this cog's "A Counter" to run PWM
    ctra[noparse][[/noparse]5..0]:=pin 'Set the "A pin" of this cog to Pin=2
    frqa:=1 'Set this counter's frqa value to 1
    WaveLength:=clkfreq/100 'Set the time for the wave Length to 10 ms
    period:=cnt 'Store the current value of the counter
    repeat 'power PWM routine.
    phsa:=-100 'Send a high pulse for 100 counts
    period:=period+WaveLength 'Calculate wave length
    waitcnt(period) 'Wait for end of wavelength

    Regards
    Harprit
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2009-11-19 22:55
    Hagen said...
    Thank you Mike Green amd MagIO2 for your reply.

    I am trying to determine which Parallax chip will work best for me. The BS2px chip has a min on time of 0.81 micro seconds. I need to be in the range of 0.5 or less micro seconds, with a long programmable OFF time. I need to pulse multiple output pins and have accurate programmable phase relationship between the pins. I will be driving multiple inductors using MOSFETS. Sounds simple enough [noparse]:)[/noparse] I will look for the PWM object in the Propeller Object Exchange.

    Thanks for your help!

    Forget about the inductors for the moment, it's driving the MOSFETs that has me worried, you have a license do you? You have driven one of these things before at high speed?

    Driving a MOSFET as a switch at high frequency requires drivers capable of rapidly charging and discharging the large gate capacitance. Failure to do so will mean the MOSFET will not turn on/off properly or spend too much time in it's linear region which also incurs the penalty of increased power dissipation. The figure of 0.5us is ambitious enough for a newbie but saying "or less" means you need to research this a little more.

    What is your application, does it need such a high frequency? The 12.5ns pulses from the Prop's counters will be too short as would the 50ns bit-banged version. Have you tried a SPICE simulation yet?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • HagenHagen Posts: 5
    edited 2009-11-19 23:31
    Thanks Peter,

    I'm not familiar with the spice simulation, I'll look that up.

    My target "ON" time is 0.5 microseconds, anything more than that is gravy.

    I understand that I will need to use a driver chip for the power MOSFET.

    Thanks Mike Green, I think I found a few programs that will help me very much in the Propeller Object Exchange.
  • RumpleRumple Posts: 38
    edited 2009-11-20 18:59
    Mike Green said...
    ·Using one instruction to turn on an I/O pin and another to turn one off, the minimum on or off time is 50ns.
    That's in assembler, right?


    Tim
  • Mike GreenMike Green Posts: 23,101
    edited 2009-11-20 20:19
    Yes, that's in assembler.

    Also remember that you can do the same sort of thing in Spin at assembly speeds by using the cog counters.
  • HarpritHarprit Posts: 539
    edited 2009-11-20 20:23
    Per Mike's comment, the example I provided above is all in SPIN and uses a counter.
    Its hard to understand assembly code if you are not proficient so SPIN is a better format for examples
    HSS
Sign In or Register to comment.