Shop OBEX P1 Docs P2 Docs Learn Events
Generating Clock Signal? — Parallax Forums

Generating Clock Signal?

lenny1337lenny1337 Posts: 26
edited 2007-07-28 00:48 in BASIC Stamp
I need a 5khz -8000khz clock for one of my linear array optical sensors, however if i say 'high 5 low 5' kind of thing on the bs2 the fastest "clock" i can get out is about 600hz. i tried with the px24 and got about 2khz, still shy of the minimum needed for this sensor

Is there a better way to get a clock signal w/o external hardware?


Thanks

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Lenny Bogdanov
Systems Concept Center

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-07-27 22:09
    The SHIFTIN/SHIFTOUT statements generate a clock for each data bit to be received/transmitted. If you only need a small number of clocks at a time, that might be what you need. Have a look at the description in the manual.

    FREQOUT can also generate a pulse stream for a fixed period of time with a frequency up to around 32KHz.
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-07-27 22:13
    No, I wouldn't use FREQOUT for that -- it doesn't generate a square wave (as I understand it).

    The BS2 is not really a "real-time" platform that generates rock-solid timing. Instead it's an extremely easy to use and reliable embedded processor at about 2000 Basic Instructions Per Second, with its own clock and its own linear regulator. Thus, you'll probably need some external hardware (a 555 perhaps) to generate the signal you want. You CAN use the BS2 to 'gate' that signal on and off, however.
  • RDL2004RDL2004 Posts: 2,554
    edited 2007-07-27 22:31
    I think the 555s top out around 1.5 MHz and that's the cmos variety. Also, 5KHz to 8MHz is a pretty wide range if it has to be continuously variable. Maybe something could be done with a fast running SX chip?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Rick
  • Mike GreenMike Green Posts: 23,101
    edited 2007-07-27 22:37
    I think you're right about the FREQOUT.· I don't have my PBasic Manual handy.· I thought there was a statement that put out a pulse train with a particular repetition rate for a period of time.· I could be wrong.
    ·
  • RDL2004RDL2004 Posts: 2,554
    edited 2007-07-27 23:08
    Mike, as usual you're right - and believe it or not, the command is called "PULSEOUT"

    Quote from PBasic help:

    PULSOUT sets Pin to output mode, inverts the state of that pin; waits for the specified Duration; then inverts the state of the pin again; returning the bit to its original state.

    edit: Units for Duration are 10 µs for the BS1, 2 µs for the BS2, BS2e, and BS2pe, and 0.8 µs for the BS2sx, BS2p, and BS2px.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Rick

    Post Edited (RDL2004) : 7/27/2007 11:15:28 PM GMT
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2007-07-28 00:42
    Mike, the PWM command is capable of generating frequencies (composed of pulses output from the carry bit like the Propeller PWM counter mode). With
    PWM ppin, 128, 1
    


    That creates a square wave of 111.3 kilohertz, lasting for 128 low time slots and 128 high time slots.
    www.emesys.com/BS2PWM.htm

    There are 100 some discrete frequencies available with different choices of the duty parameter, but only when it is a power of two are they spectrally pure, evenly spaced pulses. But is can be very useful in some situations to generate a specific number of pulses at something like a specific rate.

    Lenny, one possible outside chip for you might be the LTC6903 or LTC6904 "silicon oscillator" from www.linear.com. Frequency range 1 khz to 68 mhz, 10 bits per octave resolution in digital (SPI or I2C) frequency setting. 8 pin msop.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • lenny1337lenny1337 Posts: 26
    edited 2007-07-28 00:45
    thanks for all the advice, i looked around the shop and found a 555 which i made into a clock generator. i'm getting about 6khz out of it right now, which is just passed the min and i'm happy w/ it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Lenny Bogdanov
    Systems Concept Center

    Post Edited (lenny1337) : 7/28/2007 5:43:37 AM GMT
  • lenny1337lenny1337 Posts: 26
    edited 2007-07-28 00:48
    great advice on that PWM command - i think this is the way to do it. I'm gettin 320khz w/ my px24!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Lenny Bogdanov
    Systems Concept Center
Sign In or Register to comment.