Shop OBEX P1 Docs P2 Docs Learn Events
can somebody explain the acronyms FRQx and PHSx ? — Parallax Forums

can somebody explain the acronyms FRQx and PHSx ?

StefanL38StefanL38 Posts: 2,292
edited 2011-10-10 10:00 in Propeller 1
Hi,

I'm back on learning more details about the counters.
I know the function of FQRx and PHSx. But what does the acronyms stand for?

Is FQRx the short name for FR)eQ)ency?

What is the long name of PHS?
It's surely not P)auls H)ot S)ausage

But what does it stand for?? Maybe it makes sense. But in the docs I've read everywhere was just
the acronym.

The prop is five years old now. So its much to late to change the acronyms.
But usually acronyms make sense like JMP for jump SHR for SH)ift bits R)ight etc.

So whats the meaning of the TLA (three letter acronym) FQR and PHS?

best regards

Stefan

Comments

  • JasonDorieJasonDorie Posts: 1,930
    edited 2011-10-09 10:39
    FReQuency and PHaSe.
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-10-09 10:50
    Thanks Jason,

    so to me these acronyms don't make much sense.
    I'm sure somehow the FRQ-registers determine frequencies and somehow PHS determines a "Phase".
    But what it directly does is the FRQ-registers contains a summand

    The PHS-register contains the actual accumulated sum which summarised by adding value of FRQ to PHS.

    It won't change names in the docs - but anyway - I want to make a suggestion for better names:

    increment-summand for FRQ and a short name could be Inc-Sx

    total-sum for PHS and a shortname could be TSUMx

    Now please write arguments against these new names and explain why the old names describe things better.
    I hope this discussion will make it more understandable why the names FRQ and PHS are chosen

    best regards

    Stefan
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-10-09 11:16
    The original names are both accurate and descriptive of their use. The frqx registers define the rate at which the phase changes, the same way that f in the following equation defines the rate at which the phase changes:
    phase(t) = sin(2 π f t)

    And phsx really is a phase in this context, since its contents specify the counter's state at any particular time.

    -Phil
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-10-09 11:20
    I think the current naming makes sense in this way:

    What happens, if you increase FRQ?
    The sum will overflow faster! And as the MSB or the overflow (depending on the setup of the counter) will drive the output, in fact the frequency increases. So, the frequency of the output is proportional to the value in FRQ.

    What happens, if you change PHS?
    Let's say we set a trigger pin to 0 and then set PHS to 0 (keeping the FRQ constant). FRQ determines how long it takes until the counter output changes to 1.
    Now we set the trigger pin to 1 and then set the PHS to a value bigger than 0. What happens to the counter output? It's changing earlier than before. So, what did we change by putting a higher start-value into PHS? Right ... the phase.

    So, for me the current naming makes perfect sense.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2011-10-09 15:46
    The commonly used idea of frequency is in terms of events or full cycles per second. A full cycle can be expressed in different ways, in different units, for example, two pi radians, or 360 degrees, or 256 brads, or in the case of the Prop, 4294967296 counts. Phase is how far along the dial is around the circle. Halfway around the circle is pi radians, 180 degrees, or for the Prop, 2147483648 counts. In NCO mode, the propeller the associated output pin will be low for counts 0 to 2147483647 and high for the 2147483648 to 4294967296. That is what you expect. The resolution of phase in PHSx on the Prop is very fine!

    The rate it moves around the circle is set by the FRQx. It is like expressing frequency as radians per second or degrees per second. In simple NCO or DUTY modes, the FRQx value is added once per clock cycle, e.g. 80 million times per second. If you divide the number of counts in a circle by the FRQx value, is how many iterations it takes for dial to make one complete cycle. For example if FRQx = 50000 then 50000 has to be added to itself 85899 times to get all the way through the phase accumulator. Then there is the time it takes. At 80MHz, the addition is done once every 12.5 nanoseconds, and is 85899 * 12.5 ns = 0.0010737375 second. That is the period and corresponds to a frequency of 931 Hz. The output pin will go low and high at close to 931 Hz. (I say close to, not exactly, because there are some remainders from the division).

    Given a desired frequency Fx in Hz for complete cycles, calculate the required incremental frequency FRQx thus
    FRQx = Fx * 4294967296 / clkfreq

    If you want to preset the phase PHSx to some value expressed in degrees, then
    PHSx = degrees * 4294967296 / 360
  • AribaAriba Posts: 2,690
    edited 2011-10-09 16:37
    @Stefan
    Someone you maybe know, has asked this more than a year ago, and my explication was very similar to Tracy Allens:

    http://forums.parallax.com/showthread.php?118836

    :smile:

    Andy
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-10-09 16:45
    That's an interesting explanation Tracy (and I guess Andy - haven't looked at yours yet). I understand PHSx but have always viewed if from a full frequency cycle, not from a circles perspective.
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-10-10 09:35
    @Andy,

    please can you explain who is StefanL38 to me icon7.pngicon7.png?

    I forgot that completely. I wouldn't have asked if I would have remembered it.
    Is this beginning Alzheimer? Hope not.

    Thank you anyway for re-programming my memory. Got to repeat it 10-20 times now to get into the longterm memory.

    best regards

    Stefan
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-10-10 09:47
    Stefan,

    Don't feel bad. I've done that more than once myself. The best part of having an imperfect memory is the constant exhilaration of new discoveries!

    -Phil
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2011-10-10 10:00
    That's very funny! It must bear repeating, in many languages, and I believe the counter modes and methods are worth their space in the gray matter of serious prop-heads.
Sign In or Register to comment.