Shop OBEX P1 Docs P2 Docs Learn Events
Multy frequency generator — Parallax Forums

Multy frequency generator

ArchiverArchiver Posts: 46,084
edited 2000-07-14 14:36 in General Discussion
I need a code for my Basic stamp II which gives constantly at same
time, to separate pins, 4 frequencies (1Hz, 4Hz 11,04Hz and 13,06Hz).
Is it possible? If it is, can you help me?

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2000-07-14 14:36
    The Stamp generally does one thing at a time, so this will be hard to do
    reliably. You can generate multiple frequencies by "manually" changing the
    output lines, but the frequency is pretty low. For example:

    i=0
    loopx:
    i=i+1
    toggle 0
    if i//2=0 then loopx
    toggle 1
    goto loopx

    However, the adjustment of the frequency is rather crude.

    Have you considered a PAK-VIII? With the prescaler, you should be able to
    generate your frequencies (periods of 1s, 250mS, 90.6mS, and 76.6mS). If you
    wanted 50% duty cycle, you'd set the on and off times for each channel equal
    (500mS, 125mS, 45.3mS, and 38.3mS).

    With the default prescaler (10uS) this works out to:
    50000, 12500, 4530, and 3830 -- the values are 16-bit, so 50000 is in range.
    You can also adjust the prescaler to get a wider range, at the expense of
    resolution, of course. You might need to do this if you wanted a duty cycle
    other than 50% since a 1S period is very close to the slowest the PAK can go
    without additional prescaling. For example, say you wanted a 10% duty cycle.
    You'd need 10000 and 90000. 90000 is too big. But if you set the prescaler
    to 20uS, you could go with 5000 and 45000 -- in range.

    In addition to generating pulses, the PAK can stop after a certain count of
    pulses. You can also force any line high, low, or high impedance (so you can
    use spare pins for basic digital output functions). You can use it to
    generate pulses to control servos, PWM, tones, etc. The minimum prescale is
    5uS, but this wouldn't work for your application. Also, at 5uS you can only
    use 4 channels for pulse output.

    Hope that helps.

    Regards,

    Al Williams
    AWC
    * Basic Stamp FAQ: http://www.al-williams.com/wd5gnr/stampfaq.htm


    >
    Original Message
    > From: ska@f... [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=8A-HqQrXMGgT8g1NSRfHeqTDOdEMg-QRfcE58j3X3_ToSA42n-WZNkZ4xgidwuLBpF5nl0fo]ska@f...[/url
    > Sent: Friday, July 14, 2000 6:27 AM
    > To: basicstamps@egroups.com
    > Subject: [noparse][[/noparse]basicstamps] Multy frequency generator
    >
    >
    > I need a code for my Basic stamp II which gives constantly at same
    > time, to separate pins, 4 frequencies (1Hz, 4Hz 11,04Hz and 13,06Hz).
    > Is it possible? If it is, can you help me?
    >
    >
    >
    >
Sign In or Register to comment.