What I am stumbling on is the DC output. I just want to turn off the HV pulse generator and keep everything else running. When I remove pin 6 from ground the output on pin 5 gets strange, going in cycles.
// const byte setFallingSwitch = 5;
// char risefall = 'R'; // default rising mode
//pinMode (setFallingSwitch, INPUT_PULLUP);
You have removed the pinMode for pin5 and it will be floating. I'm somewhat unclear about what you are trying to do with the R/F setting, and you have a conflict here as you are setting the start time for both R and F modes.
ISR(TIMER1_COMPA_vect) {
OCR1A = (timerTopValue); // value to set delay between pulses to trigger cdi
digitalWrite(chargePin, LOW); // guarantee off charge pin at trigger
digitalWrite(outputPin, HIGH); // turn on pin trigger
// if (risefall == 'R') // switch not set; default Rising trigger
{
delayPeriodStart = micros(); // start looking for response as pulse rises
trigger = true;
}
// start Timer 2 for charge pulses
if (chargePulse)
{
timeSliceCount = 0;
TCNT2 = 0;
OCR2A = timerTopValue/96; // set 12 periods
TCCR2B |= 1 << CS22 | 1 << CS21; //prescaleer 256 16us/tick
}
}
ISR(TIMER1_COMPB_vect) {
digitalWrite(outputPin, LOW);
// if (risefall == 'F') // switch set for Falling trigger
{
delayPeriodStart = micros(); // start looking for response as pulse falls
trigger = true;
}
}
I also want to keep the reporting of degrees advance in the DC mode.
I see in the last bi-polar pulse code we had
degreesAdvance = pickupValue - delayDegrees;
I think you can just add it here, and display it as you do in the bipolar sketch.
delayDegrees = pickup - (360.0 * (copy_delayPeriod) / (timerTopValue * 4.0)); // for decimal place in deg display.
degreesAdvance = pickupValue - delayDegrees;