Bill,
This problem is not hard to solve when writing new code for a clock, but
the constraint you have offered makes it hard to solve.
A faster loop would make it easy.
If it were my design, I would make the clock software use a main loop of
a few milliseconds (for example 200 loops per second), triggered by a
software timer based on the CPU clock crystal. Each cycle through the
loop would do any necessary timekeeping tasks, time-setting button
reading, etc. There would be only one constraint on that code's timing,
that it complete before the next timer trigger event.
Then I would add a short routine to look up which LED to light with a
lookup table based on a cosine wave, calculated in Excel as integers, as
was suggested earlier. The input to the lookup table would be a counter
that increments once per timing loop and is reset once per pendulum
cycle, when it reaches 200.
However, since your code is not structured in this general-purpose
manner, you will need to build the cosine into your timing code. A
spreadsheet will help to calculate the position of each LED based on the
cosine of the time slice.
On 2/22/14 8:31 AM, Bill van Dijk wrote:
Hello,
I have built a clock controlled by a PIC with 6 numitrons in the centre.
Around them is a circle of 60LEDs which are programmed to display a number
of different patterns. I am currently working on a pendulum pattern which
uses the lower 30 LEDs. I have the software done, the challenge is this:
A pendulum has a period and an angular velocity that changes from 0 at the
ends, and maximum in the center, following an equation. In the software I
currently have 36 time slices (program steps, 0 to 35) in a half period of
107 clock cycles, for a total of 3852 cycles for one swing (left or right).
Looking at one swing, my challenge now is to divide the 36 program steps of
107 clock cycles such that the total number of clock cycles remains 3852,
but the actual number of clock cycles per step are divided such as to
approximate the equation of one pendulum swing (left or right).
Anyone willing to take a stab at this?
Bill van Dijk
--
David Forbes, Tucson AZ
--
You received this message because you are subscribed to the Google Groups
"neonixie-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send an email to [email protected].
To view this discussion on the web, visit
https://groups.google.com/d/msgid/neonixie-l/5308F429.9050302%40dakotacom.net.
For more options, visit https://groups.google.com/groups/opt_out.