frequency counter

Discussion in 'The Projects Forum' started by suzuki, Feb 16, 2012.

  1. suzuki

    Thread Starter Member

    Aug 10, 2011
    119
    0
    Hi,

    i am trying to generate a square wave output with a certain frequency. i would like to use "blocks" to do this for my simulation, rather than software programming, but i'm having a hard time visualling what blocks i need to implement this.

    My idea is is that i would set the frequency by the length of the counter. The counter would then count up to that value, and then count back down to zero, and then await the next value to count up to. On the "zero" and "length" value(s), the square wave would be generated by setting a high or low. i drew a quick image of what i am trying to achieve.

    [​IMG]

    any and all suggestions are appreciated.
     
  2. crutschow

    Expert

    Mar 14, 2008
    13,016
    3,235
    The square-wave in your diagram is not symmetrical. Do you want it symmetrical (equal on and off period)?
     
  3. crutschow

    Expert

    Mar 14, 2008
    13,016
    3,235
    Double post deleted.
     
  4. suzuki

    Thread Starter Member

    Aug 10, 2011
    119
    0
    hmm sorry about that. I would like to have 50% duty cycle for the square wave. however, i should add that eventually, i want to try to get a variable counter to change the frequency of the square wave.
     
  5. crutschow

    Expert

    Mar 14, 2008
    13,016
    3,235
    You could use a presetable (programmable) counter and a toggle flip-flop. Every time the counter reaches its maximum count the carry-out signal can trigger the FF to the opposite state, giving a 50% duty-cycle square-wave. The clock frequency and the programmed count you put into the counter determines the frequency of the square-wave.
     
  6. suzuki

    Thread Starter Member

    Aug 10, 2011
    119
    0
    unfortunately, i dont think i have a t flip flop in my software. and i think i want to trigger the high/low when the count has reached max (for low) or 0 (for high).

    edit: upon further review, i realised i can build a t flip flop from "fundamental" logic. although im still not quite sure how to set this up. how does the FF know that the max count has been reached? or how does it know that count has been reset, and thus setting the square wave high? if possible, could you show me a quick block diagram?
    thanks
     
    Last edited: Feb 16, 2012
  7. crutschow

    Expert

    Mar 14, 2008
    13,016
    3,235
    You don't have a JK or D flip-flop in your software? To make a toggle FF you just connect J and K to logic high, or the D input to the /Q output. What is the software?

    You just have to trigger the FF every time the count reaches the maximum set count using the "carry out" signal. At that point the counter automatically rolls over to zero and starts the count again.
     
  8. suzuki

    Thread Starter Member

    Aug 10, 2011
    119
    0
    hi crutschow,

    sorry, but i made an edit to my above post. is it possible to show a block diagram? im still not quite sure how this connects..
     
  9. crutschow

    Expert

    Mar 14, 2008
    13,016
    3,235
    I could draw the block but it's very simple. The "carry out" of a counter changes state when the count reaches it maximum count (all "1s"). That is used to clock the FF and change its state. After the next counter clock pulse, the counter rolls over to all zeros (or the preset count value) which resets the "carry out" signal and restarts the count.

    Thus the connection is: clock signal to counter "clock" input, and then counter "carry out" signal to FF "clock" input (with the JK or D inputs connected as I stated in post #7).
     
Loading...