Shop OBEX P1 Docs P2 Docs Learn Events
Controlling Hz — Parallax Forums

Controlling Hz

ghost13ghost13 Posts: 133
edited 2007-11-21 17:22 in BASIC Stamp
I'm trying to make my own altimeter for a rocket, but I have a bit of a problem. Right now, it only records about 10 times per second (I just use a loop to keep inputting data from the ADC).
Is there a way to change this rate? Or is it set by the stamp? BTW, I'm using the BS1

THANKS!

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-11-20 04:28
    What's your program?

    Although probably the speed is set by the time it takes to get a value from the ADC.
    Don't forget that the BS1 is pretty slow. Unless there are PAUSE statements in the
    program, the limiting factor is probably the overall speed of the BS1 and you can't
    change that. There may be some ways to slightly optimize your program, but don't
    expect to see more than a 10%-25% improvement at best.
  • ghost13ghost13 Posts: 133
    edited 2007-11-20 04:58
    Thanks. I assumed that. How are PICs so fast, though?

    My program is attached. My ADC sub method code is directly from the Parallax appnote on the adc I'm using (LTC1298). I never understood that ADC code... maybe that is what is slowing it down.

    Thanks for your help!
  • Mike GreenMike Green Posts: 23,101
    edited 2007-11-20 06:18
    The Stamps are PIC or SX processors whose program is an interpreter for Parallax's Basic language. There's a lot of overhead involved in interpreting the byte codes for Basic. The BS1 is the slowest of all the Stamps and executes about 2000 instructions per second ... that's not exactly 2000 statements per second ... it depends on the complexity of the statements. For example, your Convert routine probably executes 120 instructions to read one ADC value so you could read at most 15-18 ADC values per second. Some of the operations take more time like multiplication and division. I can see how you might get just 10 to 15 ADC readings per second.
  • ghost13ghost13 Posts: 133
    edited 2007-11-21 04:53
    Oh ok. I thought the compiler on my computer converted it to PIC code.

    I guess I'll just have to live with 10-15 readings per second.

    Thanks!
  • David H.David H. Posts: 78
    edited 2007-11-21 17:22
    ghost13,
    If moving up to a faster BasicStamp is possible, it could speed the sample rate some.
    Good luck with the project.
    David

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    David


    There are 10 types of people in this world,...
    Those that understand binary numbers, and those that don't!!!
Sign In or Register to comment.