Instructables

Custom Mechanical Biorhythm Computer, 3D printed

Featured

Step 4: Non-Problem 4: Writing the software

Finally, a step I've actually got the skills for.

I work on real-time 3D software a lot, which means I'm used to making things which don't work at first, and then after I've debugged them, still don't work. I'm used to staring at a screen full of text with a single punctuation mark out of place, stopping everything, and unable to spot it, at 3am.

What I needed here was a program which would build and position all of the gears for me automatically, based on the number of teeth and other info I provided. Also, it needs to take in birthdates of the two people, and build the gears specifically to point the needles in the right direction for them. All of that ends up taking a while.

I wrote the software in C++, using a framework called Qt to save time on the standard "buttons and windows" part. (Incidentally, since HotSharpToxic's lipstick thing was going on at the same time, I decided to make one program that does both, to save time.)

For this software to work, I needed a format to store a description of a gear machine.
That way I can change the specification to mess with the machine, instead of the C++ code.
The text-file format I chose is wonky and ugly, but very quickly did the job.

The complete parametric specification for the gears in the machine is here:
(Even if you're not a software engineer, you can probably pick out some parts.
The key is the group of words right after the "expr" section.)


//______________________________________________________________________
// GearMachine.tsu  -  Bio gear machine, version 49b
//
expr, thickness, 0.3
expr, extraThick, (1.0 * thickness)
expr, stackOffset, (1.25 * thickness)
expr, toothSize, 0.30
expr, axleDiameter, 0.5

// Gear id, numTeeth, toothSize, thickness, axleDiameter, addAxle, u1, u2, v1, v2

image, gears/plainGear1.png

expr, baseDrop, -0.5
expr, timeAngle, 0.0
expr, emoAngle, 220.0
expr, emoArch1Angle, (emoAngle - 60.0)
expr, emoArch2Angle, (emoAngle + 60.0)

// real gears are below
//    name          teeth  toothSize  thickness  axleDiameter  verticalOff   parent         connect angle   tilt backWidth backOffset stackOffCenter fixArrowLen fixArrowAngle fixArrowOffset  topAxleExtend  bottomAxleExtend
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
gear, rootGear89,      89, toothSize, extraThick,axleDiameter, 0.0,          none,            stack,  0.0,   0.0,    1.00,    -1.0,      0.0,           0.0,           0.0,           0.0,           0.0,           0.0
gear, rootGear79,      79, toothSize, extraThick,axleDiameter, stackOffset,   rootGear89,      stack,  0.0,   0.0,    0.00,     0.0,      0.0,           0.0,           0.0,           0.0,           0.0,           0.0

gear, 3monthStandoff,  18, toothSize, thickness, axleDiameter, 0.0,          rootGear79,      link,   timeAngle,  0.0,    1.0,      -1.0,      0.0,           0.0,           0.0,           0.0,           0.0,           0.0
gear, 3monthStandoff2,  18, toothSize, thickness, axleDiameter, 4.5,          3monthStandoff,   stack,   0.0,  0.0,    0.00,      0.0,      0.0,           0.0,           0.0,           0.0,           0.0,           0.0
gear, 3months55,         55, toothSize, thickness, axleDiameter, 0.0,          3monthStandoff2,  link,   180.0,  0.0,    0.00,    -1.0,      0.0,         10.0,           0.0,          0.3,           0.3,           0.0
//gear, 3months55,       55, toothSize, thickness, axleDiameter, 0.0,          rootGear79,      link,   0.0, 110.0,    0.00,    -1.0,      0.0,         10.0,           0.0,          0.3,           0.3,           0.0
gear, 3months10,       10, toothSize, thickness, axleDiameter, (-1.0*stackOffset),  3months55,       stack,  0.0,   0.0,    2.50,    -1.0,      0.0,           0.0,           0.0,          0.0,           0.0,           0.0
gear, monthsToYears30, 30, toothSize, thickness, axleDiameter, 0.0,          3months10,       link, -130.0,   0.0,    0.00,     0.0,      0.0,           0.0,           0.0,           0.0,           0.0,           0.0
gear, monthsToYears10, 10, toothSize, thickness, axleDiameter, (-1.5*stackOffset),  monthsToYears30, stack,  0.0,   0.0,    2.50,    -1.0,      0.0,           0.0,           0.0,           0.0,           0.0,           0.0
gear, 3years40,        40, toothSize, thickness, axleDiameter, 0.0,          monthsToYears10, link,  90.0,   0.0,    0.00,     0.0,      0.0,          7.0,                   0.0,       0.3,           0.3,           0.0

gear, 3years10,        10, toothSize, thickness, axleDiameter, (-3.0*stackOffset),  3years40,        stack,  0.0,   0.0,    2.50,    -1.0,      0.0,          0.0,           0.0,           0.0,            0.0,           0.0
gear, yearsToCentury60, 60, toothSize, thickness, axleDiameter, 0.0,          3years10,         link,  123.0,   0.0,    0.00,     0.0,      0.0,          0.0,           0.0,           0.0,            0.0,           0.0
gear, yearsToCentury10,  10, toothSize, thickness, axleDiameter, (-2.0*stackOffset),  yearsToCentury60,stack,  0.0,   0.0,    2.50,    -1.0,      0.0,          0.0,           0.0,           0.0,            0.0,           0.0
gear, century60,         60, toothSize, thickness, axleDiameter, 0.0,          yearsToCentury10, link,  180.0,   0.0,    1.00,     -1.0,      0.0,          0.0,           0.0,           0.0,            0.0,           0.0

gear, emoStandoff,     10, toothSize, thickness, axleDiameter, 0.0,          rootGear89,      link, emoAngle,  68.0,    1.00,   -1.0,      0.0,           0.0,           0.0,           0.0,           0.0,           0.0
gear, emotional19,     19, toothSize, thickness, axleDiameter, 0.0,          emoStandoff,      link,  0.0,  68.0,    1.50,     1.0,      0.0,           0.0,           0.0,           0.0,           0.0,           0.0
//gear, emotional19,     19, toothSize, thickness, axleDiameter, 0.0,          rootGear89,      link, 120.0, 120.0,    1.50,     1.0,      0.0,           0.0,           0.0,           0.0,           0.0,           0.0
gear, emotional28,     28, toothSize, thickness, axleDiameter, -stackOffset, emotional19,     stack,  0.0,   0.0,    0.00,     0.0,      0.0,           0.0,           0.0,           0.0,           0.0,           0.0
gear, physical23,      23, toothSize, thickness, axleDiameter, 0.0,          emotional28,     link, -90.0,   0.0,    1.50,     1.0,      0.0,           0.0,           0.0,           0.0,           0.0,           0.0
gear, intellectual33,  33, toothSize, thickness, axleDiameter, 0.0,          emotional28,     link,  90.0,   0.0,    1.50,     1.0,      0.0,           0.0,           0.0,           0.0,           0.0,           0.0
gear, [emotionalArrow],     10, toothSize, thickness, axleDiameter, -0.21, emotional28,         link,   0.0,   0.0,    1.50,     -0.1,      0.0,           0.0,           0.0,           0.0,           0.0,           0.6
gear, [physicalArrow],     10, toothSize, thickness, axleDiameter, 0.0, physical23,           link,  90.0,   0.0,    1.50,     -0.1,      0.0,           0.0,           0.0,           0.0,           0.0,           0.6
gear, [intellectualArrow],     10, toothSize, thickness, axleDiameter, 0.0, intellectual33,   link, -90.0,   0.0,    1.50,     -0.1,      0.0,           0.0,           0.0,           0.0,           0.0,           0.6
_________________________________________________________________________________