Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Adafruit Motor Shield Driver


  • Please log in to reply
10 replies to this topic

#1 Arron Chapman

Arron Chapman

    Advanced Member

  • Members
  • PipPipPip
  • 289 posts
  • LocationOregon, USA

Posted 02 August 2011 - 08:49 PM

I ported the Adafruit Motor Shield driver from TinyCRL (for the Fez) over to the Netduino, and now have a driver which supports steppers (2 at a time either on M1&M2 or M3&M4) as well 4 DC motors (M1, M2, M3, M4). I've had success using this shield with 2 DCs and 1 Stepper simultaneously. The driver still needs some refinment, and some easier to use methods, but overall I think it is working well. This is the test code I'm using:
Mshield MyMotors = new Mshield(Mshield.Drivers.Both);

            PWM servo = new PWM(MyMotors.Servo1);

            bool ledState = false;
            OutputPort led = new OutputPort(Pins.ONBOARD_LED, ledState);

            while (true)
            {
                ledState = !ledState;
                led.Write(ledState);

                // We have one motor connected on port M4 (Warning ! on some shields, M3 and M4 indications are reversed !)
                // Increase its speed to its maximum. Direction change at each loop
                for (int i = 0; i <= 255; i++, Thread.Sleep(20)) MyMotors.MotorControl(Mshield.Motors.M4, (byte)i, ledState);
                // Then decrease it to zero
                for (int i = 255; i >= 0; i--, Thread.Sleep(20)) MyMotors.MotorControl(Mshield.Motors.M4, (byte)i, ledState);
                Thread.Sleep(1000);

                // We have one stepper connected on driver1 (M1 + M2 ports)
                // Have it run 5s in "Hi-Torque" (High power, high speed, high power usage...)
                MyMotors.StepperMove(Mshield.Steppers.S1, Mshield.BipolarStepping.HiTorque, 0, true, 0, 5000, false);
                Thread.Sleep(1000);

                // Then 5s in the other direction
                MyMotors.StepperMove(Mshield.Steppers.S1, Mshield.BipolarStepping.HiTorque, 0, false, 0, 5000, false);
                Thread.Sleep(1000);
            }

To be clear the only changes I made to this driver were what was strictly necessary to make it work on the Netduino. I have maintained all of the original authors comments and code.

Attached Files


When you talk EE use small words, I'm just a Software Developer :)
My Blog/Site and Everything Else

If my post helped you please consider pressing the "Like This" button in the bottom right-hand corner.

 

Oh my. So many things, so little money!!

 


#2 JacopoMTK

JacopoMTK

    Member

  • Members
  • PipPip
  • 26 posts

Posted 15 July 2012 - 08:52 AM

Thanks a lot for posting your driver,a couple of question: -With Adafruit Motor shield and this driver,is it possible to driver 2 stepper (setting direction/speed/steps)? -Will i be able to use Digital/Analog netduino port unused by the shield after putting it over the netduino? Thanks in advance.

#3 Arron Chapman

Arron Chapman

    Advanced Member

  • Members
  • PipPipPip
  • 289 posts
  • LocationOregon, USA

Posted 15 July 2012 - 08:24 PM

-With Adafruit Motor shield and this driver,is it possible to driver 2 stepper (setting direction/speed/steps)?


I don't recall off-hand, but I believe you can.

-Will i be able to use Digital/Analog netduino port unused by the shield after putting it over the netduino?


Yes.

When you talk EE use small words, I'm just a Software Developer :)
My Blog/Site and Everything Else

If my post helped you please consider pressing the "Like This" button in the bottom right-hand corner.

 

Oh my. So many things, so little money!!

 


#4 JacopoMTK

JacopoMTK

    Member

  • Members
  • PipPip
  • 26 posts

Posted 16 July 2012 - 08:35 AM

Perfect,as soon that the board and the motors arrive i'll try it! Thanks! ---------- Tried it with 2 stepper motors and works fine!

#5 der_tank

der_tank

    New Member

  • Members
  • Pip
  • 5 posts

Posted 26 November 2012 - 09:03 AM

Hi there, I am new to netduino and the adafruit motor shield. I am planning to use this combination to drive a DC motor controlled by my netduino plus. I read pretty much about how to connect the motor shield to the netduino and I am currently a little bit confused. I read something about the pin layout of the shield that should not be 100% compatible with the netduino. Is this true? Or can I just put the motor shield to the netduino and use it straight forward? Can I use COM1 in combination to the motor shield? I want to use a BlueSmirf bluetooth module as well. Thx!

#6 JacopoMTK

JacopoMTK

    Member

  • Members
  • PipPip
  • 26 posts

Posted 26 November 2012 - 02:00 PM

Hi there,
I am new to netduino and the adafruit motor shield. I am planning to use this combination to drive a DC motor controlled by my netduino plus. I read pretty much about how to connect the motor shield to the netduino and I am currently a little bit confused.
I read something about the pin layout of the shield that should not be 100% compatible with the netduino. Is this true? Or can I just put the motor shield to the netduino and use it straight forward? Can I use COM1 in combination to the motor shield? I want to use a BlueSmirf bluetooth module as well.

Thx!


Hi,

I successfully used two of these shields to drive 3 stepper motors with NETDUINO (not plus but it should be the same)
If you don't have to use servos,using 2 shields let 5 pins free: 0,1,2,9,10 (using 1 will let 6 pins free)
-So yes,you can use the COM1 port (i'm also using it with the FTDI module).
-You can directly connect the shield on the netduino,but i advice to use a pin strip to avoid direct contact with the 2 shield since
when it's attached it's pretty hard to detach.
-If i'm not wrong,the issue you're talking about is that arduino has more pwm channels than netduino so
it could be a problem to drive multiple DC motors.But as i said,i'm not entirely sure of this point.

#7 der_tank

der_tank

    New Member

  • Members
  • Pip
  • 5 posts

Posted 26 November 2012 - 02:39 PM

Hi,
thanks for your reply. What driver did you use? I found a driver in the Micro Framework Toolkit on Codeplex but this does only seem to support two motors. I am not sure what about the stepmotors or servos then... And of course the driver from here.
It would be sufficient to me to use one DC motor and two servos or two steppers.
By the way, is there an even better motor shield for the use with netduino?

Thx

#8 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 26 November 2012 - 03:23 PM

I found a driver in the Micro Framework Toolkit on Codeplex but this does only seem to support two motors. I am not sure what about the stepmotors or servos then... And of course the driver from here.

Actually it supports 4 DC motors, but the pin-out is in a way only 2 motors can be used with a classic netduino. The Netduino Plus 2 should be able to use 4 DC motors.
The same counts for the driver in the post here :)
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#9 der_tank

der_tank

    New Member

  • Members
  • Pip
  • 5 posts

Posted 26 November 2012 - 03:27 PM

Actually it supports 4 DC motors, but the pin-out is in a way only 2 motors can be used with a classic netduino. The Netduino Plus 2 should be able to use 4 DC motors.
The same counts for the driver in the post here :)


Thanks for your answer!

What I understood so far is: I can use two motors, either DC or steppers on M1/M2 and additionally two servos that are controlled directly by Pins 9 & 10 wich are brought to the headers on the to left of the board. I can use the servos with this code!?

Is this correct?

Thx

#10 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 26 November 2012 - 04:21 PM

What I understood so far is: I can use two motors, either DC or steppers on M1/M2 and additionally two servos that are controlled directly by Pins 9 & 10 wich are brought to the headers on the to left of the board. I can use the servos with this code!?

Is this correct?

I think you're correct indeed.
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#11 Jamo

Jamo

    Member

  • Members
  • PipPip
  • 13 posts

Posted 05 July 2013 - 06:16 AM

Has anyone had a chance to refine this code any further?






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.