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

DFRobot and Netduino

DFRobot

Best Answer Paul Newton, 18 July 2013 - 06:41 PM

Great to hear its working! Must be time to get some sensors fitted :P

 

Keep the questions coming - makes me feel useful.

 

Nice to see that you have posted a complete solution - code with using statements, references, and firmware version.

So often people post code without the extra bits of information needed to build it - very frustrating.

 

Paul

Go to the full post


  • Please log in to reply
18 replies to this topic

#1 Dave1374

Dave1374

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 07 July 2013 - 09:53 PM

Hey.

 

So I ordered a DF Robot kit and got some help to put it together.

 

I want to control the wheels with my netduino.

 

What I want to do is simple. Press the netduino's button, and start the 4 wheels in the same direction, full power.

 

When I try to make it run with one wheel pluged in my breadboard, it works, the wheel move.

 

But when I add a second wheel, nothing appens. It seems that I dont have enough power to make the wheels move.

 

The netduino is powered by a 9volt battery. When I press the button, the net duino let the big power source ( 5 AA batteries , as suggested in the kit)  flow in the motors. (this is how I see it correct me if i'm wrong.)

 

Here's a scheme that my friend made me back when I was playing around before I had this kit. ( note that I removed the resistor)

 

Basically, I'm doing the exact same thing with my df robot kit, but i switched the power source to the 5 AA batteries.

 

I'm using the 4n35 transistor that came with my netduino kit I ordered.

 

I'm starting to realise that I will need a motor shield. Which one do you guys suggest ?

 

But before I go on and buy another thing, is there a way to get it working with my current setup ?

 

Thanks, Dave

 

Edit: I'm using netduino plus 2, latest firmware.

Attached Files



#2 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 08 July 2013 - 06:23 AM

Hi Dave,

 

I can't see anything obviously wrong with the layout you show in the picture, might be helpful to also show the circuit diagram and the code you are using.

 

I have the same buggy - it works really well. It can drive on hard floor, carpet and rugs!

https://www.youtube....h?v=fbollf-0U9A

 

Watch out with motor shields, the one I chose was not able to be directly connected to the Netduino (plus v1), so I had to add lots of wires.

 

Good luck - Paul



#3 Dave1374

Dave1374

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 09 July 2013 - 01:01 PM

Hey Paul,

 

The code I'm using is very simple and I'm pretty sure it's not the problem.

 

As I said, it looks like I dont have enough power ....

 

The circuit I'm using is basically the same you can see in the jpeg, but I pluged 4 positive wires instead of just one, and also 4 negative wires,  ( the motors wires) all in the same column.

 

The motors negative wires are all lined up in the #5 pin of the 4n35 transistor.

 

The 4 positive wires are all lined up with the positive power source positive wire. (5 new AA batteries)

 

 

Just in case... here's the code.... but as I said, I can get one wheel to spin, no problem.

        private static OutputPort onBoardLed = new OutputPort(Pins.ONBOARD_LED, false);        private static OutputPort motorPin = new OutputPort(Pins.GPIO_PIN_D0, false);        public static void Main()        {            InterruptPort button = new InterruptPort(Pins.ONBOARD_BTN, false, Port.ResistorMode.Disabled, InterruptModes.InterruptEdgeBoth);            button.OnInterrupt  += button_OnInterrupt;            Thread.Sleep(Timeout.Infinite);        }        private static void button_OnInterrupt(uint data1, uint data2, DateTime time)        {            onBoardLed.Write(data2 == 1);            motorPin.Write(data2 == 1);            try            {                string query = "http://www.xxx.com/xxx.svc/Log?Log=" + data2.ToString();// + "-" + time.ToString().Split(' ')[1]);                using (HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(query))                {                    myReq.Method = "GET";                    using (HttpWebResponse WebResp = (HttpWebResponse)myReq.GetResponse())                    {                    }                }            }            catch (Exception ex)            {                //allumer un led rouge            }        }


#4 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 09 July 2013 - 05:40 PM

I think the problem is the transistor in the opto-isolator is not able to pass enough current.

The data sheet says the maximum collector current is 100mA.

The DFROBOT web page for the buggy says:

  • No-load current(3V):60mA
  • No-load current(6V):71mA
  • Stall current(3V):260mA
  • Stall current(6V):470mA

So with 5 AA batteries you are using 6V to 7.5V.

The transistor is not even going to be able to handle the no load current.

 

Sorry, but you are going to need a bigger transistor - there are plenty to chose from, I usually use a "darlington" which is a pair of tranistors in one package. Others will recomend FETs.

 

Often the choice just comes down to what you can obtain quickest and cheapest :rolleyes:

 

I wrote up some notes on the Wiki about a darlington "BDX33C" available from Maplin in the UK - http://wiki.netduino...rrent-load.ashx

 

 

Hope this helps - Paul



#5 Dave1374

Dave1374

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 10 July 2013 - 01:40 PM

  • Stall current(6V):470mA

So with 5 AA batteries you are using 6V to 7.5V.

The transistor is not even going to be able to handle the no load current.

 

 

Hope this helps - Paul

 

I think you nailed it. My transistor sucks. Im going to buy another one that can support >=  500 mA. ([color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;font-size:14px;]darlington if possible)[/color]

 

I'll try to get one from some shop around here today and I'll keep you updated!

 

Thanks

 

edit: so i realised i have a NPN BC547B at home.I'm not sure how to read the data sheet... so for one million dollar.... i'd say that it can handle only 100 mA. .... so it wont do the job. right ?  :ph34r: 



#6 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 10 July 2013 - 09:22 PM

Sorry, you are right. It is a medium power transistor - not designed for high currents like motors.



#7 Dave1374

Dave1374

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 11 July 2013 - 12:46 PM

Sorry, you are right. It is a medium power transistor - not designed for high currents like motors.

So I went to the electronic shop around here, and asked for a darlington transistor that can support 500 mA. The dude says he has to order it and it will be 15$+tx. It was something like a 247 or 249 darlington (TO3) . That price is way to high, I'd prefer to order a motor shield.....

 

On your blog you talk about the [color=rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px;]BDX33C, and it seems like it is cheap and it could do the job for me ?[/color]

 

as for the motor shield, do you think this one fits a netduino plus 2 ?

 

And if I decide to go and buy this shield, do I need something else to get it to work ? like another power source or something.



#8 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 11 July 2013 - 06:11 PM

So I went to the electronic shop around here, and asked for a darlington transistor that can support 500 mA. The dude says he has to order it and it will be 15$+tx. It was something like a 247 or 249 darlington (TO3) . That price is way to high, I'd prefer to order a motor shield.....

 

On your blog you talk about the [color=rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px;]BDX33C, and it seems like it is cheap and it could do the job for me ?[/color]

 

as for the motor shield, do you think this one fits a netduino plus 2 ?

 

And if I decide to go and buy this shield, do I need something else to get it to work ? like another power source or something.

IMHO - $15 is about $13 dollars too much. I agree, its time to get a shield if that's your only option!

 

The BDX33C can handle 10Amps (with heat sinking etc), I did my tetsing of the BDX33C using on of the DFRobot motors - so no problems there if you can get one.

 

No I don't think that shield is a good choice - it can only drive one motor in forward or reverse. So you won't be able to steer. You need a shield that can control two (or four) motors independantly. 

 

My one only controls two motors, so I have connected them in pairs.

I am not completely happy to recomend the shield I bought because the PWM pins were in the wrong place for the Netduino. However if you are happy soldering, then it may be OK for you. There was a link on the page you posted: http://www.robotshop...uino-sfe-4.html I think its the same one as mine, a bit hard to tell because its all in French!

 

I power the robot (with motor shield) using 5 AA NiMh batteries in the supplied battery box. I use a separate battery pack to power the Netduino. (I found the Netduino was unrelaible sharing the same battery as the motors.)

 

Hope this helps - Paul



#9 Dave1374

Dave1374

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 11 July 2013 - 08:20 PM

 

I am not completely happy to recomend the shield I bought because the PWM pins were in the wrong place for the Netduino. However if you are happy soldering, then it may be OK for you. 

 

Which one will be easier to get to work for my netduino plus 2 ?

 

http://wiki.netduino...ver-Shield.ashx

or

http://wiki.netduino...tor-Shield.ashx

 

On the wiki you say the ardumoto's pwm will most likely fit my netduino 2 ?

 

Is it safer to buy the DFRobot instead ?



#10 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 11 July 2013 - 09:06 PM

Which one will be easier to get to work for my netduino plus 2 ?

 

http://wiki.netduino...ver-Shield.ashx

or

http://wiki.netduino...tor-Shield.ashx

 

On the wiki you say the ardumoto's pwm will most likely fit my netduino 2 ?

 

Is it safer to buy the DFRobot instead ?

Easier will be the DFRobot shield, I understand from the Netduino Wiki page, that you can just plug it in and there is Netduino driver code on the DFRobot wiki.

 

I am assuming that it comes with connectors all pre-soldered. (The Ardumoto does not have connectors pre-soldered.)

 

I have just had a look at the US RobotShop website, the DFrobot one is listed at USD$17 and the Ardumoto at USD$24.

So the DFRobot one is cheaper too.

 

But, I can't see the DFRobot one on the Canadian RobotShop (you linked to ealier in the thread) so you may have to shop around.

 

Paul



#11 Dave1374

Dave1374

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 12 July 2013 - 12:50 PM

 

I have just had a look at the US RobotShop website, the DFrobot one is listed at USD$17 and the Ardumoto at USD$24.

So the DFRobot one is cheaper too.

 

But, I can't see the DFRobot one on the Canadian RobotShop (you linked to ealier in the thread) so you may have to shop around.

 

Paul

 

Ok so I found this one on the US Site and finally.... I found it on the canadian site.

 

I'm ordering it.

 

Thanks for the shopping help Paul.  :)

 

edit: the shield says [color=rgb(102,102,102);font-family:Arial, Helvetica, sans-serif;font-size:13.333333015441895px;] Control 2 motors 7-12 V[/color]

 

But my 4 motors kit says [color=rgb(102,102,102);font-family:Arial, Helvetica, sans-serif;font-size:13.333333015441895px;]3 ~ 6 V[/color]

 

How does it work ?

 

I realise I'll have to plug 2x 2 motors on the kit, but how does the voltage work ?



#12 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 12 July 2013 - 02:29 PM

Just checked my circuit diagram.

 

I have connected my motors in parallel (two pairs of motors).

This means that both motors in each pair can see the full voltage available from the shield.

I am using the external power connector rather than VIN, and I have broken the VIN link between my shield and the Netduino. This was to stop the Netduino using the same supply as the motors.

 

I think the shield says 7.5 to 12V because that is the VIN voltage range. Without the link to VIN, the limits are those of the L298P driver chip: 2.5V to 46V.

 

My battery pack is 5x AA NiMh cells, these are around 1.2V each, so the nominal battery voltage is about 6V (a bit more when recently charged, but not for long).

 

The shield uses pairs of "BJT" (npn and pnp) transistors to supply current to the motors, these form the "H" bridge.

To make a motor turn, two transistors have to be turned ON, e.g. the motor current has to flow through a series circuit of two transistors and a motor. Transistors are not perfect so there will be some voltage lost in each transistor (wasted power). This will vary with the exact current flowing, but assume it will be 0.3V per transistor or more.

That leaves a bit more than 5V for the motors.

 

Thats about it, the motors are 3 to 6V, the shield will drive them at about 5V.

 

Works quite well on hard floors and rugs.

 

Paul



#13 Dave1374

Dave1374

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 12 July 2013 - 03:36 PM

That sounds right to me... My netduino is powered by a 9 volt battery, and the motors will have the same 5 X AA batteries you use.

 

I'll wait till the buggy works before ordering 8x rechargeable batteries and a charger... them bitches are quite pricey.



#14 Dave1374

Dave1374

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 17 July 2013 - 12:25 PM

Ive received the motor shield

 

I pined it on the netduino and I fixed the power, from the battery pack, in the motor shield.

 

(I think I have the pwr jumpers setted up correctly)

 

I start the netduino and the motor shield's pwr light doesnt light up....

 

Am I suppose to install an update on my netduino ?

 

edit : so I installed http://netmftoolbox.codeplex.com/ ....

 

edit 2: from this thread I found the 4.3 ones 

 

then in my project I added a reference to :

Toolbox.NETMF.Hardware.AdafruitMotorshield

Toolbox.NETMF.Hardware.Core

Toolbox.NETMF.NET.Core

 

and.... not sure what to do from there



#15 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 17 July 2013 - 06:20 PM

I can't offer any help with those libraries, I just wrote my own test code that setup two PWMs (for speed) and two GPIOs (for direction).

I don't see a power LED on the shield's circuit diagram - you will only see an LED light up when the motors are being driven.

 

Probably good to check your setup. Looking at the motor shiled Wiki, there are pictures showing the jumpers.

Looks like you need to have four jumpers in the PWM positions, this sets up GPIO 5 & 6 as PWM inputs, and GPIO 4 & 7 as direction inputs. (Inputs to the shield)

Also you need to select the power input with two more jumpers, you have a choice of the external screw terminals or Vin from the Netduino. (I prefer external) If you have selected Vin, you need to supply power on the Netduino's barrel connector.

 

Try it without motors first.

 

You should be able to get the LEDs to light by setting all the GPIOs 4 to 7 as outputs and just set them all high.

Then try setting 4 and/or 7 low (leave 5 and 6 high) and the LEDs should change colour.

 

I'm sure you will get it going - Paul



#16 Dave1374

Dave1374

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 17 July 2013 - 06:50 PM

 

Try it without motors first.

 

You should be able to get the LEDs to light by setting all the GPIOs 4 to 7 as outputs and just set them all high.

Then try setting 4 and/or 7 low (leave 5 and 6 high) and the LEDs should change colour.

 

I'm sure you will get it going - Paul

 

Well the motors are not plugged right now, and I can't get no led on the motor shield to light up.

 

My code might be incorrect tho....

Took it from there

        private static OutputPort motorPin4 = new OutputPort(Pins.GPIO_PIN_D4, false);        private static OutputPort motorPin7 = new OutputPort(Pins.GPIO_PIN_D7, false);        private static PWM motorPin5 = new PWM(Cpu.PWMChannel.PWM_5, 100, 1, false);        private static PWM motorPin6 = new PWM(Cpu.PWMChannel.PWM_6, 100, 1, false);private static void button_OnInterrupt(uint data1, uint data2, DateTime time)        {            onBoardLed.Write(data2 == 1);            /*            motorPin4.Write(data2 == 1);            motorPin7.Write(data2 == 1);            if (data2 == 1)            {                motorPin5.Start();                motorPin6.Start();            }*/        }

I get these errors when I deploy 

 

A first chance exception of type 'System.ArgumentException' occurred in Microsoft.SPOT.Hardware.dll
An unhandled exception of type 'System.ArgumentException' occurred in Microsoft.SPOT.Hardware.dll
 
edit: its caused exactly by this line
 
        private static PWM motorPin6 = new PWM(Cpu.PWMChannel.PWM_6, 100, 1, false);

 

the one with the pwm_5 doesnt seem to cause error....



#17 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 17 July 2013 - 09:10 PM

Sounds like there is an issue with the PWM setup.

I think there are some differences between your plus v2 and my plus v1.

 

Instead of PWM, just try using GPIO for D5 and D6, and set them both high.

 

EDIT:

Should they be numbered PWM 0 to PWM 5 (instead of 1 to 6)?



#18 Dave1374

Dave1374

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 18 July 2013 - 05:02 PM

finally got it working! yay.

 

thanks to Stefan Thoolen and his HBridge Motor Driver.

 

I found it in the source of the using Toolbox.NETMF 4.3

 

so heres the code :

using System;using System.Net;using System.Threading;using Microsoft.SPOT;using Microsoft.SPOT.Hardware;using SecretLabs.NETMF.Hardware;using SecretLabs.NETMF.Hardware.Netduino;using Toolbox.NETMF.Hardware;namespace BlinkLedButton{    public class Program    {        private static OutputPort onBoardLed = new OutputPort(Pins.ONBOARD_LED, false);        static HBridge MotorDriver = new HBridge(new Netduino.PWM(Pins.GPIO_PIN_D6), Pins.GPIO_PIN_D7,                                                 new Netduino.PWM(Pins.GPIO_PIN_D5), Pins.GPIO_PIN_D4);        public static void Main()        {            InterruptPort button = new InterruptPort(Pins.ONBOARD_BTN, false, Port.ResistorMode.Disabled, InterruptModes.InterruptEdgeBoth);            button.OnInterrupt  += button_OnInterrupt;            Thread.Sleep(Timeout.Infinite);                    }        private static void button_OnInterrupt(uint data1, uint data2, DateTime time)        {            bool b = data2 == 1;            onBoardLed.Write(b);            MotorDriver.SetState(HBridge.Motors.Motor1, 75);            MotorDriver.SetState(HBridge.Motors.Motor2, 75);            Thread.Sleep(4000);            MotorDriver.SetState(HBridge.Motors.Motor1, -75);            MotorDriver.SetState(HBridge.Motors.Motor2, -75);            Thread.Sleep(4000);            // Stops both motors            MotorDriver.SetState(HBridge.Motors.Motor1, 0);            MotorDriver.SetState(HBridge.Motors.Motor2, 0);                    }    }}

my project references are :

 Posted Image

 

 

I think that most of my errors when I was compiling were dues to the wrong references i had in my project.

 

-Netduino Plus 2 

-Firmware 4.3 beta 1

 

oh yeah and.... thanks alot for all the help Paul !  :D

I guess I'll be back with some new problems soon haha  :ph34r:



#19 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 18 July 2013 - 06:41 PM   Best Answer

Great to hear its working! Must be time to get some sensors fitted :P

 

Keep the questions coming - makes me feel useful.

 

Nice to see that you have posted a complete solution - code with using statements, references, and firmware version.

So often people post code without the extra bits of information needed to build it - very frustrating.

 

Paul







Also tagged with one or more of these keywords: DFRobot

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.