Shop OBEX P1 Docs P2 Docs Learn Events
Counter Issues — Parallax Forums

Counter Issues

DrranchDrranch Posts: 2
edited 2009-03-13 15:17 in Propeller 1
I have a project I'm working on where I need to toggle 12 outputs to signal events based on a single trigger and encoder feedback. So that's 2 inputs and 12 outputs....for now. I have the chance that I may need 5 counters (keeping track of a products position within my module) at one time so I was thinking dedicate 5 seprate cogs for this. My attatched code is for only 5 outputs right now but you get the idea I had in mind. only problem is I am loosing encoder counts past about 15kHz. For my application I'm going to be around 125kHz. Is there a more efficient way of organizing my code? I know the propeller is capable of this which leads me to believe it's solely my organization in the code. Any help/ideas are very welcome.

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2009-03-10 18:41
    It's because you use spin. Spin is interpreted and needs a lot of clock-cycles to do it's job.
    First of all loading the spin interpreter takes some time where you already could miss encoder signals. Next is the runtime of the spin commands. Often they need roundabout 1000 cycles. So, before you're done with setting the CTRA, the FREQA and the PHSA the encoder already toggled. In the repeat loop you miss the next encoder toggles.

    Maybe it's enough to do the cognew in advance and already prepare the counter to do it's job. But my guess is : NO, that's not enough. (Have to guess cause I'm new in propeller programming ;o)

    As the code itself is not to complex it is easy to be written in PASM.
  • DrranchDrranch Posts: 2
    edited 2009-03-13 15:17
    I was afraid of that. it's been probably 4 years since I have done anything with assembly language. Looks like I will have to do a major crash course and see the best way to attack this with pasm
Sign In or Register to comment.