Shop OBEX P1 Docs P2 Docs Learn Events
Frequency vs. Time — Parallax Forums

Frequency vs. Time

Eric REric R Posts: 225
edited 2004-10-10 14:17 in BASIC Stamp
While the BS2 does not like multitasking, what are the odds of making this situation work:

I am looking into a possible project where Frequency needs to be compared to time. Since the frequency is of a high voltage low amperage variety I will be converting this from frequency to voltage for a possible digital potentiometer scenario. Regardless of this input type, it will need to be compared to a variable time base. While the BS2 does not have a real time clock, an adjustable·pulse from a 555 timer would do fine and would lighten the load on the BS2.

What will take place is as follows:·Lets say for example, I am monitoring the speed of a treadmill and it is perfectly fine to raise the speed within moderation. The·"frequency" input vs. the "time base" input would allow for acceptable operation. However, if someone were to crank the speed knob ·faster than deemed acceptable, an output would shut down the treadmill. To determine the acceptable speed increase, the pot on the 555 timer would be adjusted inorder to increase of decrease the number of pulses (time base).


How well could the BS2 handle this situation???

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-10-10 03:22
    Actually, the COUNT function may be just what you need: it will monitor the change of state of an input pin over a given period of time. You can use this to monitor the speed of your treadmill and make a decision on what to do.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • Eric REric R Posts: 225
    edited 2004-10-10 04:36
    Didn't know you worked the weekends!

    Hadn't given the count function a thought, I will need to look into this. I have never had an application for the count function and am unfamiliar with it. I am about 6 months into the Basic Stamp learning world.

    Since this project has many variables, one day I may need to detect a 1000hz rise in less than 1 second but the next day 1000hz rise in·2 seconds may be acceptable. The count function will allow a potentiometer based adjustment for this?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-10-10 05:19
    I don't understand your potentiometer reference. COUNT does just that -- counts -- transisitons on a pin during a given window; which you can set. For example, you could measure frequency directly:

    · COUNT pin, 1000, freq

    This takes a lot of time though. Another approach is to use a shorter window and a multiplier:

    · COUNT pin, 250, freq
    · freq = freq * 4

    On last thought -- you can use PULSIN to measure each half-cycle of your input stream, the calculate the frequency from that. Lots of options....

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • BeanBean Posts: 8,129
    edited 2004-10-10 12:51
    Do you mean that the person using the treadmill would have a pot to adjust what is an "acceptable" rate change speed ?
    If so I would make the pot a different input and read it with RCTIME and let the Stamp do the decision making.

    Terry
  • Eric REric R Posts: 225
    edited 2004-10-10 14:17
    Jon, the reference to the pot is for the ability to change the time that the frequency is sampled. Terry may well be on to something if they can both be tied together for the correct result. It looks like 1 input will measure frequency via the count command and input 2 will provide the time base adjustment via rc time. I will work on it from this angle and see how it works out.

    Thanks guys!
Sign In or Register to comment.