Go Down

Topic: Arduino Motor Shield Stepper Motor control with Joystick (Read 18998 times) previous topic - next topic


noisyvoid thanks for varying the code. Urm for TheBlommie sorry if i didnt not help you much...


Thanks to both you guys for your help. I appreciate it very much and I think was a good learning curve for other out there who also intend to drive stepper motors with joysticks modules.


Hi Ash

I had a few trials and errors so far. I eventually got the setup going with the code you provided as well as other code I found. However, when I tried to connect a 12VDC,3A power supply to the motor shield, I accidentally caused damage to my arduino board. So I bought a new one and did some research on power supplies for both the arduino and the motor shield and came to the conclusion that the arduino and motor shield must rather be powered up with their own power supplies. So hooked up my arduino to a 5VDC,2000mA unregulated power supply and the motor shield to a 12VDC,1000mA regulated supply and it seemed to work quite well although the motor shield overheated quite a bit. At htis point in time I didn't connect the thumb joystick because when I first connected the 12VDC powers upply to the motor shield in the beginning, the problem occured when I gave power to the joystick when my computer shut down and the arduino board got damaged. The joystick was connected to the pins on top of the motor shield when this happened. So I suspect that the thumb joystick couldn't handle the voltage and current and therefore shorted out something on the arduino.

I also purchased a proto screw shield which is now connected between the arduino and my motor shield so I can fasten the wires properly for a better arcade joystick I purchased. The arduino has its own power supply (5VDC,2000mA), the proto screw shield draws its power from the arduino's power supply and the motor shield has its own power supply (12VDC,1000mA). I also cut the extension pin for the Vin on the motor shield underneath the board so it doesn't draw power from the arduino. I hope this will overcome any shortage problems to the arduino and proto screw shields.

My question though is simple... Will my arcade joystick work if I connect it to the proto screw shield on the specified pins while both the arduino and the motor shield is powered with their repsective power supplies? I'm a little scared to just hook it up just to short out something...

Have a look at the drawing so you can see my setup.



hi TheBlommie,

I'm sorry to hear that happen to you, the reason that happen was because the arduino cant handle any current more then 40mA if i am not mistaken, however let me assure you that in any case, the pot can handle much more abuse then the arduino, a pot is just a variable resistor.
for you to connect the pot is 5V from the arduino connect to the end while the other end is connected to the gnd of any board,only the middle pin need to be connected at port A2. remember don't just take the power from the motor shield due to the arduino max voltage is 5vdc


Well, for the moment the Arduino board seems to be working quite well with the 5VDC,2000mA power supply. My biggest concern is the joystick. With the Vin extension pin cut underneath my motor shield board, there shouldn't be a way for the joystick to be affected by the motor shield's power supply, right? Or am I wrong to assume this?

And also, why do you think the motor shield is overheating with the 12VDC, 1000mA power supply? The board can actually handle up to 2amps per channel or 4amps in total if you drive a stepper motor and the operating voltage is 12V. Can I perhaps incorporate a PC fan into the box that I'll be using to enclose the boards so it can stay relatively cool? Will this help?

Thanks for your advice so far.


hay welcome, anyway yeah since the pot is connected only to the arduino, it won't be affected by the motor shield, how ever i would recommend to you to find a higher unregulated supply of between 7 to 12 if you powering the arduino. this is due to the on board voltage regulator, there must at least have a minimum of 2 volt higher then the regulated output of 5 V. however if you supply the board with 5 volt, arduino probably only get something less then 5v. however this does not meat that the board cant function, just the operation is not optimal. anyway about the motor shield yes it is suppose to be hot, this is due to the amount of current flowing thru the I298 ic. it is wise if you could make a heat sink for the ic of like you suggest putting a fan might help too. or maybe both is better.


Hey Ash, sorry jump between posts, but I'm busy playing with various options etc. Okay, so I've tested the stepper motor control with the thumb joystick as per the connection setup I showed you in the picture and it seemed to work just well. However, when the joystick is not moved, the stepper motor has some sort of vibration. It doesn't rotate when the joystick is not pressed, but there is some vibration going on and the motor shield is heating up to such a point where you can actually smell it. The voltage for the stepper motor shield was set at 9VDC, 1000mA. It uses a power supply which can be set to specific voltages ranging from 3-12V. The Arduino board was using its own 5VDC, 2000mA power supply.

Any ideas on how I can make it better or do something different? You mentioned using a heat sink... How do I connect it to the motor shield? Attached is a picture of the motor shield...



from what i can say it that the motor when it is not moving it draw a lot of current to make it stand still, i can say that the motor need to been a low current mode when not moving. there a few way you could do this, did you know that at port A0 and A1 of the motor shield there is a current monitoring circuit. actually it is build in into 298 ic. that is you need to read the voltage value using analogread on port A0 and A1. this part i dont really know how since the page
http://arduino.cc/en/Main/ArduinoMotorShieldR3 talk very little about this feature. what is only said that 3.3V is calibrated to be equalvelent to 2Amp. what i do not know is, is the 3.3V mean 1023 in analog read or if it is just a value in the middle so that you could stop the motor b4 the current get to high? anyway in the program i gave you b4 there is one missing link
Code: [Select]
if (PVal >= 507 || PVal <= 517)
  { // fill in with the one you need to make it brake

since i dont have the shield i cant test how to make it stop safely. i hope you could fill in the program
however my fair guess is that you need to turn the pwm LOW for both. This should reduce the amount of current running thru the coil thus making it cooler.

Code: [Select]
if (PVal >= 507 || PVal <= 517)
{digitalWrite(pwm_cha, LOW);
    digitalWrite(pwm_chb, LOW);}

however you must update the other part of the program with
Code: [Select]
digitalWrite(pwm_cha, HIGH);
    digitalWrite(pwm_chb, HIGH);

at every other if statement immediately after the {

for the heat sink just use any regular metal block. if you could find one that is small enough for the biggest IC on board that is 298 with fin, that would be great, plus if you have some thermal paste between the heat sink and the ic would be great. there is no mounting hole that you could use hold the heat sink. so although most of the time i would not recommend this but use some glue to make it hold. not much just a small dot at the edge so that it is enough to hold the heat sink is suffice.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131