Shop OBEX P1 Docs P2 Docs Learn Events
Boat Speedometer — Parallax Forums

Boat Speedometer

chucklchuckl Posts: 3
edited 2006-03-14 18:50 in BASIC Stamp
I'm using a Basic Stamp·to determine the speed of a boat.· The input is a pulse from a turbine - 4.8 Hz for every mph of speed.· Due to the low frequency, especially at slow speeds, the pulsein command (counts the number of 2us increments between each pulse) will generate a value greater than the limit of 65535 allowed.· Also, after such a value is acquired, I need to divide 500,000 by that value to determine the frequency which is then converted to mph by a simple multiplication.· Basically, this is a problem where large numbers need to be dealt with and I'm sure that it's not a new problem, but I can't find anything on the forum that is helpful other than the possibility of using the function, COUNT, instead, which counts pulses over a specified period.· It's really a simple tachometer problem, but I'm struggling with working around the 16-bit limit and integer-only math on the Stamp.· Any help would be greatly appreciated.

Comments

  • Russ MillerRuss Miller Posts: 25
    edited 2006-03-11 22:45
    COUNT will do a good job for you with NO math if you choose the right period for counting. You get 4.8 pulses per second for each mph, so if you count for about 1/4.8 second each pulse will represent one mph. The count period should be 1/4.8 s = 208.33 mS but using integer math means rounding off to 208mS which intorduces a tiny error of ~0.2%, probably far less than the sensor calibration uncertainty. If the reading jumps around a lot or you want better than 1mph resolution you can count for a longer period (multiples of 208.33mS) and divide, or keep track of multiple samples in an array and use a moving average.
  • steve_bsteve_b Posts: 1,563
    edited 2006-03-11 23:16
    there are frequency to voltage converters out there.
    Analog devices has them....Not sure what the working frequency ranges are.

    How fast would the boat go? In otherwords, what would the highest freq. be?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·

    Steve

    "Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
  • chucklchuckl Posts: 3
    edited 2006-03-12 02:06
    Steve, thanks for your reply.· The speedometer is being built in the context of a cruise control with the critical range in the 15 - 30 mph, but it would be nice to have it work all the way up to 40 mph so, say 200 Hz.
  • Lee_SpeakmanLee_Speakman Posts: 32
    edited 2006-03-13 18:17
    chuck1, I had the exact same problem, im doing a digital dash for a car, measures road speed etc.... I dont think there is any good solution around this, as me and my lab partner spent the best part of a day trying different tricks.

    In the end we have ordered an LM2917 (Frequency to voltage convertor)

    Its a linear IC and gives a voltage out, proportional to frequency, where Vout=Vcc*R1*C1*Fin

    So, you configure it so so Vout=Vcc at 40MPH (192Hz)

    Next im using a 8bit ADC convertor, so you should get quite a nice speed resolution if you use one of them. Should be just some simple math inside the Stamp to convert it to mph (I havent got that far yet [noparse]:D[/noparse])

    Let me know how you get on.
  • chucklchuckl Posts: 3
    edited 2006-03-14 18:50
    Lee, I really appreciate your ideas.· We'll look into it.

    Chuck
Sign In or Register to comment.