Using a Frequency meter?
rwgast_logicdesign
Posts: 1,464
Ok so I started reading through the BOE pdf file tonight. Im doing the exercise for flashing an LED @1Hz. I just got this new meter that has a
a cheapy 1mhz frequency counter built in. I set the probes up in parallel and Im totally not getting the results on the meters display that I
excpected! Then I took the ground probe off and got .998 which is pretty close to 1hz. So when you measure frequency your only suppose to use
the hot probe? Aslo is the little bit of error i.e. .998 not 1Hz due to the meter or the crystals ppm being a bit off? Here is the code
a cheapy 1mhz frequency counter built in. I set the probes up in parallel and Im totally not getting the results on the meters display that I
excpected! Then I took the ground probe off and got .998 which is pretty close to 1hz. So when you measure frequency your only suppose to use
the hot probe? Aslo is the little bit of error i.e. .998 not 1Hz due to the meter or the crystals ppm being a bit off? Here is the code
CON _xinfreq = 5_000_000 _clkmode = xtal1 + pll1x PUB flashAt1Hz dira[0] := 1 repeat outa[0] := 1 waitcnt(clkfreq/4 + cnt) '' Turn LED on for 1/4 second outa[0] := 0 waitcnt(clkfreq/4*3 + cnt) '' Turn LED off for 3/4 second
Comments
It may be expecting a +/- signal, try a series CAP, or create a 1/2 VCC virtual ground.
Also check the Meter's spec, the very basic ones, can be as bad as 1.5% precision on Frequency.
Your result is 0.2%; too large for a Crystal deviation.
A 'proper' meter, will easily deliver single digit ppm and 7-8+ digits per second.
In your original code, the time required to compute the waitcnt argument and to set the outputs was added to the period. The new code eliminates that overhead by including it the timed period.
-Phil
Your meter is picking it up "from the air". Or it is getting in due improper grounding.
basically your saying cnt=cnt + clckfreq which is what im assuming is the true fix. so if cnt was at 40,000 now its at 80,000 plus the freqency. this is somehow accounting for clockcycles which have already passed during the code execution? im sry could you please be a little more verbose about whats going on. dealing with clockcycles on this level is a very new concept to me and one which i know i need to get a very good grasp on if i want to write the kind of software i aspire to write for the prop.
by the way im sry if the above post sounded a little rude or something, this meter is just frustrating me and theres no manual! im having a hell of a time understanding why it gave the correct results the first time and then went off and gave me something totally diffrent under the same conditions..
PUB flashAt1Hz | time ?
The '|' separates the function name from the list of local variables ('time' is a local variable, only accessible to this function). This is from the Propeller Manual v1.1 (page 208):
1) Local variable separator: appears immediately before a list of local variables on a PUB or PRI declaration. See PUB, page 182 and PRI, page 181.
2) Bitwise OR: used in expressions. See Bitwise OR |, |= on page 165.
so then exactly why double cnt before the division? like i said i understand it is somehow making up for the clock cycles lost during the function but exactly how a perfect cnt+cnt is needed is kind of an enigma to me. my best guess would be is that it takes two full hub passes to complete the function becuase theres two operations, but thats an assumption im very unsure of, since theres no hub communication going on here.
-Phil
-Phil