I have not yet had time but I plan to test whether the problem is reduced when there is no bootloader code on an Atmega MCU. That should mean that it gets to the servo.attach() in a millisec or less.
...R
I have not yet had time but I plan to test whether the problem is reduced when there is no bootloader code on an Atmega MCU. That should mean that it gets to the servo.attach() in a millisec or less.
...R
Hi all.
Can I ask for more advice please.
My servo problem is now slightly different.
The sudden surge of 20 degrees at power-up I can now cure by two steps:-
a) performing a servo.write before the servo.attach
b) by applying power to the servo after the two servo commands in step (a) above.
This gives a very slight kick as mentioned by ALKA's reply above.
Step b) is achieved by using a software controlled power-up pin used for another purpose (that is for IR leds used to provide beams for railway signals ‘interrupts’. The leds are controlled through a ULN2003 darlington array. All the inputs to the array are ganged to the aforementioned ‘power-up’ pin –pin 2 on my arduino mega.)
my idea was to apply power to the servo via the ULN2003 via the ‘power-up’ pin 2.
This works as planned and does stop the servo jump at power-up.
BUT (there’s always a but) now the servo buzzes. If I connect the power leads of the servo directly to external power supply the ‘buzz’ disappears but the jerk returns because I cannot delay the servo power-up.
Is there something I can do to continue with my ‘software’ control idea?
Would a capacitor across the servo power leads solve the problem? (i’ve not tried it in case I cause damage – at the edge of my knowledge and understanding).
hope that all makes sense
Ps in case someone asks the servo negative is connected to the ouput of the ULN2003 and the positive connected to my 5V rail.
Many thanks ins advance.
Have you tried servo.detach after its moved where you want it?
How is the ground connected to the Arduino? Is it connected to the servo negative or the uln2003 ground?
alka:
Have you tried servo.detach after its moved where you want it?How is the ground connected to the Arduino? Is it connected to the servo negative or the uln2003 ground?
Have not tried detach. Will now do so.
(I've got several 'sort of' sub-systems on the model layout. I've used a 'recycled' PC power supply for all these sub-systems. So that all grounds are tied together. Or should be. The arduino ground is connected to the ULN2003 ground.
Servo negative is connected to the number six output of the ULN2003 - ULN2003 number six input is connected to the 'power-up' pin of the arduino. Positive of the servo is connected to the 5V rail.)
will let you know on the detach.
colubridae:
Ps in case someone asks the servo negative is connected to the ouput of the ULN2003 and the positive connected to my 5V rail.
Why not just use a relay?
...R
Robin2:
Why not just use a relay?...R
Probably because we both told him a transistor would be better!
alka:
Probably because we both told him a transistor would be better!
Fair enough. I had forgotten.
@colubridae, another thing that just occurred to me - you say "Servo negative is connected to the number six output of the ULN2003". That probably means that the servo power GND is not the same as the signal GND. Put the ULN2003 (or a simple transistor) on the + side of the servo power supply.
And I assume you are NOT powering the servo from the Arduino 5v pin.
...R
Robin2:
Fair enough. I had forgotten.@colubridae, another thing that just occurred to me - you say "Servo negative is connected to the number six output of the ULN2003". That probably means that the servo power GND is not the same as the signal GND. Put the ULN2003 (or a simple transistor) on the + side of the servo power supply.
And I assume you are NOT powering the servo from the Arduino 5v pin.
...R
The servo +ve is connect to an external 5V rail.
Servo ground is definitely not the same as arduino ground, therefore not the same as the signal ground. I had stupidly not considered this. If my understating is correct the current must run up from the ground of the ULN2003 to its output pins.
ULN2003 must be (and is) grounded the same as arduino ground (i think). I suspect you have pinpointed the problem right there, though. For this to work as I want I will have to stop using the spare ‘port’ on the ULN2003 and simply use a separate transistor between the servo and the positive rail.
The ‘strange’ thing is that using the ULN2003 works as expected – except for the buzzing.
Should I browse rapid online (I buy all my stuff there) and look for an NPN transistor to switch power to the servo on and off? (the whole point of the software controlled on/off is to prevent the servo startup jerk) – I assume I can still use the voltage from the ‘power-up’ pin (pin 2) whilst that voltage also still being used for my ULN2003 powering my IR lEDs?
That is pin 2 voltage runs to the base of the transistor, emitter to the positive of the servo and collector to the 5V rail.
many thanks for your help.
I was wondering how it would go with the darlington. It has a 1.2v drop so the servo would be getting a signal that was -1.2 to 3.8 compared to its ground if it was getting a 0 to 5v input. A MOSFET for its low resistance or even a PNP would work. If you switch before the servo the grounds are the same.
alka:
I was wondering how it would go with the darlington. It has a 1.2v drop so the servo would be getting a signal that was -1.2 to 3.8 compared to its ground if it was getting a 0 to 5v input. A MOSFET for its low resistance or even a PNP would work. If you switch before the servo the grounds are the same.
Thanks ALKA
alka:
If you switch before the servo the grounds are the same.
Maybe I misunderstand but that sounds like asking the Arduino to saw through the branch it is sitting on
Also, the whole point of the exercise is to switch the servo on a little later than everything else.
@colubridae, if this was my project I would just put the switch on the servo V+ line. And, sorry, I am not proficient enough to offer advice on transistor or mosfet selection. I just work my limited analog electronics on the suck-it-and-see principle.
...R
Robin2:
Maybe I misunderstand but that sounds like asking the Arduino to saw through the branch it is sitting on
Also, the whole point of the exercise is to switch the servo on a little later than everything else.@colubridae, if this was my project I would just put the switch on the servo V+ line. And, sorry, I am not proficient enough to offer advice on transistor or mosfet selection. I just work my limited analog electronics on the suck-it-and-see principle.
...R
ALKA
putting a mosfet/bjt switch below the servo still mismatches the grounds.
Thanks for your advice anyway.
ROBIN"
I’m pretty much flying by the seat of my pants and trying out various options.
ALKA suggested a mosfet for its low resistance which seems like a good idea.
Also points the fact that by using the ULN2003 as a switch for the servo I’m the putting the servo below its quoted operational voltage.
Sorry, switching before the load might not be the best way to word it.
I mean switching high side rather than low side, ie with a PNP transistor or p-channel MOSFET.
That puts the ground of the load at the same potential as the Arduino ground.
alka:
I mean switching high side rather than low side,
Yes. That is what I have had in mind.
...R
Keep in mind you cannot use a NPN bjt or N-FET if you switch high side. Must be P-Channel unless you find some way of keeping your gate voltage well above threshold (charge pump) when the MOSFET is conducting.
If your source voltage is the same or less as your switching voltage (and under the 5v arduino limit) you can get by without the second NPN transistor driving the gate of the P-FET.
alka:
Keep in mind you cannot use a NPN bjt or N-FET if you switch high side. Must be P-Channel unless you find some way of keeping your gate voltage well above threshold (charge pump) when the MOSFET is conducting.If your source voltage is the same or less as your switching voltage (and under the 5v arduino limit) you can get by without the second NPN transistor driving the gate of the P-FET.
Bugger! I did not know that.
Thanks for the circuit diagram. I will need a few days to figure them out.
Sorry I misunderstood your meaning.