Shop OBEX P1 Docs P2 Docs Learn Events
What to do with two counters? — Parallax Forums

What to do with two counters?

LoopyBytelooseLoopyByteloose Posts: 12,537
edited 2008-02-11 01:26 in Propeller 1
Obviously the Propeller has two very sophisticated counters on each of the 8 cogs. I have read, searched the web, and pondered. But I just seem to not be grasping the whole concept.

Why two? While I·understand that each has 32 funtional uses [noparse][[/noparse]even though some might be very obscure to me], I am wondering how the two work together.· It seems to me that might really empower me [noparse][[/noparse]and others] to fully·understand their creative uses.· After all, there seems to be a reason that two were provided.



▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
PLEASE CONSIDER the following:

Do you want a quickly operational black box solution or the knowledge included therein?······
···················· Tropically,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan

Comments

  • rjo_rjo_ Posts: 1,825
    edited 2008-02-04 14:49
    Well... to start with 32 different functions... and 2 counters that makes for 32^2 possible combinations for each cog.

    What can you do with it? Easier to discuss what you can't do with it.

    A simple example: you can watch for a positive going edge on one set of pins... and use that to change the output functions on a different set of pins.

    So, for example, you could change a PWM on one set of pins depending upon complex patterns detected on another set of pins.

    The counter architecture is probably the most powerful facility built into the Prop... it can be set up in Spin with a couple of lines of code and then operates with no further attention or processor time. And the counter architecture is why it irritates me so much when people try to compare the power of the Prop with other architectures. There is never a discussion of total signal bandwidths or actual machine instruction equivalents. A Prop dedicated solely to counter functions is a beast[noparse]:)[/noparse]

    Each counter is actually a very simple processor... taking the "dedicated RISC" concept to the absolute limit. If you look at it that way... the Prop actually has 24 processors built into it... and I'm still counting[noparse]:)[/noparse]

    Look at the education labs... they are fabulous.
  • rjo_rjo_ Posts: 1,825
    edited 2008-02-04 15:49
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2008-02-05 06:10
    Thanks, I'll take a look at DiSilva, but I presume that some of the 32 functions are less important than others.

    I just think that it would be helpful to have something in the way of tutorial show some practical uses for using a combination of the two. Forgive me, but merely saying that there are 32 x 2 choices adds to the cloud of complexity rather than leads the way to pragmatic design choices.

    There seems to be two conceptual subset - traditional rf modulation and digital modulation [noparse][[/noparse]inculding digital multiplexing] that create a tool kit of what the timer might do. For instance, I'd love to hear from Chip Gracy as to why he selected these 32 and what was left behind.

    I seem to feel that there is a main reason for two counters and then trivial secondary reasons. My suspicion is that originally·one counter was developed to generate video vertical and the other to generate video horizontal.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    PLEASE CONSIDER the following:

    Do you want a quickly operational black box solution or the knowledge included therein?······
    ···················· Tropically,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan

    Post Edited (Kramer) : 2/5/2008 7:49:44 AM GMT
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-05 11:00
    There is always a TIMER and a COUNTER application with timers... there is no specific selection of the PIN_A/PIN_B logical combinations, as they are "complete".

    The other modes are "common".

    The true "gimick" are the differential modes, which are considered "superfluous" in other controllers as they can be accomplished by external logic *)

    I should like very much to write a tutorial, as the timers/counters are much underestimated, as often remarked. I once called them the "work horses" of the Propeller. Not using them is like taking the ox rather than the tractor...


    *) However it can be tricky to do it glitch free smile.gif
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2008-02-05 11:12
    deSilva,
    I really do understand that these are the real powerhouse behind the Propeller's unique abilities. That's why I want to know more about using the two in tandem and - now that you mention it - more about the differential modes that other microprocessors leave out.

    Yes, the SX-48 is typical as it has 3 timers and counters, but no differential mode. It manages to somehow do video without them. So I am wondering what goodies the differential mode provides.

    Hopefully, any tutorial will have some working applications as concrete examples or maybe just progressive refinements of one application - like the video output.

    I really admire how easily you have understood the Propeller.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    PLEASE CONSIDER the following:

    Do you want a quickly operational black box solution or the knowledge included therein?······
    ···················· Tropically,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2008-02-05 13:48
    I did a very simple application where I used one counter as a pulse generator and the other to count the pulse generated, I could then make trains of pulses of specific lengths easily, even while doing other things.

    Graham
  • Steph LindsaySteph Lindsay Posts: 767
    edited 2008-02-06 19:25
    Kramer said...
    ...
    I just think that it would be helpful to have something in the way of tutorial show some practical uses for using a combination of the two. Forgive me, but merely saying that there are 32 x 2 choices adds to the cloud of complexity rather than leads the way to pragmatic design choices.

    ...

    There is some introductory material for using counters in·the PE Labs, including both counters in concert in one cog, have you read that?·The draft is·in this thread:

    http://forums.parallax.com/showthread.php?p=648967
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2008-02-07 07:01
    One point that I would like to clarify. Do all these Propeller counters work independently of the COG microprocessors CPU untii either requested to provide information or an event is triggered?

    This may sound obvious to you, but implies that hardware counter/timers has a big advantage over software counter/timers. For instance, the SX-48 has the hardware, while the SX-28 creates them in software. It seems to me that the SX-48 is actually somewhat primative parallel processing while the SX- 28 is mutiplexing.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    PLEASE CONSIDER the following:

    Do you want a quickly operational black box solution or the knowledge included therein?······
    ···················· Tropically,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-02-07 07:10
    The counters work independently. So your propeller can actually be doing 24 (8 cogs+16 timers) things at the same time
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-07 07:47
    There is a lot of information how the Propeller works, how to interface things to it, how to write assembly programs, how to propgram simple and more advanced things,.... in Andr
  • OzStampOzStamp Posts: 377
    edited 2008-02-07 08:29
    A useless non technical post.. sorry could not resist..

    I like that "Propgram it.."

    I concur... lets conquer it...

    Very true .. Andre's book is pretty comprehensive...
    cheers ron mel oz...
  • bufflerbuffler Posts: 22
    edited 2008-02-07 08:42
    Counters? Gee how about optical encoders? there are simple up/down interfaces.. . or A on one, B on t'other, calculate position and velocity for a bunch of axes, etc, etc.
    Don
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2008-02-07 13:29
    Thanks again di Siliva,
    I do have Andre's book and a Hydra board, so I should jump back into that. I let things go for a few months and repainted my home. So I am now getting back into things.

    Optical encoders are quite interesting, but I have yet to use them as there is an initial investment in motors with encoders. Speeds or power output can be very high. In some cases, you need to have brakes and/or cluthes on the motors as well. Steppers do nicely at reasonable speeds. If I had a factory of some sort, that would be great. But robots generally need 300 rpm or less at the wheel axel.

    Sometimes, I wish I had been born a machinist so I could take advantage of all this.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    PLEASE CONSIDER the following:

    Do you want a quickly operational black box solution or the knowledge included therein?······
    ···················· Tropically,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-07 20:51
    Encoders cost $3 or so now. They are the most terrific parts and will substitute many "analogue" inputs to microcontrollers I should say...
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2008-02-08 12:07
    I hadn't thought of them as attached to knobs for an user input interface. I was thinking mainly of them mounted to the backside of a high RPM motor. It would be interesting to have two of them attached to a joystick instead of potentiometers for high resolution. And, in some cases you could translated the rotary motion into linear measurement.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    PLEASE CONSIDER the following:

    Do you want a quickly operational black box solution or the knowledge included therein?······
    ···················· Tropically,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
  • RinksCustomsRinksCustoms Posts: 531
    edited 2008-02-11 01:26
    I was successful at reading three neg-coff thermisistors and one calibration pot with one cog & two counters.

    I know, woohoo!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    E3 = Thought

    http://folding.stanford.edu/·- Donating some CPU/GPU downtime just might lead to a cure for cancer! My team stats.
Sign In or Register to comment.