Motor Shield v2 and Netduino

by deashute on Wed Oct 30, 2013 4:53 pm

Hi all,

I'm fairly new to the world of Netduino, but my goal is to use stepper motors with the Adafruit Motor Shield v2.0 on my Netduino Plus 2. I have found a plethora of code samples for using the first generation of motor shield with C# and the Netduino, but have had no luck in my attempts to control version 2. I understand that the motor shield is controlled through I2C, but am not completely certain what the process of programming for I2C entails. I know that the majority of users on this forum most likely tend towards Arduino, but does anyone have any experience with Netduino and this motor shield, or maybe any idea of where I can get started?

Thanks,
Dean
deashute
 
Posts: 4
Joined: Wed Oct 30, 2013 4:46 pm

Re: Motor Shield v2 and Netduino

by adafruit_support_mike on Thu Oct 31, 2013 1:35 am

I2C is a fairly simple protocol once you get used to it, but you have to suspend disbelief for a while as you do get used to it.

Start by looking at datasheets for a few devices that use I2C. They almost always include a description of the basic protocol, then explain the variations necessary to make the device in question work.

http://www.adafruit.com/datasheets/mcp23017.pdf
http://www.adafruit.com/datasheets/ina219.pdf
http://www.adafruit.com/datasheets/mcp4725.pdf

If you have questions, post back and we'll see if we can help.
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.
User avatar
adafruit_support_mike
 
Posts: 8698
Joined: Thu Feb 11, 2010 1:51 pm

Re: Motor Shield v2 and Netduino

by deashute on Fri Nov 01, 2013 3:06 pm

Thanks for your help. I suppose that has been my biggest problem so far, grasping that we can control an entire slave device using just two pins.

Those links definitely help in understanding some of the basics. In looking at the first link, there is a table of register addresses (TABLE 1-2). Under the "Access to" heading, are those the names of the pins that I can access through the I2C connection?

Also, I have so far not had any success finding such a data sheet for the Motor Shield v2, at least not one that references I2C and gives the information regarding its use. I have also attempted to look at the C++ library for the Motor Shield, but had very little luck modifying/rewriting that library in C#. I'm hoping that there's a better way.

Thanks,
Dean
deashute
 
Posts: 4
Joined: Wed Oct 30, 2013 4:46 pm

Re: Motor Shield v2 and Netduino

by deashute on Fri Nov 01, 2013 4:26 pm

This blog post was also very helpful in finding some of the methods to initialize I2C.

http://blog.codeblack.nl/post/NetDuino- ... h-I2C.aspx

The biggest question I have now is how to find the registers for the Motor Shield. Once those are determined, I am hopeful that I can successfully program the Steppers. I just don't really know how to communicate with them at the moment.

Thanks,
Dean
deashute
 
Posts: 4
Joined: Wed Oct 30, 2013 4:46 pm

Re: Motor Shield v2 and Netduino

by adafruit_support_bill on Sat Nov 02, 2013 6:04 am

The Arduino library would be your best reference there. The H-bridge chips are controlled via the PCA9685 PWM chip. Some of the PWM channels us e PWM for speed control. Others are used more like simple digital output pins to control enable the H-bridge.
User avatar
adafruit_support_bill
 
Posts: 28187
Joined: Sat Feb 07, 2009 9:11 am

Re: Motor Shield v2 and Netduino

by deashute on Mon Nov 04, 2013 3:14 pm

Thanks Bill!

I found what I think are the register addresses, we'll see if they work. I think I'm making some progress, but unfortunately I know that I'm still a ways off. I think this has helped me get moving though. The real trick for me is to work out transitioning the C++ Adafruit driver to usable C#.

Thanks,
Dean
deashute
 
Posts: 4
Joined: Wed Oct 30, 2013 4:46 pm