0
gus

Techy problem: is this possible?

Recommended Posts

I know we've got some techy bods around here so I thought I'd share this problem with you all and let you show off your intelligence - it's been hurting my head trying to figure it out!

EDIT: There's a better explanation a few posts down.

(1) I have a counter, which increments every 27 microseconds.
(2) I'm receiving frames of data, one every 125 microseconds.
(3) Each frame contains the value of the counter at the instant the frame was produced.

OK then! If, for some reason, I miss some frames can I work out exactly how many I've missed by comparing the counter value of the current frame with the counter value of the last frame I received???

Ta!

Gus
OutpatientsOnline.com

Share this post


Link to post
Share on other sites
in what context are these values generated? i am assuming video. and do you mean milliseconds? never heard of a microsecond. this would be a trivial calculation, but by hand could become tedious. are you running windows? if so, elaborate on your problem and i will write you a calculator. is a text log being generated? if so, we can automate this.
namaste, motherfucker.

Share this post


Link to post
Share on other sites
I probably do mean milliseconds but it doesn't really matter, it's the 27:125 ratio that's important.

Quote

this would be a trivial calculation



I'm not so sure. Each value of the counter represents a chunk of time 27 milliseconds long and if you don't know where in that chunk your frame was created I think the answer to "how many frames have I missed" can be ambiguous. I'm trying to think of an example but it's a problem of the counter and the frames not being in synch. If the counter incremented every 25 milliseconds we'd be laughing...

Gus
OutpatientsOnline.com

Share this post


Link to post
Share on other sites
Hmm not video then, 25fps means each frame is 40 milliseconds long, or each field is 20 milliseconds long......whatchoo talkin' bout then?
--------------------

He who receives an idea from me, receives instruction himself without lessening mine; as he who lights his taper at mine, receives light without darkening me. Thomas Jefferson

Share this post


Link to post
Share on other sites
Is there an application for this? or is this just a math problem?

Because so far, I have
current - last / 4.629 rounded - 1 = number missed

However, because of the odd number (27/125) I'm sure there's a case, if you miss enough frames, that it won't hold true anymore.
it's like incest - you're substituting convenience for quality

Share this post


Link to post
Share on other sites
Quote

microsecond
One millionth (10^-6) of a second
--



amzing the holes we can have in our knowledge bases. I have been writing code for over 20 years and have only every found relevant milli and nano. wonder why?
namaste, motherfucker.

Share this post


Link to post
Share on other sites
Ok, I have a good analogy:

(1) A guy walks into a room with a clock on the wall, he sits down, pulls out a piece of paper, writes a 0 on it and starts to watch the clock. Every 27 seconds he tears up his bit of paper, adds 1 to the number he's just destroyed and writes it on a new bit of paper.

(2) Some time later a second guy walks into the room and sits down. He looks at what's written on the 1st guy's bit of paper, writes it down on another bit of paper, puts it aside and starts watching the clock. Every 125 seconds he repeats this process (creating a pile of paper) - sometimes the 1st guy's counter has gone up by 4, sometimes by 5.

(3) You're sat next to the 2nd guy but can't see the 1st guy, his bit of paper or the clock on the wall. If you took out a wedge of paper from the 2nd guy's pile, could you work out how many bits there were there by looking at the top and bottom pieces only?

Gus
OutpatientsOnline.com

Share this post


Link to post
Share on other sites
Quote

Is there an application for this? or is this just a math problem?

Because so far, I have
current - last / 4.629 rounded - 1 = number missed

However, because of the odd number (27/125) I'm sure there's a case, if you miss enough frames, that it won't hold true anymore.



depends whether gus wants to keep a running log to respond to sync errors or simply wants an end report.
namaste, motherfucker.

Share this post


Link to post
Share on other sites
Quote

Is there an application for this? or is this just a math problem?



It's just a boring work thing (think packets/frames/networks) but it's really bugging me. :S

Quote

Because so far, I have
current - last / 4.629 rounded - 1 = number missed



That's where I'm at. :)
Quote

However, because of the odd number (27/125) I'm sure there's a case, if you miss enough frames, that it won't hold true anymore.



This is exactly what I'm talking about. So is it possible or am I just wasting my time? [For "my time" please read "my employer's/customer's" time.]

Gus
OutpatientsOnline.com

Share this post


Link to post
Share on other sites
Quote

I have been writing code for over 20 years and have only every found relevant milli and nano. wonder why?



Obviously you don't work on the shuttle software :)
We use them (that would be microseconds) all the time, for modules that have critical timing requirements. In fact, when we compile, the disassembled output (included for analysis) includes the number of milliseconds for each instruction. The software is cyclic in nature, and overrunning a cycle is a big deal :(

And if that isn't TMI, I don't know what is :)

Wendy W.
There is nothing more dangerous than breaking a basic safety rule and getting away with it. It removes fear of the consequences and builds false confidence. (tbrown)

Share this post


Link to post
Share on other sites
Quote

This is exactly what I'm talking about. So is it possible or am I just wasting my time? [For "my time" please read "my employer's/customer's" time.]


So "close enough" and "probably right" won't work in this case? :D
it's like incest - you're substituting convenience for quality

Share this post


Link to post
Share on other sites
Quote

Damn you and your crazy Jedei mind (:o), for the sake of my sanity let's assume the clock's ok.

Gus



Well yes, but you have to also consider the CACHING time (when the System writes data to the HD) and CPU speed, I used to do a lot of programming, and I encountered similar situations, so, good luck :P
__________________________________________
Blue Skies and May the Force be with you.

Share this post


Link to post
Share on other sites
> . . . can I work out exactly how many I've missed by
> comparing the counter value of the current frame with the counter
> value of the last frame I received???

Yes, up to a limit. You will see either a 4 or a 5 count between each frame, so until you get to 5 skipped frames you can figure it out with no problem. You might be able to go longer by using remainders to predict the state of the counter at the beginning of each frame, but timebase problems (and basic sampling problems) limit the accuracy of that approach, unless you assume both frames and counter clocks are synchronous to the same clock.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

0