I'm getting some unusual behavior from my solenoid (SolenoidTrPin). Here are 2 segments of code that "SolenoidTrPin" should behave the same way (30 ms press):
SolenoidTrPin and RelayPin are set to OUTPUT during setup.
SolenoidTrPin is a solenoid triggered by a transistor. RelayPin triggers a relay for another device function.
Using an ATTINY
ATTINY and all components draw power from a wall outlet. Regulators with filter caps reduce voltage to the amounts needed for the components
I can't change line 2 (has to do with warm-up time)
"SolenoidTrPin" does not quite behave the same in both cases. I'm not sure if this is what it is, but in executing code variant "B", there seems to be a "hop" at the end. It's like SolenoidTrPin loses power for an instant around line 5 and then re-energizes, resulting in a double-hit (hop). I need to know why this happens.
SolenoidTrPin needs to work flawlessly with it's timing, so I need to figure out what is going on. It seems that Variant A is more reliable, but then I can't change the timing of SolenoidTrPin without changing the timing of RelayPin (and remember that I can't change line2). Why doesn't Variant B perform as expected?
Before you go much (any?) further you should have a look at the approach used in the BlinkWithoutDelay example, also available in the IDE at File > Examples > 2.Digital
You may find a delay-less approach much better in the long-run, although you'll have to invest a bit of effort up-front.
weedpharma:
Do relays actually move in 10 to 20 millisec pulse on the coil?
I have the datasheet around here somewhere, but I'm pretty sure the answer is yes. But my concern is with the Solenoid/transistor timing, not the relay timing.