Shop OBEX P1 Docs P2 Docs Learn Events
count function on Bs2p — Parallax Forums

count function on Bs2p

divsterdivster Posts: 2
edited 2005-04-05 17:51 in BASIC Stamp
I am trying to measure frequency using the COUNT function in PBASIC. For the project I am working on, I need to get as high a count as i can get....but am unfortunately limited by the WORD size - 65535 max limit.

Is there anyway I can count to a higher number?

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-04-04 22:51
    No. What you can do, though, is count for a shorter period.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • divsterdivster Posts: 2
    edited 2005-04-05 05:02
    Counting for a shorter period doesn't give us enough resolution - for the sensor we are building.

    Would ideally like to count to a million over 1 second - but anything over 65K would be a good start.

    Is there any kind of flag or interrupt that overflows when the counter rolls over? Is there any such thing we can use to increase the counts?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-04-05 12:14
    No. The BASIC Stamp may not be the best solution for your application. You might consider an SX microcontroller -- we now provide a free BASIC compiler with our SX-Key tool kit; perhaps that's a viable option. That said, SX/B does not have the count function of PBASIC, so you'd have to code that yourself. Doing so would allow you to create and use a 24-bit variable (in assembly).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-04-05 17:51
    Another limitation of the COUNT command is that the highest frequency the BS2p can count is around 400khz, so your goal of 1 million per second is not possible from that standpoint either. Maybe you could use an external prescaler to reduce the frequency to a range that the Stamp can COUNT, say a /10 to reduce 1mhz to 100khz? Yes, that would degrade the resolution. But the Stamp's COUNT command depends for its accuracy and stability on a ceramic resonator, which will be important if you are really going after 16 bit precision.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
Sign In or Register to comment.