Thread: 60 hz timer

  1. #1
    Registered User
    Join Date
    Jul 2009
    Posts
    50

    60 hz timer

    Hi all, I've become quite frustrated with a problem and so I seek help from the powerful minds that congregate here.

    The main device I work on has a large COTS piece of hardware that operates, and sends us packets, at 60hz. We use these incoming packets as a timer for a large number of processes.

    Recently we developed a stripped down device for our customer that offers 75% capability at 20% of the price. One of the things to get cut was this hardware that sends us packets at 60hz.

    Because we no longer have a hardware timer I attempted to write a 60hz software timer(using QueryPerfromanceCounter() and the like). This works great on my desktop, unfortunately the machines in the device are both slower and running a lot of processes which causes the software timer to be slow by about 8 seconds per hour.

    So now I'm searching for cheap hardware solution. I know they exist, I just can't figure out the proper search phrase(I've been looking on and off for a bout a month). Does anybody know of a simple device that can output a signal to RS-232 at 60hz?

    Thanks!

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    At first glance I think you could take a power cord off an appliance like a toaster, strip the ends of the wires, and attach to a cat. The cat will meow 120 times per second (one meow for each of the positive/negative peaks of the AC waveform). Using a microphone, attach to an ADC and digitize, then process digitally to remove every other meow. The resulting meows will be at a frequency of 60 hz.

    EDIT: Ugh, I just realized that this may make your device too expensive, since shipping of a live cat is not cheap and food must be provided. Depending on which TI ADC you choose (you DO buy only TI components for DSP, right) that may be another added cost. Hmm. I'll try to think of something cheaper.
    Last edited by brewbuck; 01-19-2010 at 11:55 AM.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #3
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Okay, okay. Obviously I'm joking. The serious point I am obscuring with this stupidity is that the power itself will be at 60 hz (if you're American, at least) and you MAY be able to use this somehow.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  4. #4
    Registered User
    Join Date
    Jul 2009
    Posts
    50
    Quote Originally Posted by brewbuck View Post
    EDIT: Ugh, I just realized that this may make your device too expensive, since shipping of a live cat is not cheap and food must be provided. Depending on which TI ADC you choose (you DO buy only TI components for DSP, right) that may be another added cost. Hmm. I'll try to think of something cheaper.
    Not to mention, this will be used on an Army base, and those guys like to walk off with piece of the units. Probably wouldn't go over so well to have to keep replacing cats.

    (also, the smell...)

  5. #5
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    A serial port server perhaps?
    Here
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  6. #6
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638
    meow! love it. the link brewbuck put up send packets at 802.11gb not 60 hz. something more like a 555 timer chip would give you 60 hz. connect it to the clk pin on your rs232.

    a meowtrakngome
    Last edited by kryptkat; 01-19-2010 at 02:31 PM.

  7. #7
    Registered User
    Join Date
    Jul 2009
    Posts
    50
    Quote Originally Posted by kryptkat View Post
    something more like a 555 timer chip would give you 60 hz. connect it to the clk pin on your rs232.

    This is closer to what I was looking for, although I doubt the management would like the idea of building this in house(They would much rather buy COTS or sub-contract). Any chance there's an existing product using these?

  8. #8
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    This is why I love programming.

    The 555 is a good way to go if your power is not guaranteed to be 60hz (but if military and using oseas power lines they tend to be 50hz; I had serious problems in Germany in the 80s w/systems that derived clock from power). And the 555 is both harder to walk off with and cheaper than a cat.
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  9. #9
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    Or just run it through a comparator (the other terminal to ground). Why would you need to sub-contract someone for that?

  10. #10
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    Come to think of it, 555 is probably a better idea.

    Only needs DC (just draw it from any of the internal power supply lines).

  11. #11
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    But this should be doable in software.

    You can make it "self-correcting".

    After each wait, subtract the extra time from the next wait.

  12. #12
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638
    And the 555 is both harder to walk off with and cheaper than a cat.
    hey ! i am a parsh kitten.

    Come to think of it, 555 is probably a better idea.
    thank you.
    you should be able to run it off of your computers +5v power supply. do not remember if rs232 has a pos +5v line or not. one thing you may run in to is power leveling <amps> or in this case micro amps. impedance match a must.

  13. #13
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Quote Originally Posted by kryptkat View Post
    meow! love it. the link brewbuck put up send packets at 802.11gb not 60 hz.
    Brewbuck didn't post that link. I did.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  14. #14
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638
    oops.

  15. #15
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    Problem with RS-232 is that it requires a negative voltage for low, and the port doesn't supply power. Since all the power supply lines in a computer probably have a common ground, you cannot just connect 2 together to get the negative voltage. Meaning you'll probably need to get power from outside, with your own transformer.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. hi-res vs. normal timer
    By MK27 in forum C Programming
    Replies: 0
    Last Post: 12-02-2009, 08:53 PM
  2. SIGALRM and timer
    By nkhambal in forum C Programming
    Replies: 1
    Last Post: 06-30-2008, 12:23 AM
  3. tic tac toe crashes :(
    By stien in forum Game Programming
    Replies: 4
    Last Post: 05-13-2007, 06:25 PM
  4. strcat - cannot convert char to const char
    By ulillillia in forum C Programming
    Replies: 14
    Last Post: 12-07-2006, 10:00 AM