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

Speed and turning control with Ardumoto - Motor Driver Shield


  • Please log in to reply
9 replies to this topic

#1 swestcott

swestcott

    Member

  • Members
  • PipPip
  • 16 posts
  • LocationMontclair Va

Posted 13 November 2010 - 08:14 PM

I am using the http://www.sparkfun....roducts_id=9896 so have this code very simple using System; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.Netduino; namespace NetduinoApplication1 { public class Program { public static void Main() { // write your code here OutputPort Motor1 = new OutputPort(Pins.GPIO_PIN_D12, false); OutputPort Motor2 = new OutputPort(Pins.GPIO_PIN_D13, false); while (true) { Motor1.Write(true); Thread.Sleep(500); Motor1.Write(false); Motor2.Write(true); Thread.Sleep(500); Motor2.Write(false); } } } } and this turns the motors on and off moving it forward how do you make one motor reverse so it will make a turn and I played a bit with PWM to control speed but maybe I am missing something as it will load but the speed does not seem to change PWM pwm1 = new PWM.PWM(Pins.GPIO_PIN_D3, Pins.GPIO_PIN_D11); gets error Error 1 The type name 'PWM' does not exist in the type 'SecretLabs.NETMF.Hardware.PWM' and well I am lost on how to set the speed after that just a bit of weekend fun

#2 bill.french

bill.french

    Advanced Member

  • Members
  • PipPipPip
  • 260 posts
  • LocationPrinceton, NJ

Posted 14 November 2010 - 12:07 AM

Your syntax is wrong: PWM pwm1 = new PWM(Pins.GPIO_PIN_D3); PWM pwm2 = new PWM(Pins.GPIO_PIN_D11); I think is more what you want?

#3 swestcott

swestcott

    Member

  • Members
  • PipPip
  • 16 posts
  • LocationMontclair Va

Posted 14 November 2010 - 01:12 AM

Your syntax is wrong:
PWM pwm1 = new PWM(Pins.GPIO_PIN_D3);
PWM pwm2 = new PWM(Pins.GPIO_PIN_D11);

I think is more what you want?

cool thanks I tried that as well I think I am not using it correctly later on not to sure where to reference the duty cycle if thats what I am supposed to do


get this error

An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in SecretLabs.NETMF.Hardware.dll
I think this means I am not defining later in the code what I want pwm1 and pwm2 values to be so I tried this well ...lets take a look

// write your code here

PWM pwm1 = new PWM(Pins.GPIO_PIN_D3);
PWM pwm2 = new PWM(Pins.GPIO_PIN_D11);

OutputPort Motor1 = new OutputPort(Pins.GPIO_PIN_D12, false);
OutputPort Motor2 = new OutputPort(Pins.GPIO_PIN_D13, false);



while (true)
{
Motor1.Write(true);
pwm1.SetDutyCycle(100);
Thread.Sleep(500);
Motor1.Write(false);
Motor2.Write(true);
pwm2.SetDutyCycle(100);
Thread.Sleep(500);
Motor2.Write(false);

}

but I don't think thats where it is supposed to go

#4 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 14 November 2010 - 06:21 AM

Which line of code gives you the exception?

#5 bill.french

bill.french

    Advanced Member

  • Members
  • PipPipPip
  • 260 posts
  • LocationPrinceton, NJ

Posted 14 November 2010 - 12:41 PM

I didn't catch this the first time, but I think PWM is only supported on pins 5,6,9,10 -- not 3 and 11. Specs are here: http://www.netduino....duino/specs.htm digital i/o features ● all 20 digital and analog pins: GPIO ● digital pins 0-1: UART 1 RX, TX ● digital pins 2-3: UART 2 RX, TX ● digital pins 5-6: PWM, PWM ● digital pins 7-8: UART 2 RTS, CTS ● digital pins 9-10: PWM, PWM ● digital pins 11-13: SPI MOSI, MISO, SPCK ● analog pins 4-5: I2C SDA, SCL

#6 swestcott

swestcott

    Member

  • Members
  • PipPip
  • 16 posts
  • LocationMontclair Va

Posted 14 November 2010 - 02:27 PM

I didn't catch this the first time, but I think PWM is only supported on pins 5,6,9,10 -- not 3 and 11.

Specs are here: http://www.netduino....duino/specs.htm

digital i/o features
● all 20 digital and analog pins: GPIO
● digital pins 0-1: UART 1 RX, TX
● digital pins 2-3: UART 2 RX, TX
● digital pins 5-6: PWM, PWM
● digital pins 7-8: UART 2 RTS, CTS
● digital pins 9-10: PWM, PWM
● digital pins 11-13: SPI MOSI, MISO, SPCK
● analog pins 4-5: I2C SDA, SCL

cool that was it wrong pin thanks for the help

#7 bill.french

bill.french

    Advanced Member

  • Members
  • PipPipPip
  • 260 posts
  • LocationPrinceton, NJ

Posted 14 November 2010 - 02:31 PM

Sorry I didn't notice originally! Just FYI, the "outofrange" exception made me think you were trying to access some capability outside of the range where it was possible.

#8 swestcott

swestcott

    Member

  • Members
  • PipPip
  • 16 posts
  • LocationMontclair Va

Posted 14 November 2010 - 08:29 PM

this is what I have it is hard to tell is the motors are running slower until I have it on the ground but no errors using System; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.Netduino; namespace NetduinoApplication1 { public class Program { public static void Main() { // write your code here PWM pwm1 = new PWM(Pins.GPIO_PIN_D6); PWM pwm2 = new PWM(Pins.GPIO_PIN_D9); OutputPort Motor1 = new OutputPort(Pins.GPIO_PIN_D12, false); OutputPort Motor2 = new OutputPort(Pins.GPIO_PIN_D13, false); while (true) { pwm2.SetDutyCycle(100); pwm1.SetDutyCycle(100); Motor1.Write(true); Motor2.Write(true); Thread.Sleep(5000); pwm2.SetDutyCycle(100); pwm1.SetDutyCycle(100); Motor1.Write(false); Motor2.Write(false); Thread.Sleep(5000); } } } } I cut and jumper-ed the pins on the motor shield to get them to line up I am using an old base from a TAB book on the basic stamp take a look

Attached Files



#9 wood

wood

    New Member

  • Members
  • Pip
  • 9 posts

Posted 06 December 2010 - 05:40 PM

this is what I have it is hard to tell is the motors are running slower until I have it on the ground but no errors

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;

namespace NetduinoApplication1
{
public class Program
{
public static void Main()
{
// write your code here

PWM pwm1 = new PWM(Pins.GPIO_PIN_D6);
PWM pwm2 = new PWM(Pins.GPIO_PIN_D9);

OutputPort Motor1 = new OutputPort(Pins.GPIO_PIN_D12, false);
OutputPort Motor2 = new OutputPort(Pins.GPIO_PIN_D13, false);



while (true)
{
pwm2.SetDutyCycle(100);
pwm1.SetDutyCycle(100);
Motor1.Write(true);
Motor2.Write(true);
Thread.Sleep(5000);

pwm2.SetDutyCycle(100);
pwm1.SetDutyCycle(100);
Motor1.Write(false);
Motor2.Write(false);
Thread.Sleep(5000);



}





}

}
}

I cut and jumper-ed the pins on the motor shield to get them to line up I am using an old base from a TAB book on the basic stamp take a look



I started a post to learn how to get my "Adafruit Motor Shield" to work but maybe you can help. How do I know what port on my shield is which. Also, do I need a different driver. I was told "4 PWM, not 6..." and I may have to make a driver.

Here's my post: http://forums.netdui...t=668&qpid=4916

#10 Azzmodious

Azzmodious

    New Member

  • Members
  • Pip
  • 1 posts

Posted 21 September 2011 - 03:59 AM

Thanks guys for clearing up the whole PWM pin mismatch. I was close to tossing out my netduino. Using the above program, I got a motor to move in one direction and then stop (repeat). How do I get the motor to actually reverse direction? Thanks in Advance!




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.