How many hours has my Prop been running?
mosquito56
Posts: 387
·I am looking for a way to keep track of how long the prop is running in real time. Is there a way to intercept the cnt rollover? I read that if you miss a cnt you might have to wait over a minute. This is perfect for my purposes.
· I don't want to tie up a cog to do this. Any ideas?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
······· "What do you mean, it doesn't have any tubes?"
······· "No such thing as a dumb question" unless it's on the internet
Technologically challenged individual, Please have pity.
Post Edited (mosquito56) : 1/20/2008 5:46:42 AM GMT
· I don't want to tie up a cog to do this. Any ideas?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
······· "What do you mean, it doesn't have any tubes?"
······· "No such thing as a dumb question" unless it's on the internet
Technologically challenged individual, Please have pity.
Post Edited (mosquito56) : 1/20/2008 5:46:42 AM GMT
Comments
-Phil
Addendum: BTW, the correct way to read the counters is to read the most-significant counter (MSC) first, then the least signficant counter (LSC), then the MSC again. If the two readings of the MSC are different, repeat the process. This will catch any rollovers from the LSC during the reading process.
Post Edited (Phil Pilgrim (PhiPi)) : 1/17/2008 9:25:05 PM GMT
· Also, how do i catch that one pulse?
Addendum: BTW, the correct way to read the counters is to read the most-significant counter (MSC) first, then the least signficant counter (LSC), then the MSC again. If the two readings of the MSC are different, repeat the process. This will catch any rollovers from the LSC during the reading process.
Sorry, this is greek to me.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hmm, "What do you mean, it doesn't have any tubes?"
······· "No such thing as a dumb question" unless it's on the internet
········"What happens in Vegas ends up on the Internet"
Technologically challenged individual, Please have pity.
Take a digital watch, put your hand over the hours so you can only see the minutes; "59". Close your eyes, move your hand to uncover the hours and hide the minutes; "10".
Is the time now really "10:59" or in the intervening period when you had your eyes shut and moved you hand did the time roll over from "9:59" to "10:00" ?
You get the same problems if you read the hour first "10" and then read the minutes "00", is it now "10:00" or "11:00" ?
The hour is the most-significant counter, the minutes is the least-significant counter in this case. Hence, read the hour, read the minutes, read the hour again, repeat if the hour has changed. That solves the roll-over problem.
the light bulb went on, I don't have to code the ctrb, it does it automatically in pos detect mode.
thanx guys
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hmm, "What do you mean, it doesn't have any tubes?"
······· "No such thing as a dumb question" unless it's on the internet
········"What happens in Vegas ends up on the Internet"
Technologically challenged individual, Please have pity.
ctra[noparse][[/noparse]30..26] := %00110 ' Set mode to "counter mode"
ctra[noparse][[/noparse]5..0] := 0 ' Set APIN to unused pin (P0)
frqa := 1
dira[noparse][[/noparse]0]:=0 'set pin 0 to input
ctrb[noparse][[/noparse]30..26]:=%01000 'set ctrb to pos detect
ctrb[noparse][[/noparse]5..0]:=0 ' set ctrb to detect pos on pin 0
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hmm, "What do you mean, it doesn't have any tubes?"
······· "No such thing as a dumb question" unless it's on the internet
········"What happens in Vegas ends up on the Internet"
Technologically challenged individual, Please have pity.
-Phil
ctra[noparse][[/noparse]30..26] := %00110·· ' Set mode to "counter mode"
ctra[noparse][[/noparse]5..0] := 0·············· ·' Set APIN to unused pin (P0)
frqa := 1
ctrb[noparse][[/noparse]30..26]:=%01000····· 'set ctrb to pos detect
ctrb[noparse][[/noparse]5..0]:=0
frqb:=1
dira[noparse][[/noparse]0]:=1······················· 'set to output and low
outa[noparse][[/noparse]0]:=0·
temp2:=ctrb[noparse][[/noparse]31..0]
·term.bin(ctrb,32)
·term.dec(ctrb)
term.dec(temp2)
term.bin(ctrb,32)
·term.out($0D)
everything prints 0's ctrb is not incrementing or i am not reading it correctly?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hmm, "What do you mean, it doesn't have any tubes?"
······· "No such thing as a dumb question" unless it's on the internet
········"What happens in Vegas ends up on the Internet"
Technologically challenged individual, Please have pity.
-Phil
deSilva: I wasn't aware (or didn't remember) that this had been brought up before. Can you post a link to Ariba's post? It's always helpful to link as much related info together as possible. Thx.
I print phsa and it's always around 68_000, phsb is always 0. I put in a delay and it is still the same. I just have everything in
pub start and read the values in my dataloop, still only 0's. A well what can I say. Thanx much for the help.
ctra[noparse][[/noparse]30..26] := %00110 ' Set mode to "counter mode"
ctra[noparse][[/noparse]5..0] := 0······· ' Set APIN to unused pin (P0)
frqa := 1
ctrb[noparse][[/noparse]30..26]:=%01000··· 'set ctrb to pos detect
ctrb[noparse][[/noparse]5..0]:=0
frqb:=1
dira[noparse][[/noparse]0]:=1
outa[noparse][[/noparse]0]:=0·············· 'set to ouput and set low
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hmm, "What do you mean, it doesn't have any tubes?"
······· "No such thing as a dumb question" unless it's on the internet
········"What happens in Vegas ends up on the Internet"
Technologically challenged individual, Please have pity.
In fact there could be older references, but this solution looked so "typically Ariba" to me, I was sure it was his idea...
Where are you putting your delay? The counters start counting from zero after they've been configured. Unless you're inserting your delay after this configuration, you will get the same reading every time; and the number you report seems about right.
-Phil
I setup the pins in start
I read the values in a repeat loop further down the same cog.
repeat
term.dec(phsb) that's it
term.dec(phsa) prints about 68_000 everytime.
I'm lost. This thing should be working .
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hmm, "What do you mean, it doesn't have any tubes?"
······· "No such thing as a dumb question" unless it's on the internet
········"What happens in Vegas ends up on the Internet"
Technologically challenged individual, Please have pity.
Can you list your entire program, please, from beginning to end? And put it in between [noparse][[/noparse]code] [noparse][[/noparse]/code] tags, if you would.
Thanks,
-Phil
PUB Start· |st, x,temp2
st:=" "
angle:=0
delaygen:=1
term.Start(31, 30)
ctra[noparse][[/noparse]30..26] := %00110 ' Set mode to "counter mode"
ctra[noparse][[/noparse]5..0] := 0······· ' Set APIN to unused pin (P0)
frqa := 1
ctrb[noparse][[/noparse]30..26]:=%01000··· 'set ctrb to pos detect
ctrb[noparse][[/noparse]5..0]:=0
frqb:=1
dira[noparse][[/noparse]0]:=1
outa[noparse][[/noparse]0]:=0···········
Pub· temps |tempss
repeat
·term.str(string("TI1"))
·term.dec(phsb)
·term.out($0D)
·term.bin(phsb,32) 'I HAD a pause here to try to change phsa but it didn't
·term.dec(phsa)
·waitcnt(clkfreq/10+cnt)
/code
·Don't know what code /code means sorry
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hmm, "What do you mean, it doesn't have any tubes?"
······· "No such thing as a dumb question" unless it's on the internet
········"What happens in Vegas ends up on the Internet"
Technologically challenged individual, Please have pity.
·If you paste code in the forum it has a bad habit of re-spacing it. I think the code tags are to prevent the forum software (running here) from re-spacing the code. Spacing is very important in Spin. It is considered syntax in Spin unlike some other languages. The spaces are operationally important.
I've never heard of the [noparse][[/noparse]code] [noparse][[/noparse]/code] tags, I've aways used the quote tags myself.
But someone smarter than I, can clarify better.
James L
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
James L
Partner/Designer
Lil Brother LLC (SMT Assembly Services)
Post Edited (James Long) : 1/18/2008 6:26:46 AM GMT
Please post all of your program, including the CON, OBJ, and VAR sections and the code that calls Start and temps. Put it between [noparse][[/noparse]code] and [noparse][[/noparse]/code] tags, as I indicated before. (You have to include the square brackets, just as I've shown here.) This will maintain your indentations. To make life easier, you can also copy and paste your code into my formatter here to reformat it for posting to the forum. As a further alternative, you could archive your entire program and attach it as a zip.
-Phil
Post Edited (Phil Pilgrim (PhiPi)) : 1/18/2008 6:55:28 AM GMT
·Thanx for all your help.
[noparse][[/noparse]code]
· [noparse][[/noparse]b]_xinfreq[noparse][[/noparse]/b]····· = 5_000_000
[noparse][[/noparse]b]PUB[noparse][[/noparse]/b] Start·
term.Start(31, 30)
[noparse][[/noparse]b]waitcnt[noparse][[/noparse]/b](clkfreq *2 + [noparse][[/noparse]b]cnt[noparse][[/noparse]/b])
[noparse][[/noparse]b]ctra[noparse][[/noparse]/b][30..26] := %00110 ' Set mode to "counter mode"
[noparse][[/noparse]b]ctra[noparse][[/noparse]/b][5..0] := 0······· ' Set APIN to unused pin (P0)
[noparse][[/noparse]b]frqa[noparse][[/noparse]/b] := 10
[noparse][[/noparse]b]ctrb[noparse][[/noparse]/b][30..26]:=%01000··· 'set ctrb to pos detect
[noparse][[/noparse]b]ctrb[noparse][[/noparse]/b][5..0]:=0
[noparse][[/noparse]b]frqb[noparse][[/noparse]/b]:=1
[noparse][[/noparse]b]dira[noparse][[/noparse]/b][0]:=1
[noparse][[/noparse]b]outa[noparse][[/noparse]/b][0]:=0·············· 'set to ouput and set low
temps
[noparse][[/noparse]b]Pub[noparse][[/noparse]/b]· temps
[noparse][[/noparse]b]repeat[noparse][[/noparse]/b]
· term.[noparse][[/noparse]b]str[noparse][[/noparse]/b]([noparse][[/noparse]b]string[noparse][[/noparse]/b]("[noparse][[/noparse]b]Phsb[noparse][[/noparse]/b] decimal..."))·········
· term.dec([noparse][[/noparse]b]phsb[noparse][[/noparse]/b])
· term.out($0D)
· term.[noparse][[/noparse]b]str[noparse][[/noparse]/b]([noparse][[/noparse]b]string[noparse][[/noparse]/b]("[noparse][[/noparse]b]Phsb[noparse][[/noparse]/b] binary..."))·········
· term.bin([noparse][[/noparse]b]phsb[noparse][[/noparse]/b],32)
· term.out($0D)
· term.[noparse][[/noparse]b]str[noparse][[/noparse]/b]([noparse][[/noparse]b]string[noparse][[/noparse]/b]("[noparse][[/noparse]b]Phsa[noparse][[/noparse]/b] decimal..."))·········
· term.dec([noparse][[/noparse]b]phsa[noparse][[/noparse]/b])
term.out($0D)
[noparse][[/noparse]b]waitcnt[noparse][[/noparse]/b](clkfreq/10+[noparse][[/noparse]b]cnt[noparse][[/noparse]/b])
·
[noparse][[/noparse]b]PUB[noparse][[/noparse]/b] dec(value, scaleBy) | i
'' Print a decimal number
· [noparse][[/noparse]b]if[noparse][[/noparse]/b] value < 0
··· -value
··· term.out("-")
· i := 1_000_000_000
· [noparse][[/noparse]b]repeat[noparse][[/noparse]/b] 10
··· [noparse][[/noparse]b]if[noparse][[/noparse]/b] i == scaleBy / 10
····· term.out(".")
····· [noparse][[/noparse]b]result[noparse][[/noparse]/b]~~
··· [noparse][[/noparse]b]if[noparse][[/noparse]/b] value => i
····· term.out(value / i + "0")
····· value //= i
····· [noparse][[/noparse]b]result[noparse][[/noparse]/b]~~
··· [noparse][[/noparse]b]elseif[noparse][[/noparse]/b] [noparse][[/noparse]b]result[noparse][[/noparse]/b] [noparse][[/noparse]b]or[noparse][[/noparse]/b] i == 1
····· term.out("0")
··· i /= 10
[noparse][[/noparse]/code]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hmm, "What do you mean, it doesn't have any tubes?"
······· "No such thing as a dumb question" unless it's on the internet
········"What happens in Vegas ends up on the Internet"
Technologically challenged individual, Please have pity.
I'm really perplexed that the forum software didn't handle your tags properly. I've never seen that happen before. So I'm going to copy and paste the program from your post here:
Ah, much better. Now I can see what's going on. More to come...
-Phil
-Phil
I will work on it tommorow.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hmm, "What do you mean, it doesn't have any tubes?"
······· "No such thing as a dumb question" unless it's on the internet
········"What happens in Vegas ends up on the Internet"
Technologically challenged individual, Please have pity.
Anyway, I've done some code modification that will permit you to ignore the reading in phsa and just read phsb, which will be in tenths of a second (with 99.975% accuracy ± crystal drift). ctra outputs pulses at 10Hz now, and ctrb counts them.
Here are the relevant code snippets:
-Phil
Post Edited (Phil Pilgrim (PhiPi)) : 1/18/2008 9:38:06 AM GMT
OUTA[noparse][[/noparse]0]:= 0
should be omitted from the code as redundant, and the comment
'Set mode to "counter" mode
is misleading (shoud read "Duty" mode), which isn't thus descriptive either, but would allow a better reference to the data sheet
-Phil
I wasn't sure if the boot program took care of all that. I wanted to make sure that it was low in case it was floating.
I was switching things back and forth, trying to figure it out so the comments weren't matching the codes. I.E.
says "counter" when acutally was duty or vice versa.
I put our code in a different cog. It prints fine with proterminal.
I call the subroutine from main and it returns weird stuff, "2716" now. prints about 4 times and locks up.
Call
·timer:=(phabget.starttimer)
·term.dec(timer)
Pub· starttimer [noparse]:p[/noparse]hsbrett
·· phsbrett:=phsb
{repeat
· ·term.dec(phsb)
·· term.out($0D)· "this works fine by itself
·· term.dec(phsa)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hmm, "What do you mean, it doesn't have any tubes?"
······· "No such thing as a dumb question" unless it's on the internet
········"What happens in Vegas ends up on the Internet"
Technologically challenged individual, Please have pity.
All I/O settings within a COG are ORed, so a ONE set by accident in OUTA would nullify all timer output ....
I read in one post that defining var with same name in both cogs can share a variable. I 've tried res but it won't take it in the lower cog when I use the same name. I tried referencing it from second cog with @timer1 but that doesn't work. Totally lost here. Thanx
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
······· "What do you mean, it doesn't have any tubes?"
······· "No such thing as a dumb question" unless it's on the internet
Technologically challenged individual, Please have pity.