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

Netduino Plus 2 and Adafruit Motor Shield V2

Adafruit Motor Shield V2

  • Please log in to reply
7 replies to this topic

#1 glasswaster

glasswaster

    New Member

  • Members
  • Pip
  • 4 posts

Posted 29 July 2015 - 06:07 AM

Hello all!!

 

I was wondering if anyone has made the NP2 play nicely with the motor shield v2.  I think I've be through all of the threads about this, but they all see to come up short. 

 

I'm just trying to drive 6v/1A hobby type motors w/ the shield as I don't think think the NP2 can handle it, am I wrong about that.  Am I making this too complicated than it needs to be?

 

I'm running .NetMF 4.3 QFE2

Netduino SDK 4.3.2. 05/2015

NP2 firmware 4.3.2.1

 

I am more than willing to change to any version if I need to te get this working, and then try to update from there.

 

Should I just try to write one by porting over the Adafruit code, C/C++ is not my strong suit.

 

Thanks for any help!

 

Will



#2 NameOfTheDragon

NameOfTheDragon

    Advanced Member

  • Members
  • PipPipPip
  • 112 posts
  • LocationCanterbury, Kent, UK

Posted 31 July 2015 - 04:58 AM

You may find this interesting...

http://tigra-astrono...-microframework

 

I developed this on Netduino Plus 2, so it definitely works. The description of the project on my web page is a bit out of date... the Adafruit V2 board is fully supported and you get stepper motors (accelerated and non-accelerated), DC motors (accelerated and non-accelerated) and servos. There are lots of sample programs in the source repository.

 

You may want to get the source code for reference, but I recommend using the NuGet package when it comes to including in your own project. I push updates from time to time.

 

--Tim Long



#3 glasswaster

glasswaster

    New Member

  • Members
  • Pip
  • 4 posts

Posted 31 July 2015 - 06:23 AM

Tim,

 

I found this while doing my research, but I couldn't get it to work.  I verified that my shield is OK by using it w/ an arduino uno r3.  Now the r3's pin out is a bit different than the r2's, the i2c are their own separate pins on the r3 and on r2 they sat on A4/A5.

 

I know the NP2 I2C pins match the r3's pins.  Could this be an issue due to the shield only using the i2c pins?

 

Is this driver working for DC motors?  I tried just driving LED's to make sure my motors are not the problem.  I turn on all 4 ports and see no voltage.

 

One thing I do notice is that when I have the shield on the uno, I can set the jumper to use the power pins from the uno of the Vcc terminal block.  When on the NP2, I can only use the terminal block for power as the shield power light doesn't turn on when I set the jumper.  Can you use onboard power on yours?

 

I do not have steppers or servos to see if those work, but like I said, I can drive my motors with the uno and shield.

 

What other troubleshooting can I do to work through this?

 

Thanks for any help, it looks like a very well written library.

 

William

 

Edit:  It looks like the i2c pins are still on A4/A5, the other i2c pins are just a break out.



#4 NameOfTheDragon

NameOfTheDragon

    Advanced Member

  • Members
  • PipPipPip
  • 112 posts
  • LocationCanterbury, Kent, UK

Posted 31 July 2015 - 10:37 AM

The library definitely 100% works with Netduino Plus 2 and Adafruit V2 motor board, using the I2C pins on the Netduino Plus 2 board, because that was my primary use-case when I was developing it. It's plug-and-play.

 

It seems like power might be your problem. You have to have a power supply connected, either to the Netduino power jack and the Vin jumper applied, or directly to the Adafruit power terminals and the Vin jumper removed. The motor board cannot be powered from the USB connection (the logic will power up and work, but there will be no voltages on any of the motor ports). The USB power is insufficient to drive motors, so the Adafruit board takes power directly from the Vin power connector. Plug a 9v PSU into your Netduino and put the VIn jumper on the Adafruit board. The LED on the Adafruit board should light up to indicate that the motors are powered.

 

You should be able to control DC motors with the motor control library. I believe there is a sample program for that in the source repository. You might have to edit it a bit to select the Adafruit shield. All of the samples work with Adafruit V1 and V2 plus the Sparkfun ArduMoto - you have to define which one you are using with the #define directives at the top of the file.

 

Let me know how you get on, I am here to help if you still can't get it going.

--Tim Long



#5 glasswaster

glasswaster

    New Member

  • Members
  • Pip
  • 4 posts

Posted 31 July 2015 - 06:44 PM

Tim,

 

So here is where I am.

 

I erased the NP2 of any previous deployments.

I then loaded up your driver from NuGet: Install-Package TA.NetMF.MotorControl

 

I then loaded this code to the NP2:

using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
using TA.NetMF.ShieldDriver;
using TA.NetMF.Motor;


namespace NetduinoApplicationTest
{
    public class Program
    {
        static OutputPort Led = new OutputPort(Pins.ONBOARD_LED, false);

        public static void Main()
        {
            //blink to show ready
            Led.Write(true);
            Thread.Sleep(200);
            Led.Write(false);
            Thread.Sleep(200);
            Led.Write(true);
            Thread.Sleep(200);
            Led.Write(false);

            HBridge bridge1;

            var shield = new AdafruitV2MotorShield();
            shield.InitializeShield();
            bridge1 = shield.GetDcMotor(1);

            // Create the stepper motor axes and link them to the Ada-fruit driver.
            var motor = new DcMotor(bridge1);

            var targetSpeed1 = 1;
            motor.AccelerateToVelocity(targetSpeed1);//fire up motor
            Led.Write(true);
            Thread.Sleep(10000);//spin up for 10 sec
            Led.Write(false);
            motor.AccelerateToVelocity(0);//stop motor
        }
    }
}

I have a 9v plugged into the NP@, the motor shield has the Vin jumper in place and the pwr light is green.  The time it takes to get from the initial led blinking to the start of the motor coming on is 1min 45sec, this seems like a long initialization.

 

I retried again with a LED in place of the motor in both directions.

 

I still can't get this to work.  Could the NP2 be damaged somehow?  All 14 digital pins look ok when I turn them on.



#6 glasswaster

glasswaster

    New Member

  • Members
  • Pip
  • 4 posts

Posted 04 August 2015 - 07:32 PM

I am still having problems w/ the shield and NP2.  What kind of diagnostics can I do to the NP2 to rule it out.

 

Tim,

 

Do you have a bare bones working DC motor example?

 

@Chris Walker

Do you guys have access to the Adafruit motor shield V2 to be able to test some code?

 

 

Thanks for all the help so far guys!

 

William



#7 NameOfTheDragon

NameOfTheDragon

    Advanced Member

  • Members
  • PipPipPip
  • 112 posts
  • LocationCanterbury, Kent, UK

Posted 05 August 2015 - 01:58 AM

Have you tried the DC motor sample from the source repository? Actually I see your code is very similar to that, so probably the answer is yes.

 

The default value for Acceleration is 0.2 (20% per second) so it should only take about 5 seconds for the motor to ramp up to full speed.

 

Your post sort of hints that the motor might be moving, so that suggests something is happening. What exactly are you seeing? You're powering the motor with 9v, I assume it is a 9v motor? If the motor needs more than 9V then you'd have to find another way to power the Adafruit board, as the Netduino is rated for "7.5 to 9 volts" (although Chris has mentioned it is 12v tolerant).

 

If the motor is moving *at all* then that suggests that there is communication over the I2C bus so it seems unlikely that your Netduino is damaged. Only the I2C bus is used to control the Adafruit board.

 

Just to prove the library does work, there's a video of it working here: https://youtu.be/jZ9vwmktcvk

--Tim



#8 NameOfTheDragon

NameOfTheDragon

    Advanced Member

  • Members
  • PipPipPip
  • 112 posts
  • LocationCanterbury, Kent, UK

Posted 05 August 2015 - 05:21 AM

Also, for what it's worth, a logic analyzer is something that's very useful in these circumstances. With such a device, you can monitor the I2C bus and see what's going on, and whether or not the Adafruit shield is talking to the Netduino. If you could afford it, something from https://www.saleae.com would be perfect, or if you can live with the quirks and your conscience, you can get the 'cheap Chinese knock-off version' on eBay for under $10. Well worth the investment.

--Tim







Also tagged with one or more of these keywords: Adafruit Motor Shield V2

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.