What is the simplest way to get a second tick


Closed Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Oct 2006
    Location
    Cape Town SA
    Posts
    23

    Default What is the simplest way to get a second tick

    Hi, I'm making an ampere-hour meter to monitor battery consumption on an electric boat motor. I have the shuntderived mV measurement and A/D part sorted, now I just need to integrate amps with time. I have it working in a simple loop with a constant using 'pause' set to about 490mS, and it ticks over roughly every second and takes a reading. Is there a better way using a built in timer or perhaps an external 1 sec tick derived from a 32.768 xtal driving an interrupt, if you could point me to an example perhaps?

  2. #2
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: What is the simplest way to get a second tick

    Well it depends on what you mean by better. If it is working for you now with no issues, I would say you are done. If you want to start using the uP for more stuff, and timing is an issue, use an interrupt or DT_INT elasped timer to drive the ticks.

    Or for a somewhat middle of the road approach, you could set up a timer to free run, then poll that timers flag (ie: PIRx.x) in your main. when its set, gosub to update a counter. From there, if the count=time to take reading, take the reading and reset the counter. You can set this up with little trouble and it will be as accurate as the time between polling the flag. depending on your uP, using pre/post scalers and PR if available, it is not too hard to do.

    IMHO, adding external things does not make this easier at all.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  3. #3
    Join Date
    Mar 2011
    Location
    Los Angeles, California
    Posts
    322


    Did you find this post helpful? Yes | No

    Default Re: What is the simplest way to get a second tick

    This may be more than you are after and STMicroelectronics makes a series of RTC (Real Time Clock) chips such as the M41T62,63,64,65 and others that might be worth looking at as a way of know the exactly time if that is important?

    Best, Ed
    Last edited by Ramius; - 28th April 2011 at 12:27. Reason: Forgot the T in the part number

  4. #4
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default Re: What is the simplest way to get a second tick

    DS1307 has that feature.

    It gives you a tick at the interval you set.
    And it is a RTC.

    ___________
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  5. #5
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default Re: What is the simplest way to get a second tick

    And here : http://www.josepino.com/microcontrol...base_generator it's something interesting..."Update: The reason why this projects is not longer available is because you can buy a $1 USD clock and use the circuit as timebase"

  6. #6
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: What is the simplest way to get a second tick

    With all these valid replies for external components, I feel I should clarify my statement
    IMHO, adding external things does not make this easier at all.
    I do not meant to say adding any of the above is hard. Just that for this app, with what little explanation there is, twiddling bits seems the easiest approach.
    And for me, anytime I can leave a few parts off the board, life got a little bit easier.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  7. #7
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default Re: What is the simplest way to get a second tick

    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  8. #8
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default Re: What is the simplest way to get a second tick

    You can have multiple ticks (of different durations) without additional parts using the technique in post #10 here http://www.picbasic.co.uk/forum/show...213#post102213
    Why pay for overpriced toys when you can have
    professional grade tools for FREE!!!

  9. #9
    Join Date
    Oct 2006
    Location
    Cape Town SA
    Posts
    23


    Did you find this post helpful? Yes | No

    Default Re: What is the simplest way to get a second tick

    Hi Guys
    Thanks for the answers, I had forgotten how easy it was to use Bruce's instant interrupts, and that is how I did it, all I needed was a 1 second tick to start the a/d sample and the A/H integration. All sorted now.

  10. #10
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default Re: What is the simplest way to get a second tick

    I had forgotten how easy it was to use Bruce's instant interrupts
    Credit for instant interrupts belongs to Darrel Taylor..;o)
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts