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

Issue with DFRobot MotorShield 1A


  • Please log in to reply
8 replies to this topic

#1 Asymptot

Asymptot

    Member

  • Members
  • PipPip
  • 19 posts

Posted 16 August 2012 - 02:18 PM

Hello,

I currently have this strange problem when I try to use the DFRobot MotorShield 1A (http://www.dfrobot.c...or_Shield_(L293)_(SKU:_DRI0001)) with my Netduino, still using the 4.1 firmware and framework :

When I use a dummy code like this :

while (true)
{

}

Both motors run (and if i don't plug any motor, the motor LEDs indicating motor activity are lit)
Nevertheless when i set the different PINs for more control, like this :

            PWM E1 = new PWM(Pins.GPIO_PIN_D5);
            OutputPort M1 = new OutputPort(Pins.GPIO_PIN_D4, true);

            PWM E2 = new PWM(Pins.GPIO_PIN_D6);
            OutputPort M2 = new OutputPort(Pins.GPIO_PIN_D7, true);
            
            E1.SetDutyCycle(50);
            E1.SetDutyCycle(50);

Then, both motors run during the boot/loading phase, and then stop.
It seems to me that for some reason, bothmotors run by default, and trying to set PWM on them turn them off...
I have no idea why this is happenning.

Does anyone has an idea of why this is happenning?

#2 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 16 August 2012 - 03:03 PM

Hi there! Most people find this! When the Netduino boots, all the IO lines are set as inputs with weak pullup resistors enabled. The internal resistors don't give enough current to light an LED, but they DO give enough to turn on logic gates like your motor driver. :angry: Its a very annoying problem, but there is method behind the apparent madness. Paul

#3 Asymptot

Asymptot

    Member

  • Members
  • PipPip
  • 19 posts

Posted 16 August 2012 - 03:12 PM

Thank you, that explains why the motors run by default. I still don't understand why trying to set the PWMs completely turn them off... Any suggestion?

#4 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 16 August 2012 - 03:23 PM

It might be the period of the pwm signal. I am not sure what the default is. Try something less than 1000Hz and see what happens. Also, what happens with higher duty cycles? Paul

#5 Stefan

Stefan

    Moderator

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

Posted 16 August 2012 - 03:28 PM

What kind of power source do you use? Just so you know, I've written a library for using that shield, documentation @ http://netmftoolbox.... L298N and L293
"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

#6 Asymptot

Asymptot

    Member

  • Members
  • PipPip
  • 19 posts

Posted 16 August 2012 - 03:45 PM

Thank you for your answers! I use a 9V battery power source when i have the motors plugged, and onyl the USB one when I don't have the motors plugged, and just testing the shield looking what happens with the LEDs. I will test your library and also try different cycle values. Thank you for the suggestions :-)

#7 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 16 August 2012 - 04:37 PM

A few technical insights: The SAM7X MCU enables pullups on all pins by default during boot. Generally speaking, MCU pins are best left in pullup or pulldown state. This helps reduce power consumption among other things. The SecretLabs.NETMF.Hardware PWM class sets the PWM dutycycle to zero by default, as a safe initialization value. This will also turn off the pin pullups if they were activated, which could then cause the motors to stop running. The new Shield Base actually keeps the pins floating during boot, and also has control over power to the shield. The motor sceanrio was taken into account when designing the new Netduino Go and Shield Base. The design ensures a premium experience for new users and offers high design flexibility for one's projects. Chris

#8 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 16 August 2012 - 06:28 PM

I made some notes a while ago and created a Wiki page about using opto-isolators. On my robot buggy I am using two opto-isolators to prevent my motors running during reset.

Its fairly simple, cheap and works!

Regards - Paul

#9 Asymptot

Asymptot

    Member

  • Members
  • PipPip
  • 19 posts

Posted 17 August 2012 - 09:21 AM

Thank you very much! I think i figured out my PWM problem. Any value of the duty in SetDutyCycle(duty) between 70 and 100 work well. 70 giving a very slow running motor. Under 70 it sometimes run, and sometimes doesn't. I plan of using it in a PID-corrected line following bot. If i keep using SetdutyCycle, it'll give me 30 distinct values, which is enough. Do you think it'd be worth it using SetPulse for more granularity? (then, i'll need to figure out what frequency to use first). Thank you again, Farouk




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.