09-11-2015, 05:27 PM
(This post was last modified: 09-11-2015, 05:28 PM by dandruczyk.)

I'm designing a new way to define the crank/cam wheel patterns for Ardu-Stim. As of now (sept 11, 2015) this is a DRAFT and may be subject to change as the idea develops further...

The primary motivator behind this is a lack of FLASH space on the arduino (a paltry 32 K, which also includes the code itself). Â Some complexÂ patterns with 1 degree resolution each, take up to 720 bytes EACH, and it doesn't take long at all to gobble up all the flash, as I'm right on the edge now and a new pattern is likely to push it over the edge, and I have 38 patterns already and would prefer to support a LOT more including user provided patterns over the serial link (this method allows that)

The secondary motivator is that the patterns are cumbersome to edit and debug and staring at columns of ones and zeros is hell on the brain....

So here it is so far:

/* New Wheel definition strings

Â * All patterns start with a "C" meaning "crankshaft" or "c" meaning "camshaft

Â * The second parameter determines the pattern style

Â * Â "A" for an angular defined wheel (time on, time off in degrees, total time must equal 360 degrees)

Â * Â "S" is for the simplest symmetric, non-missing teeth wheels ONLY

Â * Â "M" is for M-N or more complex M-N+N styles

Â *

Â * Third param (pattern tooth duty cycle) (1/2 == 50%, 1/4 == 25% and so on, any ration allowed)

Â * Â up to 5 characters (xx/yy) to allow for really odd duty-cycles

Â *

Â * Fourth param depends on 2nd param (A,S, or M)

Â * Â For "A" (angular (complex or odd)) defined wheels the sequence isÂ

Â * Â the number of degrees the tooth is "high" followed by low for each tooth, The total MUST equalÂ

Â * Â 360 for crank wheels and 720 for cam wheels

Â * Â i.e. for a wheel that is 40 degrees high, 50 deg low with 4 teeth it would be:

Â * Â 40,50,40,50,40,50,40,50

Â *

Â * Â For "S" simple/symmetric pattern, you just need the number of teeth that the wheel should generate in a revolution

Â * Â i.e. 2 Â (dizzy 4 cylinder)

Â *

Â * Â For M-N(-/+N...) (missing teeth pattern, any style)

Â * Â List the number of teeth the wheel would have if it had NO MISSING teeth, then

Â * Â the SEQUENTIAL present teeth followed by sequential missing teeth as follows until you complete the whole pattern

Â * Â The total number of teeth and missing MUST equal the number the preceding number as shown

Â * Â 36t,1m Â (36-1 pattern)

Â * Â 13t,2m,16t,2m,1t,2m (Mazda 36-2-2-2)

Â *

Â * Â So for a simple 4 cylinder distributor (2 teeth per crank rotation, 50% duty cycle)

Â * The pattern is "CS1/2,2"

Â * For a 36-1 with 33% dutycycle (short teeth, 2x as wide gaps) it would be:

Â * CM1/3,36,35t,1m Â (15 bytesÂ vs 108 bytes with the current setup)

Â *

Â * For Crank+Cam setups the CRANK pattern is always defined FIRST,Â

Â *Â then a colon character ":" and the same structure as the crank but with lowercase "c" instead

Â *Â in the same style as above. Â You need to be careful to "word" your pattern in a way to get the

Â * crank to cam relationship right. Â The crank pattern will repeat every 360 degrees, the cam one, every 720 degrees

Â *

Â * Example:

Â * 60-2 bosch wheel (crank only)

Â * CM1/2,60,58,2

Â * hypothetical wheel with 60-2 crank and half-moon single tooth cam

Â * CM1/2,60,58,2:cS1/2,1 Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â

Â *

Â */

When a pattern is selected by the serial UI, the arduino will parse that string and build the output array in RAM and output the pattern as usual, Â there's plenty of RAM to accommodateÂ 1 degree resolution for all wheels, and I have thought of ways to compress that by a factor of 8, though I'm not 100% sure if that'll impact the output signal significantly or not.

Thoughts?

The primary motivator behind this is a lack of FLASH space on the arduino (a paltry 32 K, which also includes the code itself). Â Some complexÂ patterns with 1 degree resolution each, take up to 720 bytes EACH, and it doesn't take long at all to gobble up all the flash, as I'm right on the edge now and a new pattern is likely to push it over the edge, and I have 38 patterns already and would prefer to support a LOT more including user provided patterns over the serial link (this method allows that)

The secondary motivator is that the patterns are cumbersome to edit and debug and staring at columns of ones and zeros is hell on the brain....

So here it is so far:

/* New Wheel definition strings

Â * All patterns start with a "C" meaning "crankshaft" or "c" meaning "camshaft

Â * The second parameter determines the pattern style

Â * Â "A" for an angular defined wheel (time on, time off in degrees, total time must equal 360 degrees)

Â * Â "S" is for the simplest symmetric, non-missing teeth wheels ONLY

Â * Â "M" is for M-N or more complex M-N+N styles

Â *

Â * Third param (pattern tooth duty cycle) (1/2 == 50%, 1/4 == 25% and so on, any ration allowed)

Â * Â up to 5 characters (xx/yy) to allow for really odd duty-cycles

Â *

Â * Fourth param depends on 2nd param (A,S, or M)

Â * Â For "A" (angular (complex or odd)) defined wheels the sequence isÂ

Â * Â the number of degrees the tooth is "high" followed by low for each tooth, The total MUST equalÂ

Â * Â 360 for crank wheels and 720 for cam wheels

Â * Â i.e. for a wheel that is 40 degrees high, 50 deg low with 4 teeth it would be:

Â * Â 40,50,40,50,40,50,40,50

Â *

Â * Â For "S" simple/symmetric pattern, you just need the number of teeth that the wheel should generate in a revolution

Â * Â i.e. 2 Â (dizzy 4 cylinder)

Â *

Â * Â For M-N(-/+N...) (missing teeth pattern, any style)

Â * Â List the number of teeth the wheel would have if it had NO MISSING teeth, then

Â * Â the SEQUENTIAL present teeth followed by sequential missing teeth as follows until you complete the whole pattern

Â * Â The total number of teeth and missing MUST equal the number the preceding number as shown

Â * Â 36t,1m Â (36-1 pattern)

Â * Â 13t,2m,16t,2m,1t,2m (Mazda 36-2-2-2)

Â *

Â * Â So for a simple 4 cylinder distributor (2 teeth per crank rotation, 50% duty cycle)

Â * The pattern is "CS1/2,2"

Â * For a 36-1 with 33% dutycycle (short teeth, 2x as wide gaps) it would be:

Â * CM1/3,36,35t,1m Â (15 bytesÂ vs 108 bytes with the current setup)

Â *

Â * For Crank+Cam setups the CRANK pattern is always defined FIRST,Â

Â *Â then a colon character ":" and the same structure as the crank but with lowercase "c" instead

Â *Â in the same style as above. Â You need to be careful to "word" your pattern in a way to get the

Â * crank to cam relationship right. Â The crank pattern will repeat every 360 degrees, the cam one, every 720 degrees

Â *

Â * Example:

Â * 60-2 bosch wheel (crank only)

Â * CM1/2,60,58,2

Â * hypothetical wheel with 60-2 crank and half-moon single tooth cam

Â * CM1/2,60,58,2:cS1/2,1 Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â

Â *

Â */

When a pattern is selected by the serial UI, the arduino will parse that string and build the output array in RAM and output the pattern as usual, Â there's plenty of RAM to accommodateÂ 1 degree resolution for all wheels, and I have thought of ways to compress that by a factor of 8, though I'm not 100% sure if that'll impact the output signal significantly or not.

Thoughts?

-- David