Go Down

Topic: Need some help with H11AA1 circuit (Read 434 times) previous topic - next topic


Just connect the end of the cap that is not connected to the opto, to +5V instead of ground.
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.


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.

Code: [Select]

//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()

  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();


  //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()
  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.


Aug 18, 2020, 06:37 am Last Edit: Aug 18, 2020, 06:39 am by larryd
Not sure what you are saying.

100ms is like a filter i.e. the A.C. has to disappear for 100ms then the solenoid LED goes out.

Do some experimenting with the sketch.

unsigned long dropoutInterval   = 100;
Change the line above to:
unsigned long dropoutInterval   = 10000;

You should see the solenoid LED go out 10 seconds after you let go of the switch.
If you tap the switch within the 10 second interval, the 10 second interval starts over.

You can make as many timers as you need.

No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.


Aug 18, 2020, 07:00 am Last Edit: Aug 18, 2020, 07:12 am by larryd
If you add the capacitor and diode into the schematic, you do not have to worry about filtering the output of the OPTO.

You can now treat the signal on pin 2 as if it was any other switch.

If you need to, tune the value of C1 try: 1uF or 0.1uF or 10uF.

No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.


Use a 47 to 100nF cap and put a 10k pullup resistor from +5V to the H11AA1 output pin, when you turn power on, that fat, discharged cap is pulling the input pin LOW until it can charge through the 30k internal pullup.
Is that a 220 Ohm pulldown resistor on the MOSFET gate? Should be at least 10k.
There is a 10k on the bottom for the MOSFET gate, the 220 Ohm is for the LCD.


Thank you to everyone for the help!

@larryd I did get it to work with the diode and cap, but I am going to try to rewrite since my program does create a slight problem. If the switch opens for a sec and the timer starts the countdown and the switch closes again the timer keeps going to zero and the solenoid does stay open until the next switch release and then the timer starts again.

So it does work, just not gracefully.

Go Up