- Fri Mar 30, 2012 12:49 pm
#142144
OK, here goes.
In all cases, the gearbox shouldn't stop cranking until it is in a "good spot", AND the trigger is off.
This saves us on debounce issues.
If the trigger is pressed, the gearbox fires a round and increments the round counter. The motor continues to run until the round is fired.
In SA mode we have the following flow:
If the trigger is depressed, immediately start cranking the gearbox (we don't need to debounce this)
After the shot is fired, stop cranking the gearbox.
Make sure the trigger is "Latched" (Do not progress until the trigger is released. THIS we need to debounce. We're not going to allow another initiation of the gearbox for a "debounce period")
In "Explicit Burst Mode" we have the following pseudo-code:
If the trigger is depressed, the gearbox starts cranking.
After the gearbox cycles it increments the burst-fire tracker. If the burst-fire tracker is less than the burst setting, the system continues to crank. If it equals (or exceeds) the burst setting, it stops the gearbox.
Again, we "latch" the trigger, again paying attention to debounce.
In "Command Burst Mode" the following code:
If the trigger is depressed, the gearbox starts cranking.
After the gearbox cycles it increments the burst-fire tracker. If the burst-fire tracker is less than the burst setting, AND the trigger is still depressed (no worries about debounce here), the system continues to fire. If it equals (or exceeds) the burst setting, it stops the gearbox (regardless of the trigger state).
Again, we "latch" the trigger, paying attention to debounce.
In "Full-Auto":
If the trigger is depressed, the gearbox starts cranking.
After the gearbox cycles, we check the trigger state. If it is still depressed (no worries about debounce) we continue firing. If not, we stop the gearbox.
In every case, we don't check the trigger until immediately after the round is fired. If the system is not supposed to fire again (due to trigger/burst issues), the motor stops immediately. This will stop the gearbox at with the spring as uncompressed as possible (we can't stop the motor before the spring is released). If the trigger is released AFTER this point, the motor is already starting to compress the spring, we should just fire the shot. In any case, the motor stops with the spring in the extended position.
If we "surrender" to the limitations of the system, we can almost ignore debounce completely. We only need to watch for it when the trigger is released, because a "bounce" could initiate an uncommanded discharge.
We literally don't care about the position of the trigger during the firing sequence. Once the system is commanded to fire, it's going to fire. It will continue firing until the gearbox cycles. Then it will check the conditions for a valid continuation of the firing process.
Static