SeeedStudio Motorshield
#1
Posted 15 September 2012 - 09:24 PM
#2
Posted 18 September 2012 - 12:38 PM
#3
Posted 18 September 2012 - 12:50 PM
- JerseyTechGuy likes this
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#4
Posted 18 September 2012 - 02:09 PM
- JerseyTechGuy likes this
#5
Posted 18 September 2012 - 02:59 PM
#6
Posted 18 September 2012 - 03:03 PM
It wasn't too bad setting it up on the go: http://forums.netdui...a-simple-rover/ . There is a beta version of code attached in that post. I've written a class that allows you to create motor objects for each motor port. I can grab that when I get home. If you need help adapting for the regular netduino, let me know.
I'm not seeing the code attached. Maybe I am missing something?
#7
Posted 18 September 2012 - 08:42 PM
I'm not seeing the code attached. Maybe I am missing something?
No, you're completely right...I know everybody says this...but I really thought I attached it. That's fine, I'll put the new version of the code here and there when I get home(as my home computer decided to go into hibernate and prevent teamviewer). It'll probably be pretty late
#8
Posted 19 September 2012 - 03:09 AM
Attached Files
#9
Posted 19 September 2012 - 03:18 AM
#10
Posted 01 November 2013 - 05:44 PM
Ok, attached is a zip with the motor class, and the program I'm using with it. Hope this helps!
Thanks RandTheDragon. I got chance to run the DC motors using your code. Its working with no issues. But not able to run the stepper motor. Do you have any code update to run the stepper motor using SEEED motor shield?
#11
Posted 29 December 2013 - 07:08 AM
I have a Netduino (series 1), and am trying to convert the above code to run my motor shield. I have made some progress, considering that I know little programming. I think I have it set up to power the motor back and forth when it starts, but it is not powering it very much (barely powers the small motor I got to check if it was working, let alone the large motor I want it to power)
Here is what I have:
SeeedMotorShield.cs
using System;using Microsoft.SPOT;using Microsoft.SPOT.Hardware;using SecretLabs.NETMF.Hardware;using SecretLabs.NETMF.Hardware.Netduino;using System.Collections;namespace Seeed.MotorShield{ class Motor { public enum motors { M1, M2, Stepper }; private static int[] activeMotors=new int[2]; public static int[] ActiveMotors { get { return activeMotors;} } public /*readonly*/ Microsoft.SPOT.Hardware.PWM SpeedPin /*= new PWM(PWMChannels.PWM_PIN_D9, 20000, 1500, false)*/; //Pins.GPIO_PIN_D9, 20000, 1500, Microsoft.SPOT.Hardware.PWM.ScaleFactor.Microseconds, false public /*readonly*/ OutputPort pinPos; //= new OutputPort(Pins.GPIO_PIN_D8, false); public /*readonly*/ OutputPort pinNeg; //= new OutputPort(Pins.GPIO_PIN_D11, false); //public readonly OutputPort pin_step1; //public readonly OutputPort pin_step2; //public readonly OutputPort pin_step3; //public readonly OutputPort pin_step4; //public readonly Microsoft.SPOT.Hardware.PWM public void spinPositive() { SpeedPin.Start(); pinNeg.Write(false); pinPos.Write(true); } public void spinNegative() { SpeedPin.Start(); pinPos.Write(false); pinNeg.Write(true); } public void stop() { SpeedPin.Stop(); pinPos.Write(false); pinNeg.Write(false); } }}
And Program.cs
using System;using System.Threading;using Microsoft.SPOT;using Microsoft.SPOT.Hardware;using SecretLabs.NETMF.Hardware;using SecretLabs.NETMF.Hardware.Netduino;using Seeed.MotorShield;namespace HelloMotor{ public class Program { private static Motor motorA; private static bool moveForward = true; private static bool motorOn = false; public static void Main() { motorA = new Motor(); /*InputPort button = new InputPort(Pins.ONBOARD_SW1, false, Port.ResistorMode.Disabled);*/ /*OutputPort */motorA.pinPos = new OutputPort(Pins.GPIO_PIN_D8, false); /*OutputPort */motorA.pinNeg = new OutputPort(Pins.GPIO_PIN_D11, false); /*public readonly Microsoft.SPOT.Hardware.PWM*/ motorA.SpeedPin = new PWM(PWMChannels.PWM_PIN_D9, 20000, 5000, Microsoft.SPOT.Hardware.PWM.ScaleFactor.Microseconds, false); motorA.SpeedPin.SetDutyCycle(65) motorA.spinPositive(); System.Threading.Thread.Sleep(800); motorA.spinNegative(); System.Threading.Thread.Sleep(200); motorA.spinPositive(); System.Threading.Thread.Sleep(200); motorA.spinNegative(); System.Threading.Thread.Sleep(800); motorA.spinPositive(); System.Threading.Thread.Sleep(200); motorA.spinNegative(); System.Threading.Thread.Sleep(800); motorA.stop(); /*while (true) { motorOn = True; if (motorOn) { if (moveForward) forward(); else backward(); } else { motorA.stop(); } //ledPort.Write(!ledPort.Read()); //System.Threading.Thread.Sleep((int)(pot.GetValue()*1000)); }*/ } private static void forward() { motorA.spinPositive(); System.Threading.Thread.Sleep(200); } private static void backward() { motorA.spinNegative(); System.Threading.Thread.Sleep(200); } private static void onboardButton_OnInterrupt(uint data1, uint data2, DateTime time) { motorOn = !motorOn; } private static void button_ButtonReleased(object sender, bool buttonState) { moveForward = !moveForward; } }}
I am very new to this, and would appreciate any feedback!
.
Edit: update! I have worked on the code, and I now get a series of blinking lights but the motor is way under powered, can anyone tell why by the code?
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users