Need some help with H11AA1 circuit

larryd:
Can you follow how a timer can be set up to monitor a 120/100 Herz signal (no capacitor needed) ?

I think I can, and I will try! (very amateur programmer)

Is the 100ms the monitor against the frequency? If so, I would need to add another timer after switch release of desired time after myTimerFlag = false; before dropSolenoid.

Note: The A.C. going to the H11AA1 will produce 120/100 hertz at the collector pin 5.

//When the switch is pushed, the solenoid is picked

//While the switch is pushed the solenoid remains picked
//When the switch is released, the solenoid drops out after ≈100ms

#define pickSolenoid            HIGH
#define dropSolenoid            LOW
#define PUSHED                  LOW

const byte heartbeatLED         = 13;
const byte solenoidPin          = 8;
const byte mySwitch             = 2;

//const byte tonePin              = 3;

byte lastState                  = 0;

boolean myTimerFlag             = false;

unsigned long heartbeatMillis;
unsigned long switchMillis;
unsigned long myTimerMillis;

unsigned long heartbeatInterval = 500;
unsigned long switchInterval    = 10;
unsigned long dropoutInterval   = 100;

//*********************************************************************
void setup()
{
 Serial.begin(9600);

pinMode(heartbeatLED, OUTPUT);
 pinMode(solenoidPin, OUTPUT);

pinMode(mySwitch, INPUT_PULLUP);

//  pinMode(tonePin, OUTPUT);
//  tone(tonePin, 120);

} //END of setup()

//*********************************************************************
void loop()
{
 //***************************
 //time to toggle the heartbeat LED ?
 if (millis() - heartbeatMillis >= heartbeatInterval)
 {
   heartbeatMillis = millis();

digitalWrite(heartbeatLED, !digitalRead(heartbeatLED));
 }

//***************************
 //time to sample the switches ?
 if (millis() - switchMillis >= switchInterval)
 {
   //reset Timer
   switchMillis = millis();

checkSwitches();
 }

//***************************
 //has the myTimer expired ?
 if (myTimerFlag == true && millis() - myTimerMillis >= dropoutInterval)
 {
   //disable Timer
   myTimerFlag = false;

digitalWrite(solenoidPin, dropSolenoid);
   Serial.println("The solenoid has been dropped");
 }

//***************************
 // other non blocking code
 //***************************

} //END of loop()

//*********************************************************************
void checkSwitches()
{
 //mySwitch
 byte currentState = digitalRead(mySwitch);

if (lastState != currentState)
 {
   //update to the new state
   lastState = currentState;

//is the switch pressed ?
   if (currentState == PUSHED)
   {
     digitalWrite(solenoidPin, pickSolenoid);

//restart TIMER
     myTimerMillis = millis();

//enable the Timer
     myTimerFlag = true;
   }
 }

//other switches

} //END of  checkSwitches()

//*********************************************************************







---



As an alternative, you can place a diode in series with the 4.7k resistor and add a filter capacitor. 

The resulting DC voltage will now feed the H11AA1 rather than A.C.

Are there guides or charts on figuring the filter capacitor value?

I found this Cfilt=Po / ωVoVr

where power must be processed by the system (Po), the frequency of the AC voltage (ω radians per second), the output voltage (Vo) and the peak-to-peak voltage ripple allowable (Vr)

So would I be close to assume that the Po and the Vo would come from the datasheet for the H11AA1 and the Vr would be small enough to stay within the Vmin and Vmax?

If I am way overthinking this feel free to tell me, I can take it.

Thank you for the direction pointing.