Bill, Thanks for providing a description of the software architecture.
Since you're already using timers, it should be easy to set one up for a periodic interrupt, and have that interrupt turn off the LED that's on and turn on the next LED in the lookup table.
Often, the LED that it turns on is the same one that it just turned off, so the pendulum doesn't move during that interval. That's OK.
The point is that if the timer interrupt occurs at the same interval every time, the code is a lot easier to write. You don't have to keep changing the interval every time, and no fancy math is required, just a cosine lookup table that maps the fractional pendulum time into the LED position..
On 2/22/14 12:54 PM, Bill van Dijk wrote:
The PIC actually has a really cool feature I am using for the LED patterns. First of all, everything is timed through interrupts, every time a timer 2 interrupt occurs, LEDs need to be moved. Depending on the active pattern, it uses a number of lookup tables, some for the position, another for the timing of the next move. Timer 2 overflows once it content matches a particular readable and writable variable (same function used in its PWM). This is the value I am trying to find. One swing of the pendulum (let's say left to right) takes 3852 interrupts. In this time it completes 36 steps of 107 interrupts, which also happens to be 1 second real time. The trick is now to adjust the steps from 36 107 interrupts to 36 steps of varying values that still add up to the required 3852 interrupts, but in steps that approximate the true pendulum dynamic. I have now made a table that goes something like this (off-sets from the basic 107): ......-50 -40 -30 -20 -10 0 +10 +20 +30 +40 +50........ | ......-50 -40 -30 -20 -10 0 +10 +20 +30 +40 +50........ It actually looks not bad..... Bill
-- 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/53090615.4070709%40dakotacom.net. For more options, visit https://groups.google.com/groups/opt_out.
