Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

#16
April 25th, 2012, 03:30 AM
 SimonB2
Contributing User

Join Date: Apr 2008
Posts: 249
Time spent in forums: 3 Days 17 h 55 m 47 sec
Reputation Power: 110
That's okay, you're welcome.

I REALLY wish you would start using code-tags! This is the last message I will repond to of yours that includes code and doesn't doesn't use code-tags.
Again, for reference: click "Go Advanced button", paste code snippet, highlight with mouse, click button with # symbol on it.

EDIT:
Alternately, type "[ code ]" before the code, followed by "[ /code ]" after the code block. (remove spaces and " chars)
/EDIT

I don't know what the device is you're putting this code into, nor do I know it's application. You may well find that the error introduced by an (integer) division here will be greater than the error introduced if 11.7ns is rounded-up to 12ns.

E.g
D1=6, D2=7, D3=7
Dtotal = 6+7+7 = 20
Daverage = 20 / 3 = 6 (remainder 2) I.e Daverage is actually 6.667

Therefore, you have an error here of (6.77-6) / 6.77 = 10%

Rounding 11.7ns up to 12ns gives an error of (12-11.7) / 11.7 = 2.5%

Perhaps you would benefit from using a fixed-point library? Assuming 32bit ints, you can represent any number from 0-65535, in increments of 0.0000152590

Also, for what it's worth - a CISC(complex instruction set) cpu without pipelining running at 1Ghz can execute no more than 1 instruction per ns. It's entirely possible that the amount of time required to perform 'ideal' calculations is greater than the error introduced by approximating the transmission interval.

It's food for thought anyway.

EDIT: Editor changed my escaped sequences for [ and ]

Last edited by SimonB2 : April 25th, 2012 at 03:44 AM.

 Viewing: Dev Shed Forums > Programming Languages > C Programming > Packet distribution interval: