Digigurdy-baz
Loading...
Searching...
No Matches
Variables
Gear-Motor Crank Configuration Variables

Variables

const int SPIN_SAMPLES = 700
 The number of voltage samples per update. More...
 
const int VOL_THRESHOLD = 5
 The lower voltage threshold for the crank to register motion. More...
 
const int MAX_SPIN = 7600
 The maximum "spin" value. More...
 
const int SPIN_WEIGHT = 2500
 The amount of spin to add when motion is detected. More...
 
const int SPIN_DECAY = 200
 The amount of spin to subtract when motion is not detected. More...
 
const int SPIN_THRESHOLD = 5001
 The amount of spin necessary to make sound. More...
 
const int SPIN_STOP_THRESHOLD = 1000
 The amount of spin below which sound stops. More...
 
const int BUZZ_SMOOTHING = 250
 The amount of buzz "smoothing" to start with when buzzing registers. More...
 
const int BUZZ_DECAY = 1
 The amount of buzz "smoothing" to subtract when buzzing is not registering. More...
 

Detailed Description

These are configuration variables that only apply to gear-motor-crank models.

USE_GEAR_CRANK must be enabled for these to have effect.

Variable Documentation

◆ BUZZ_DECAY

const int BUZZ_DECAY = 1

The amount of buzz "smoothing" to subtract when buzzing is not registering.

Buzz smoothing is subtracted by this amount every cycle that buzz does not register.

  • This produces a set delay for buzzing to stop, as well as a minimum buzz duration.

◆ BUZZ_SMOOTHING

const int BUZZ_SMOOTHING = 250

The amount of buzz "smoothing" to start with when buzzing registers.

  • When the crank voltage registers higer than the buzz knob's voltage, buzzing registers.

Buzz is set to this value when buzzing registers and decays.

  • The buzzing effect continues as long as this smoothing value is positive

◆ MAX_SPIN

const int MAX_SPIN = 7600

The maximum "spin" value.

Gear crank behavior uses a "spin" number to determine motion, which is added to when cranking is detected, and subtracted from when cranking stops. This is the maximum spin value the counter will allow.

◆ SPIN_DECAY

const int SPIN_DECAY = 200

The amount of spin to subtract when motion is not detected.

Every cycle that cranking is not detected, this amount is subtracted from the spin value, down to zero.

  • This should be significantly less than SPIN_WEIGHT in order to give a smoothing effect, as the geared cranks induce a voltage in steps, not smoothly.
  • If you have a rectifier on your crank to register motion in both directions, you also don't want it to be too low as to smooth over direction changes entierly.

◆ SPIN_SAMPLES

const int SPIN_SAMPLES = 700

The number of voltage samples per update.

This is used to slow down how fast the code runs and avoid timing issues. Choose based on your Teensy unit:

  • Teensy3.5 @ 120MHz = 700 <– full 3.5 speed
  • Teensy3.5 @ 72Mhz = 240 <– probably too slow now
  • Teensy3.5 @ 48Mhz = 100 <– probably too slow now
  • Teensy4.1 @ 600MHz ~ 3850 <– full 4.1 speed
  • Teensy4.1 @ 150Mhz ~ 1150 <– seems fine, fast enough, but why do this?

◆ SPIN_STOP_THRESHOLD

const int SPIN_STOP_THRESHOLD = 1000

The amount of spin below which sound stops.

Sound will stop when spin is below this value.

  • Note that it is signficantly lower than SPIN_THRESHOLD.

◆ SPIN_THRESHOLD

const int SPIN_THRESHOLD = 5001

The amount of spin necessary to make sound.

Ultimately, sound will be produced when spin is above this value.

◆ SPIN_WEIGHT

const int SPIN_WEIGHT = 2500

The amount of spin to add when motion is detected.

Every cycle that cranking is detected, this amount is added to the spin value, up to the MAX_SPIN.

◆ VOL_THRESHOLD

const int VOL_THRESHOLD = 5

The lower voltage threshold for the crank to register motion.

  • Voltage values are reported between 0-1023, with 0 = 0V and 1023 being 3.3V.
  • This should generally be set as low as possible to be sensitive but not register "phantom" cranking.