Favorite cross-fading algorithms...

192 views
Skip to first unread message

Nick

unread,
Nov 13, 2016, 9:10:49 AM11/13/16
to neonixie-l
Just wondering what people's favorite smooth cross-fading algorithms were, assuming that they're prepared to share !

I tend to PWM down one digit and PWM up the next over a short interval, but others will have their own methods...

Nick

Ian Sparkes

unread,
Nov 20, 2016, 2:38:00 AM11/20/16
to neonixie-l
Hi Nick

controllers nowadays are easily fast enough to do very smooth fading even when dimmed. I do 6 iterations (one for each digit) of 1000 counts (for dimming and fading of each digit) with a minimum digit on time of 1000 and a maximum digit on time of 999. I calculate the switch from old to new digit based on the percentage of the fade that is done and the dim factor. This gives smooth dimming when fully on, or fully dimmed, or anywhere in between.

There's still easily enough time to do all the other work that's needed outside the loop.

You have one of my early clocks modules don't you? I should arrange a firmware update for you, the hardware is largely the same, but the firmware has come on leaps and bounds.

Ian

Ian Sparkes

unread,
Nov 20, 2016, 2:39:50 AM11/20/16
to neonixie-l
Of course that is "minimum digit on time of 100 and a maximum digit on time of 999". Doh! Fat fingers and early morning make many typo...

threeneurons

unread,
Nov 21, 2016, 4:19:43 AM11/21/16
to neonixie-l



On Sunday, November 13, 2016 at 6:10:49 AM UTC-8, Nick wrote:
Just wondering what people's favorite smooth cross-fading algorithms


On my current multiplexed clock kits, I've been using an exponential decay and complementary rise:

Completed over a half second period. The duty cycle for the "old" and "new" values are stored in a look-up table, that was calculated on a spreadsheet. Blanking (dark) period is greatest in the middle, so the total light does dip in transition.


Seems to work okay in 1 of 6 multiplexing, with an AVR chip at 8MHz.

  

Ian Sparkes

unread,
Nov 21, 2016, 7:42:33 AM11/21/16
to neonixie-l
That's a really nice idea. I do something like this with LED brightness for the backlights, but didn't think of it for tube brightness.

Nick

unread,
Nov 22, 2016, 5:53:40 AM11/22/16
to neonixie-l
Hi - Not sure which clock that would be - you may well be right, but there two "Nick"s here, both British, both ex-pats too (one in the US of A, the other in the UAE)...

Cheers Nick (the UAE one)

Ian Sparkes

unread,
Nov 22, 2016, 5:57:02 AM11/22/16
to neoni...@googlegroups.com
Ohhh OK. It's the other one then.

Anyway, if you want to look at the code how the cross fading is done (I might still add the fade profile like 3n says), it's on GitHub, and I'll happily go over it with you, if it's not clear (which is probably isn't - it's a bit involved).

On 22 November 2016 at 11:53, Nick <ni...@desmith.net> wrote:
Hi - Not sure which clock that would be - you may well be right, but there two "Nick"s here, both British, both ex-pats too (one in the US of A, the other in the UAE)...

Cheers Nick (the UAE one)

--
You received this message because you are subscribed to a topic in the Google Groups "neonixie-l" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/neonixie-l/bh7kymv2xQA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to neonixie-l+unsubscribe@googlegroups.com.
To post to this group, send email to neoni...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/neonixie-l/d784c375-6b47-454b-95ef-a3f0bbea5b1f%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Nick

unread,
Nov 22, 2016, 6:01:05 AM11/22/16
to neonixie-l
Hi Ian - do you have a link to the repository?

Thanks

Nick (the UAE one)

Ian Sparkes

unread,
Nov 22, 2016, 6:13:55 AM11/22/16
to neoni...@googlegroups.com
In particular line 2000 - 2137 is the main display loop, which does each of the 6 digits in turn.
Line 2013-2136 is for each digit.
For fading (20138-2044) we set the digitOffTime which is where we control the dimming (min digitOffTime is 100, max 999)
In lines 2092-2110 we detect if there has been a digit change between the new value we are to show and the old one (2093)
If there is and we are not already in a fade, we set up the fade counter with the initial value (2096)
If we are in a fade, we just continue (2101-2110) until we know it is time to stop (2012-2105)

Now we have all the values set up to do a single impression

2116-2128 does the impression of a single digit, switching the value at the appropriate point.

All clear? %-)



--
You received this message because you are subscribed to a topic in the Google Groups "neonixie-l" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/neonixie-l/bh7kymv2xQA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to neonixie-l+unsubscribe@googlegroups.com.
To post to this group, send email to neoni...@googlegroups.com.

Nick

unread,
Nov 22, 2016, 6:30:05 AM11/22/16
to neonixie-l
Thanks for that - looks OK - nicely laid out code - I spent 20-odd years doing low-level real-time C++ design & coding for exchanges and trading systems, so I like a bit of C++ !

I'll read through it over the next few days - appreciated...

Cheers

Nick
Reply all
Reply to author
Forward
0 new messages