Shop OBEX P1 Docs P2 Docs Learn Events
Generate Squarewave Using BS2 — Parallax Forums

Generate Squarewave Using BS2

ArchiverArchiver Posts: 46,084
edited 2002-12-19 07:17 in General Discussion
Hi Frenzs,

I'm currently having problem generating a square wave with a 50% duty
cycle using the "PULSOUT" command.

With reference to BS Mannual Ver 2.0, page 244, it states that
there's pulse glitches. Is there any way to avoid this problem. Any
otheer commands to 50% duty cycle?


In deep ****
pctsp

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-12-13 12:42
    I'm looking at a similar problem. The idea of feeding an external
    oscilator circuit seems to possible. I haven't gotten to that part
    as yet, so I haven't thought it all the way thru.

    In my case, I'm also looking to adjust the duty cycle as well as the
    frequency.

    I am very interested in this thread.

    I wonder if Don's desulfator circuit would benefit from an adjustable
    pulse rate and duty cycle ?

    Dave


    --- In basicstamps@yahoogroups.com, "pctsp <pctsp@y...>" <pctsp@y...>
    wrote:
    > Hi Frenzs,
    >
    > I'm currently having problem generating a square wave with a 50%
    duty
    > cycle using the "PULSOUT" command.
    >
    > With reference to BS Mannual Ver 2.0, page 244, it states that
    > there's pulse glitches. Is there any way to avoid this problem. Any
    > otheer commands to 50% duty cycle?
    >
    >
    > In deep ****
    > pctsp
  • ArchiverArchiver Posts: 46,084
    edited 2002-12-14 15:07
    Simply tie the stamp output to a D-type flip flop at twice the
    desired frequency. The first pulse sets the FF and the next clears
    it. Perfectly 50-50.

    Paul

    --- In basicstamps@yahoogroups.com, "Dave Mucha <davemucha@j...>"
    <davemucha@j...> wrote:
    > I'm looking at a similar problem. The idea of feeding an external
    > oscilator circuit seems to possible. I haven't gotten to that part
    > as yet, so I haven't thought it all the way thru.
    >
    > In my case, I'm also looking to adjust the duty cycle as well as
    the
    > frequency.
    >
    > I am very interested in this thread.
    >
    > I wonder if Don's desulfator circuit would benefit from an
    adjustable
    > pulse rate and duty cycle ?
    >
    > Dave
    >
    >
    > --- In basicstamps@yahoogroups.com, "pctsp <pctsp@y...>"
    <pctsp@y...>
    > wrote:
    > > Hi Frenzs,
    > >
    > > I'm currently having problem generating a square wave with a 50%
    > duty
    > > cycle using the "PULSOUT" command.
    > >
    > > With reference to BS Mannual Ver 2.0, page 244, it states that
    > > there's pulse glitches. Is there any way to avoid this problem.
    Any
    > > otheer commands to 50% duty cycle?
    > >
    > >
    > > In deep ****
    > > pctsp
  • ArchiverArchiver Posts: 46,084
    edited 2002-12-14 16:57
    Agree 100%. I have "squared" many of pulse trains using a D FF.

    > Simply tie the stamp output to a D-type flip flop at twice the
    > desired frequency. The first pulse sets the FF and the next clears
    > it. Perfectly 50-50.
    >
    > Paul
    >
    > --- In basicstamps@yahoogroups.com, "Dave Mucha <davemucha@j...>"
    > <davemucha@j...> wrote:
    > >I'm looking at a similar problem. The idea of feeding an external
    > >oscilator circuit seems to possible. I haven't gotten to that part
    > >as yet, so I haven't thought it all the way thru.
    > >
    > >In my case, I'm also looking to adjust the duty cycle as well as
    > the
    > >frequency.
    > >
    > >I am very interested in this thread.
    > >
    > >I wonder if Don's desulfator circuit would benefit from an
    > adjustable
    > >pulse rate and duty cycle ?
    > >
    > >Dave
    > >
    > >
    > >--- In basicstamps@yahoogroups.com, "pctsp <pctsp@y...>"
    > <pctsp@y...>
    > >wrote:
    > >>Hi Frenzs,
    > >>
    > >>I'm currently having problem generating a square wave with a 50%
    > >duty
    > >>cycle using the "PULSOUT" command.
    > >>
    > >>With reference to BS Mannual Ver 2.0, page 244, it states that
    > >>there's pulse glitches. Is there any way to avoid this problem.
    > Any
    > >>otheer commands to 50% duty cycle?
    > >>
    > >>
    > >>In deep ****
    > >>pctsp
    >



    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-12-18 18:20
    Hi Frends,

    Thanks for the informative suggestion. I'm currently using the D-
    Flip-Flop to fulfil my objective. However there's another problem.

    My Flip-flop does not produce the output correctly. I'm using a clock
    frequency of 20Khz. Is it because of this frequency, that i'm facing
    this problem.

    All connection of the D Flip-Flop throughly checked.

    D Flip-Flop Used : DM74LS574N

    Thanks again,
    octsp
    --- In basicstamps@yahoogroups.com, smartdim@a... wrote:
    > Agree 100%. I have "squared" many of pulse trains using a D FF.
    >
    > > Simply tie the stamp output to a D-type flip flop at twice the
    > > desired frequency. The first pulse sets the FF and the next
    clears
    > > it. Perfectly 50-50.
    > >
    > > Paul
    > >
    > > --- In basicstamps@yahoogroups.com, "Dave Mucha <davemucha@j...>"
    > > <davemucha@j...> wrote:
    > > >I'm looking at a similar problem. The idea of feeding an
    external
    > > >oscilator circuit seems to possible. I haven't gotten to that
    part
    > > >as yet, so I haven't thought it all the way thru.
    > > >
    > > >In my case, I'm also looking to adjust the duty cycle as well as
    > > the
    > > >frequency.
    > > >
    > > >I am very interested in this thread.
    > > >
    > > >I wonder if Don's desulfator circuit would benefit from an
    > > adjustable
    > > >pulse rate and duty cycle ?
    > > >
    > > >Dave
    > > >
    > > >
    > > >--- In basicstamps@yahoogroups.com, "pctsp <pctsp@y...>"
    > > <pctsp@y...>
    > > >wrote:
    > > >>Hi Frenzs,
    > > >>
    > > >>I'm currently having problem generating a square wave with a
    50%
    > > >duty
    > > >>cycle using the "PULSOUT" command.
    > > >>
    > > >>With reference to BS Mannual Ver 2.0, page 244, it states that
    > > >>there's pulse glitches. Is there any way to avoid this problem.
    > > Any
    > > >>otheer commands to 50% duty cycle?
    > > >>
    > > >>
    > > >>In deep ****
    > > >>pctsp
    > >
    >
    >
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-12-18 20:14
    You have to connect the Q bar output to the D input of the flip flop and
    apply the square wave that you have to the Clock input of the flip flop to
    make it divide by 2. If you have the flip flop connected in this manner it
    should work fine up into Mhz range.
    You should probably disabe the Clear and Set inputs also ijust to make sure
    noise isn't triggering these.


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-12-18 20:20
    20Khz is not too fast for the D FF.

    And a big fat OOOPPPPS!!!!!!!!!!! A "D" FF is not the correct device.

    Use a "JK" FF, a 74LS76 and tie the J and K inputs high through 10k ohms.
    There is also a device called a TOGGLE FF, I can't find the number right
    now..
    The toggle FF does not have the J & K inputs, just a clock in and output.

    Email me personally with a tel number if you need clarification

    Sorry for the mix up....A "D" FF will definately NOT work!!!!!!!!!! SORRY

    I guarantee the 74LS76 will do what you want, 20khz input and 10kHz output!!


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-12-18 20:25
    In a message dated 12/18/2002 12:15:23 PM Pacific Standard Time,
    azeasi@a... writes:

    > You have to connect the Q bar output to the D input of the flip flop and
    > apply the square wave that you have to the Clock input of the flip flop to
    > make it divide by 2. If you have the flip flop connected in this manner it
    > should work fine up into Mhz range.
    > You should probably disabe the Clear and Set inputs also ijust to make sure
    >
    > noise isn't triggering these.
    >

    Really? I never have done it that way. Sounds good though. There are also
    Toggle FF or you can use a JK, tie JK high, although there is more hook up
    using the JK.


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-12-18 23:07
    Just to add to the confusion:

    For the D flip-flop or the JK flip-flop, be sure you connect your
    pulse to the _clock_ input, not the data input.

    For the D flip-flop, connect the Q' output back to the D
    (data) input. Use the Q output as your square wave source.

    For the JK flip-flop, pull the J and K inputs high as smartdim wrote.
    Use the Q output as your square wave source.

    Why this works:

    Characteristic equation for D flip-flop: Q(t+1) = D

    If D = Q'(t), Q(t+1) = Q'(t)

    Characteristic equation for JK flip-flop: Q(t+1) = JQ'(t) + K'Q(t)

    If J = K = 1, Q(t+1) = 1Q'(t) + 0Q(t) = Q'(t)


    Regards,

    Steve
  • ArchiverArchiver Posts: 46,084
    edited 2002-12-19 00:05
    I have to disagree with your statement that a D flip flop will not work. I
    have built many circuits using a D Flip Flop wired as I stated in the last
    posting. It is a very common way to produce a divide by 2 circuit which will
    give you exactly a 50% duty cycle at 1/2 the input frequency.


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-12-19 07:17
    In a message dated 12/18/2002 4:09:22 PM Pacific Standard Time,
    azeasi@a... writes:

    >
    > I have to disagree with your statement that a D flip flop will not work. I
    > have built many circuits using a D Flip Flop wired as I stated in the last
    > posting. It is a very common way to produce a divide by 2 circuit which
    > will
    > give you exactly a 50% duty cycle at 1/2 the input frequency.

    My bad!!!

    I later learned that you put the Qbar output to the D input and get the
    divide by two function..I did not know that previously, now I do!!!!!!!!!!!!

    Didn't want to come off sounding like an idiot, but too late for that!
    None the less, I learned something today,,,,,

    Previously I had used either a Toggle FF or a JK FF and tie J&K high. Next
    time I need a 50% duty cycle I will certainly use a D FF.


    [noparse][[/noparse]Non-text portions of this message have been removed]
Sign In or Register to comment.