Shop OBEX P1 Docs P2 Docs Learn Events
Fastest that you would or could toggle an IO pin? — Parallax Forums

Fastest that you would or could toggle an IO pin?

WBA ConsultingWBA Consulting Posts: 2,933
edited 2012-08-31 23:39 in Propeller 1
I am getting mixed answers in my searching so I figured I would ask my question directly. Irregardless of what the propeller can do as far as speed of toggling a pin, in most uses of a propeller, what is the fastest you would toggle an IO pin? For example, I know my Honda is spec'd to do 110mph, but I never need to go over 75.

I also need to answer the same question for a BASIC Stamp because my project ties into both.

Update 8/31/12
In SPIN, I was able to obtain 18KHz
In PASM, I was able to obtain 5MHz as a 50% duty cycle with a XOR loop.
With Counters, I was able to obtain 60MHz through my translators which was my goal. I did go to 80, but the translators output was very unstable.

Comments

  • TubularTubular Posts: 4,620
    edited 2012-05-27 18:46
    I think...

    Using a counter, you can output a ClkFreq/2 square wave (ie 40~50MHz depending on 5~6.25MHz xtal)
    Or in single cog Pasm, about 10~12.5 MHz

    Your Honda, whats it go to 6000rpm? Thats 100 Hz, or 500,000 times slower :)
  • whickerwhicker Posts: 749
    edited 2012-05-27 19:01
    hmm.

    I think what's really being asked is how long it takes for a spin statement to turn on, and then turn off, a single output pin.

    rough estimate is that I was just barely able to get 38 KHz IR working with just spin instructions with an 80 MHz clock.
    subsequent revisions used a counter, of course, to produce the 38 KHz modulation and then much more slowly stream out the bits using spin.
  • pedwardpedward Posts: 1,642
    edited 2012-05-27 19:51
    If using the PLL, the max I've been able to see is 230Mhz with 80MHz system clock.

    If PASM, 10Mhz, 1 instruction on, 1 off.
  • frank freedmanfrank freedman Posts: 1,974
    edited 2012-05-27 19:56
    Find out for yourself. But determine whether you are using spin or pasm. There (big duh please) is a huge difference in speeds. What will your project require to meet your needs? Then set up loops of different functions to get a feel for timing. Not just a toggle on/off as that may give an absolute speed, but would not be very representative of what you will get.

    An example test I ran was step through all 4096 values into a 12bit mdac to put out a ramp function. In spin it took multiple seconds to run from 0 to 4096. In PASM, the same ramp would take about 18 mS. So maybe it would make better sense to evaluate whether the chip specs can deliver on the project.

    FF
  • turbosupraturbosupra Posts: 1,088
    edited 2012-05-27 20:44
    <-- Hit the speed limiter on a Honda :)

    I've toggled a pin at 9000hz, so on for 4444 clk cycles and off for 4444 clk cycles, for my automotive project. (15k rpm) This was in PASM and spin, although with spin I had nothing else in the loop besides the pin toggle code, because it is so much slower. If you can spare a dedicated cog to spin, this will be fine. If you have other stuff going on, PASM is the way to go IMO.



    I am getting mixed answers in my searching so I figured I would ask my question directly. Irregardless of what the propeller can do as far as speed of toggling a pin, in most uses of a propeller, what is the fastest you would toggle an IO pin? For example, I know my Honda is spec'd to do 110mph, but I never need to go over 75.

    I also need to answer the same question for a BASIC Stamp because my project ties into both.
  • Cluso99Cluso99 Posts: 18,066
    edited 2012-05-27 21:00
    The counters can toggle at clock speed, so an 80MHz clock can toggle at 80MHz. Using the internal PLL in the video counter can toggle faster - IIRC up to 2x clock speed. PASM can do clock/8 (2 sets of 4 clocks for 2 instructions but of course will top out when you need a jump instruction. Spin is much slower, typically ~50 pasm instructions per spin simple instruction.

    FYI: FUllDUplexSerial will run at 115,200 quite happily - some have run it faster IIRC. That is 115,200 bits per second.
  • RDL2004RDL2004 Posts: 2,554
    edited 2012-05-27 21:12
    I tried toggling a pin on a plain old BS2 and got 1.19 kHz out.
  • SRLMSRLM Posts: 5,045
    edited 2012-05-27 21:17
    I don't think the question is asking for the fastest possible speed, but the fastest speed that most code runs at. I.e., if you averaged the maximum speed of I/O toggling of every object in the Obex, what would that speed be?
  • WBA ConsultingWBA Consulting Posts: 2,933
    edited 2012-05-27 21:54
    Some very good answers and details to help me along, but SRLM is correct as I am trying to determine if a 30mhz limit on IO pins would limit the propeller's functionality.
    I was at the conclusion that toggling a propeller pin at 80mhz was possible, but why would you need to? A better way to ask my question is probably: If you can't toggle a pin over 30mhz, what can the propeller NOT do that most propeller users would be doing. If I hand you a propeller board that cannot go faster than 30mhz on an IO pin, could you still use it?

    Rdl2004: thanks, I was figuring the stamp would be way under my 30mhz breakpoint.
  • kwinnkwinn Posts: 8,697
    edited 2012-05-27 23:39
    For mechanical systems the fastest I need to toggle a pin for would be a 20,000 rpm bldc motor (3 phases/windings) which is 1 KHz. For data acquisition more than 1MHz is rarely needed. Fastest ever was 96MHz for acquiring data from a PMT but that was done in hardware.
  • jmgjmg Posts: 15,140
    edited 2012-05-28 00:21
    Some very good answers and details to help me along, but SRLM is correct as I am trying to determine if a 30mhz limit on IO pins would limit the propeller's functionality.
    I was at the conclusion that toggling a propeller pin at 80mhz was possible, but why would you need to? A better way to ask my question is probably: If you can't toggle a pin over 30mhz, what can the propeller NOT do that most propeller users would be doing. If I hand you a propeller board that cannot go faster than 30mhz on an IO pin, could you still use it?

    Only for some things - remember the Prop can also resolve any pin edge to 12.5ns, so any Bandwidth limit restricts the corner cases on both generate, and sync.

    A better question is, what drives the need to limit a pin BW to 30MHz ?
  • AribaAriba Posts: 2,682
    edited 2012-05-28 04:49
    Some very good answers and details to help me along, but SRLM is correct as I am trying to determine if a 30mhz limit on IO pins would limit the propeller's functionality.
    I was at the conclusion that toggling a propeller pin at 80mhz was possible, but why would you need to? A better way to ask my question is probably: If you can't toggle a pin over 30mhz, what can the propeller NOT do that most propeller users would be doing. If I hand you a propeller board that cannot go faster than 30mhz on an IO pin, could you still use it?

    Rdl2004: thanks, I was figuring the stamp would be way under my 30mhz breakpoint.

    With a 30 MHz limit you can not do SigmaDelta ADC and DutyPWM output. If Duty not works then for example all the sound object that use DUTY mode for DACs will not work well.

    With 30 mhz (=0.03 Hz) you can not do much more than blinking a LED very slow.

    Andy
  • Mark_TMark_T Posts: 1,981
    edited 2012-05-28 07:42
    kwinn wrote: »
    For mechanical systems the fastest I need to toggle a pin for would be a 20,000 rpm bldc motor (3 phases/windings) which is 1 KHz. For data acquisition more than 1MHz is rarely needed. Fastest ever was 96MHz for acquiring data from a PMT but that was done in hardware.

    Rather off topic but a BLDC motor at 20,000 rpm the frequency depends on the number of magnet pole pairs, not the number of windings, each winding sees one cycle per pole-pair. I've some brushless BLDCs with 7 pole pairs so the windings would run at 2.33kHz for 20,000rpm, but the time step between each phase switching would be 1/6 of that period, i.e. 71.4us - in the PASM range clearly.

    Pet peeve for previous posters: mhz ?? KHz ?? really?? Those mean 0.1 'z' and 1024 hertz respectively (m = milli = x0.001, h = hect = x100, K = x1024 (not SI) hertz is abbreviated Hz not hz)
  • WBA ConsultingWBA Consulting Posts: 2,933
    edited 2012-05-28 12:53
    jmg wrote: »
    A better question is, what drives the need to limit a pin BW to 30MHz ?
    I am working on a propeller pcb design that will have another chip between the prop and the io pin. The particular chip I am currently looking at has a switching limit of 30mhz (megahertz) ;-)
  • jmgjmg Posts: 15,140
    edited 2012-05-28 14:10
    I am working on a propeller pcb design that will have another chip between the prop and the io pin. The particular chip I am currently looking at has a switching limit of 30mhz (megahertz) ;-)

    So there must be some as yet unstated benefit of that chip, and it presumably does not go between ALL Prop Pins, and the real world ?
    Dedicated IO functions are fine, provided users still have some choice.
    Plenty of designs have RS232 chips, or Darlington Arrays on some of their pins.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-05-28 15:05
    I am working on a propeller pcb design that will have another chip between the prop and the io pin.
    What is the other chip, and what is it's purpose? We could help you better if you were less coy about your intentions. :)

    -Phil
  • WBA ConsultingWBA Consulting Posts: 2,933
    edited 2012-05-28 21:00
    Phil, et al,
    My apologies, but there are many caveats to the design that are as yet undisclosed purposely, so forgive my attempts to get detailed answers from a non-detailed question. After more thought and an email from someone who has some knowledge of the design, I have been able to confirm that the 30mhz limit will pose minimal issues for my design's main intent. The secondary intent of the design will only have concerns among 10-20% of those users, so overall, less than 5% of my target market will be saddened by the limit.
  • WBA ConsultingWBA Consulting Posts: 2,933
    edited 2012-08-31 19:26
    Update: I have my design in prototype stage and I am trying to "break it". For more detail, I am using voltage translators with the prop that are rated at 60Mbps (TXS0108E). I am trying to get the prop to surpass that by using PASM and counters to toggle a pin. Earlier in this thread it is mentioned that 10Mhz should be possible in PASM. The best I can get is 6.684Mhz (on my board and my PropBOE.

    Can anyone tell me why my PASM code is not faster than that? I am using a modified version of Jonnymac's JM_Blinker code. I still need to dig deeper into counters to try to get to 40Mhz as reported being possible.
    '' =================================================================================================
    ''
    ''   File....... jm_blinker.spin
    ''   Purpose.... PASM LED blinker
    ''   Author..... Jon "JonnyMac" McPhalen              
    ''   E-mail..... jon@jonmcphalen.com
    ''   Started.... 
    ''   Updated....  Andrew Wiliams, PASM Toggle Speed
    ''
    '' =================================================================================================
    
    CON
      _clkmode  = xtal1+pll16x
      _clkfreq  = 80_000_000
      
    var
    
      long  blinkpin                                                ' pin used by blinker cog
    
    pub start
    
      blinkpin := 5
      result := cognew(@blinker, @blinkpin)                  ' start blinker cog
    
    dat
    
                            org     0
    
    blinker                 mov     t1, par                         ' start of structure
                            rdlong  t2, t1                          ' read blink pin
                            mov     pinmask, #1                     ' create mask from pin #
                            shl     pinmask, t2
                            mov     dira, pinmask                   ' make pin an output
                      
    bloop                   andn    outa, pinmask                   ' pin off
                            or      outa, pinmask                   ' pin on
                            jmp     #bloop                          ' loop forever
                              
    ' --------------------------------------------------------------------------------------------------
    
    pinmask                 res     1                               ' mask for blinker pin
    ontix                   res     1                               ' on timing in system ticks
    offtix                  res     1                               ' off timing in system ticks
    timer                   res     1
    
    t1                      res     1
    t2                      res     1
    
    
    dat
    
    {{
    
      Terms of Use: MIT License
    
      Permission is hereby granted, free of charge, to any person obtaining a copy of this
      software and associated documentation files (the "Software"), to deal in the Software
      without restriction, including without limitation the rights to use, copy, modify,
      merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
      permit persons to whom the Software is furnished to do so, subject to the following
      conditions:
    
      The above copyright notice and this permission notice shall be included in all copies
      or substantial portions of the Software.
    
      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
      INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
      PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
      HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
      CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
      OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    
    }}  
    
    
  • jmgjmg Posts: 15,140
    edited 2012-08-31 19:38
    Earlier in this thread it is mentioned that 10Mhz should be possible in PASM. The best I can get is 6.684Mhz (on my board and my PropBOE.

    Can anyone tell me why my PASM code is not faster than that?

    It depends on semantics - you have a Set/Clr/Jmp, in a 3 op code loop. You have one Pin-cycle per loop (not 50% duty), so 6.6666' MHz is the result.
    You can do a XOR+JMP and now the loop runs at 10MHz, but a 10MHz toggle is a 5MHz pin frequency.

    Or you can unroll the loop and chain XOR, for a 20MHz toggle burst, or a 10MHz pin frequency burst, for tests.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2012-08-31 20:27
    In Tachyon a normal bit-bashed SET and CLR will generate a 178.6kHz frequency but if I use the OUTCLK which toggles a pin I can get 416.7kHz.
    #11 MASK BEGIN DUP OUTSET DUP OUTCLR AGAIN
    #11 MASK DUP OUTSET BEGIN OUTCLK AGAIN
  • WBA ConsultingWBA Consulting Posts: 2,933
    edited 2012-08-31 21:02
    Well that's just too easy. I updated to the XOR+JMP and now it's 5MHz for a full pin toggle cycle which makes sense to me now. Now I am off to messing with counters to get to the next level......
  • kuronekokuroneko Posts: 3,623
    edited 2012-08-31 23:37
    Have a look at [thread=133741]clkfreq/2n[/thread] for more hand-made (non-counter) stuff.
  • WBA ConsultingWBA Consulting Posts: 2,933
    edited 2012-08-31 23:39
    And lastly, I figured out counter setup (well, actually, I found ctr.spin in the propeller library which gave me the final answer) and now have 60Mhz coming from a propeller pin through my 5v translator. The translator output starts getting unstable around 72MHz, but since it is spec'd at 60MHz, I think I can live with pushing the spec to 120%.

    Thanks to all or the help. I am going to change the thread to solved.
Sign In or Register to comment.