Home
Prox / RFID
Verichips
Ladder Logic
[interfacing] †
Tube Joints
Key Code From Photo
SolveSpace (3d CAD)
SketchFlat (2d CAD)
Photographs
Miscellany
Resume / Consulting
Contact Me

LDmicro Forum - Designing a variable squarewave generator.

(you are viewing a thread; or go back to list of threads)

Designing a variable squarewave generator. (by Juan)
Hi,

Could you help me design a variable square wave generator able to vary the square wave frequency with up and down push buttons in 1Hz increments from 1Hz to 1000Hz?

I don't really know where to begin.

I tried manipulating the Ton and Toff timer values by writing an ADD function to the Ton and Toff registers adding Ton + "value" but this does not seem to work.

Can you also give me an example on how to operate the look up table?

Thanks.
Thu Aug 20 2009, 14:42:57
(no subject) (by Jonathan Westhues)
The highest possible resolution for the period of a software timer is the cycle time. This means that you can't get 1 Hz resolution around 1 kHz without an impractical cycle time (of around 1 us). But that resolution is easy on the slow side.

See the attachment. The highest possible output frequency is 1/(2*Tcycle). So you want to set the cycle time to at most 0.5 ms. This means that you should use the fastest crystal allowed, and keep the rest of the program short.

Note that we specify the period of the timer, not the frequency. If you wanted to specify the frequency instead, then you would have to divide to calculate the period from that.
Thu Aug 20 2009, 16:00:27, download attachment program-frequency.ld
(no subject) (by Ilie)
One Exemple.
Thu Aug 20 2009, 16:08:30, download attachment Adjustable Frecvent.ld
Post a reply to this comment:
Your Name:
Your Email:
Subject:
(no HTML tags; use plain text, and hit Enter for a line break)
Attached file (if you want, 5 MB max):