I'm using a TIP 122 fed from a digital pin on an arduino mega to switch the power to a 12v 330mw actuator.
Intermittently from powering the circuit up I'm only getting 7v at the actuator rather than the 16v the power supply is pushing out. Other times the circuit fires up and works as it's meant to, other times after several minutes of problems, it will start to operate correctly.
The code I'm using does this;
int S1pin50 = 50;
in void setup
pinMode (S1pin50, OUTPUT);
digitalWrite (S1pin50, LOW);
in void loop
//when the actuator is fired
digitalWrite (S1pin50,HIGH);
// to turn it off
digitalWrite (S1pin50,LOW);
I think the code above will stop the output from the mega wandering, but that's what I think is happening, so my suspicions go to the resistor values I'm using.
I've seen various circuits that use the TIP122 use anything from no resistor to those with a 10k resistor in circuit. I have a 7k53 in the circuit at the moment.
A wider search of circuits that have a 5v trigger and use the TIP122 seem to use 1k for the value of this resistor.
Can anyone advise on a value that will work in this type of application or am I barking up the wrong tree here??
Well first your posted code is not a real sketch, it would never compile, so it's hard to tell what you are trying to do. Are you wishing to turn on the actuator fully on and for how long?
The code you show implies a looping of on and off to the output pin, simulating a high speed PWM with 50% output which would definitely not apply a full 12vdc across the actuator.
So if you could post a real sketch and possible a wiring diagram of what you have, it might be easier for us to help.
PS: Your post title is a little misleading. Pull-ups and pull-downs in the Arduino world applies to digital input pins only, not output pins, which can already source or sink up to a 40ma max rating.
Thanks for the reply Lefty, please accept my apologies.
I understand that the code is not a real sketch, the full sketch is rather long and the only parts of the sketch that apply to the pin in question are those elements I included in the previous post.
There is a delay in the actual code between the open command and close command which is varied by a keyboard input between 40 milliseconds and 8 seconds, this information is also displayed on an LCD and implemented via a switch.
As the circuit "sometimes" works and I'm trying to troubleshoot this and learn and understand more about it at the same time, I mentioned only the parts I am currently investigating and think might be problematic.
I certainly did not know that
Pull-ups and pull-downs in the Arduino world applies to digital input pins only, not output pins,
(That came as a shock to the system!) My belief is was that the output of an arduino pin would "float" as we discussed in another thread about buttons.
My confusion with my circuit and the naming of this thread seems to lie with my thinking that the "output" of 5v from an arduino pin through a switch to ground is an output rather than an input???
I don't have a wiring diagram for the circuit as I'm still, er, experimenting with it! The closest match I found was for a solenoid link below.
All the TIP 122 circuits I have seen have a resistor between the arduino and the collector, presumably this serves a purpose other than to pull the output in a specific direction?
You are getting input pins and output pins confused or mixed up.
Input pins read a value from the outside world, either digital or analog inputs. For digital input pins, if you don't wire a load (pull-up or down resistor, or an external sinking and sourcing voltage, then it will 'float' and not give valid values when reading the pin.
Output pins supply a low or high (+5vdc) voltage when writting to the output pin, they never 'float', there are either high or low of switching between high and low (as when doing a PWM analogWrite command).
The reason you see a resistor wired from a output pin to the base of a external transistor is to supply and limit the output current from the pin. Drawing too much current (over 40ma) will damage the pin, supplying too little current will prevent the transistor from fully turning on.
So keep you inputs and output straight in you head, they are two different modes of operation. What can confuse new comers it that a digital pin can be either a input or output at any given time depending on how you program the pin with the mode command (example: pinMode(ledPin, OUTPUT); // sets the digital pin as output).