beginner dc motor issues

Drive a 4-wire bipolar stepper motor or a pair of DC motors from your Arduino. [Product page]
Post Reply
jkennedy_87
Posts: 4
Joined: Tue May 20, 2014 12:39 pm

beginner dc motor issues

Post by jkennedy_87 » Tue May 20, 2014 1:35 pm

hey all i am new here this is my first post so apologies for any stupid questions.

i am looking to power a 55rpm geared 12v dc motor from my arduino. it is for a camera dolly so also has two limit switches at each end of a rail that wen hit i want to reverse the motor and go the other way.the dolly is for night time lapse photography so i want to move the dolly 5 mm then stop it for 20 seconds to expose image then move it another 5mm then stop and so on until limit is hit then reverse. i have the motor and i have a h bridge motor driver shield and an arduino eleven board and the limit switches.
i have written a tiny amount of code but im not the best with it so my questions are as follows

. if i power the motor power at 12v can i bridge the vin and motor power to power the board or is 12v to much?

. what pin do i jump the vin to? eg where is the motor power pin?

. how do i write the code to reverse motor?

. how do i write code to run the motor at half speed?


in summary i would like to run a motor at half speed for short bursts then stop it for a given time to take a picture then continue a short burst then hit a limit and do the whole thing in reverse.
sorry for the vaugue questions as i said im new to this and any help would be appreciated

thanks Jake

andrew
Freetronics Staff
Freetronics Staff
Posts: 978
Joined: Sun Jul 14, 2013 7:06 am
Location: Melbourne, Australia
Contact:

Re: beginner dc motor issues

Post by andrew » Tue May 20, 2014 11:03 pm

Please review the HBRIDGE guide:
http://www.freetronics.com/pages/hbridg ... tart-guide

It discusses motor control, power connections and has some example sketches.

jkennedy_87
Posts: 4
Joined: Tue May 20, 2014 12:39 pm

Re: beginner dc motor issues

Post by jkennedy_87 » Wed May 21, 2014 1:31 am

thanks john

i have gone through that pretty well and it makes a little more sense now. can i ask why the serial begin and serial print in are there? are they needed?
i want my motor to run wen one limit switch is high and the other is low then vise versa.

thanks

jkennedy_87
Posts: 4
Joined: Tue May 20, 2014 12:39 pm

Re: beginner dc motor issues

Post by jkennedy_87 » Wed May 21, 2014 1:33 am

also sorry for all the stupid questions but when i solder a jumper to the vin where does the other end solder to or do i just put it into the motor power positive terminal.

thanks again

andrew
Freetronics Staff
Freetronics Staff
Posts: 978
Joined: Sun Jul 14, 2013 7:06 am
Location: Melbourne, Australia
Contact:

Re: beginner dc motor issues

Post by andrew » Wed May 21, 2014 11:14 am

The Serial statements are used to show the progress of the sketch and motor in the serial monitor when running - and optional.

There's no need to solder anything to the Vin jumper, if you want to power the Arduino from the motor power supply just put the little plastic jumper over the two pins. Your Arduino can run from 12 V.

The analogWrite functions in the example sketch have the motors running at full speed (255), for half use 127 etc. This uses pulse-width modulation.

http://arduino.cc/en/Tutorial/PWM

If you are new to the world of Arduino it's a good idea to review some of the various tutorials available on the Internet, or get a good book for beginners such as "Arduino Workshop":
http://www.freetronics.com/collections/ ... o-workshop
use coupon code "SC14A" for 20% off
John

jkennedy_87
Posts: 4
Joined: Tue May 20, 2014 12:39 pm

Re: beginner dc motor issues

Post by jkennedy_87 » Thu May 22, 2014 1:07 pm

hey thanks for all the help i am getting there slowly i think

i would like some help with one more problem. i am using the h bridge to drive motor but i want to know what in the code makes the motor stop.
is there a motor stop command?

thanks heaps

andrew
Freetronics Staff
Freetronics Staff
Posts: 978
Joined: Sun Jul 14, 2013 7:06 am
Location: Melbourne, Australia
Contact:

Re: beginner dc motor issues

Post by andrew » Thu May 22, 2014 10:57 pm

jkennedy_87 wrote:hey thanks for all the help i am getting there slowly i think

i would like some help with one more problem. i am using the h bridge to drive motor but i want to know what in the code makes the motor stop.
is there a motor stop command?

thanks heaps
From the example sketch, this turns both outputs off:

Code: Select all

 digitalWrite( 4, LOW );
  digitalWrite( 7, LOW );
  digitalWrite( 6, LOW );
  digitalWrite( 3, LOW );
  digitalWrite( 2, LOW );
  digitalWrite( 5, LOW );

Trevor
Posts: 1
Joined: Thu Nov 06, 2014 10:56 pm

Re: beginner dc motor issues

Post by Trevor » Thu Nov 06, 2014 11:09 pm

Hi,
I'm newer to this than the original poster. He asks about soldering jumpers. My new H bridge shield appears to have jumpers already soldered to the "Bridge VIN to motor power" and 3 jumpers connecting each of channels A and B (ie for Channel A jumpers connect IN1 to D4, IN2 to D7 and EN to D6. For channel B the corresponding connections are In3:D3, IN4:D2 and EN:D5). The latter sets of jumpers appear to be necessary. But the documentation provides for the "Bridge VIN to motor power" jumper to be optional. Is the documentation not up to date with the boards in that connecting jumpers is recommended but they're already connected? Or have I completely missed something?

Further, the features include the following: "Min 8V Max 40V 2A peak rating". I was planning to use a 2S battery for my project, giving me 7.2V. Will this not work?

andrew
Freetronics Staff
Freetronics Staff
Posts: 978
Joined: Sun Jul 14, 2013 7:06 am
Location: Melbourne, Australia
Contact:

Re: beginner dc motor issues

Post by andrew » Fri Nov 07, 2014 2:42 am

Trevor wrote:Hi,
I'm newer to this than the original poster. He asks about soldering jumpers. My new H bridge shield appears to have jumpers already soldered to the "Bridge VIN to motor power" and 3 jumpers connecting each of channels A and B (ie for Channel A jumpers connect IN1 to D4, IN2 to D7 and EN to D6. For channel B the corresponding connections are In3:D3, IN4:D2 and EN:D5). The latter sets of jumpers appear to be necessary. But the documentation provides for the "Bridge VIN to motor power" jumper to be optional. Is the documentation not up to date with the boards in that connecting jumpers is recommended but they're already connected? Or have I completely missed something?

Further, the features include the following: "Min 8V Max 40V 2A peak rating". I was planning to use a 2S battery for my project, giving me 7.2V. Will this not work?
The jumpers are pre-fitted at the factory, however you can lift them off easily.
You will need a motor voltage and supply between 8 and 40V DC.

Post Reply