Netduino home hardware projects downloads community

Jump to content


Photo

MotorShield driver


  • Please log in to reply
14 replies to this topic

Poll: How do you prefer to set the state? (9 member(s) have cast votes)

Which one to use

  1. MotorShield.SetMotor1State(Directions.Backward, 100); (0 votes [0.00%])

    Percentage of vote: 0.00%

  2. MotorShield.SetMotor1State(-100); (0 votes [0.00%])

    Percentage of vote: 0.00%

  3. MotorShield.SetState(Motors.Motor1, Directions.Backward, 100); (4 votes [44.44%])

    Percentage of vote: 44.44%

  4. MotorShield.SetState(Motors.Motor1, -100); (5 votes [55.56%])

    Percentage of vote: 55.56%

  5. All of the above, who cares about code memory anyway? (0 votes [0.00%])

    Percentage of vote: 0.00%

Vote Guests cannot vote

#1 Stefan

Stefan

    Moderator

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

Posted 21 April 2011 - 10:48 AM

Hi Guys and Girls,

Currently I have a successful Netduino driver for this shield: Arduino Motor Shield (L298N).

The shield is quite simple; you can connect 2 DC-motors to it, and by sending some signals it's possible to change voltage to each motor from -12V to +12V (when Vin is set to 12V)

Now I got it to work on the Netduino I'm looking for a good solution to make it easy to control. I have four ways in mind, these codes do the same. Which one do you prefer?
The code sets motor one in reverse at full speed and the second motor half speed forward.

MotorShield.SetMotor1State(Directions.Backward, 100);
MotorShield.SetMotor2State(Directions.Forward, 50);
MotorShield.SetMotor1State(-100);
MotorShield.SetMotor2State(50);
MotorShield.SetState(Motors.Motor1, Directions.Backward, 100);
MotorShield.SetState(Motors.Motor2, Directions.Forward, 50);
MotorShield.SetState(Motors.Motor1, -100);
MotorShield.SetState(Motors.Motor2, 50);

I can also create an overload so all of the above will work, but that could be quite some overhead on code memory.

I made a poll and will work out the option with the most votes. The driver will be done this sunday, already got it 100% working.
"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

#2 Michel Trahan

Michel Trahan

    Advanced Member

  • Members
  • PipPipPip
  • 155 posts

Posted 21 April 2011 - 11:36 AM

Hi Guys and Girls,

Girls ? Where ?

Currently I have a successful Netduino driver for this shield: Arduino Motor Shield (L298N).

Cool, I'll want one when budget will allow :) I know it is a stupid question with you since you will ... but can you add it to the sandbox wiki ?

MotorShield.SetState(Motors.Motor1, Directions.Backward, 100);
MotorShield.SetState(Motors.Motor2, Directions.Forward, 50);

I vote for this one, you can easily read the purpose of the code :)

that could be quite some overhead on code memory.

I vote for not adding all those overloads ... no overlords please :) (pun intended)
Started with C in 1985, moved to Vb3 ... to vb6 and stopped. Now started with .Net and learning C# and VB.net and wishing VB.net was on MF !

#3 Stefan

Stefan

    Moderator

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

Posted 21 April 2011 - 11:42 AM

Girls ? Where ?

It was a subtle way to find that out! :D

I know it is a stupid question with you since you will ... but can you add it to the sandbox wiki ?

I will when it's done. I hate to put stuff online that isn't finished, but expect a nice article before monday!

I vote for this one, you can easily read the purpose of the code :)

True! The only thing I have against it is that an enumeration requires additional memory, but it's a very clean way.

I vote for not adding all those overloads ... no overlords please :) (pun intended)

I totally agree, although sometimes I'm happy overloads are possible! :D
"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

#4 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 21 April 2011 - 12:11 PM

Hi guys (at now, no girls at sight...at least from your pictures) I voted for the 4th option, because it is the most abstract. I think that the most exciting task in the motor control is the speed-shaping, that is *NOT* easy! Consider having a simple motor, where you may control its speed from -100 to +100%. Now imagine having a dish hardly connected to the motor axis. On the dish there is a sign (e.g. at 12 o'clock). The deal is: the motor/dish is idle with the sign exactly at noon. Let spin the dish N times as fast as possible, then position the sign back to noon. When your brain is melted, but you've got the goal, just add this puzzle: - grant the performance with dishes of different weight. LOVELY!!! Ciao
Biggest fault of Netduino? It runs by electricity.

#5 Stefan

Stefan

    Moderator

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

Posted 21 April 2011 - 12:22 PM

The motor shield is intended for DC motors which aren't very precise. But it can be very useful for robots. You can let them walk slow or fast, forward and backward. If you want a precize motor it should be a servo anyway I suppose. There's a solution for every problem, this one isn't a solution for clocks but a very nice one for rc cars and stuff I suppose :) I liked the 4th myself as well, but I like the diversity in opinions in this. To be honest, I designed "MotorShield.SetState(Motors.Motor1, Directions.Backward, 100);" at first, since that's how the shield works; a pin that switches forward and backward and a pin that defines speed. But while giving it some thought I decided to do "MotorShield.SetState(Motors.Motor1, -100);". Then I though some more and was like: "what would others do and why?" And to get an answer on the first thing; Chris, if you read this, can you query how many users have their gender on female? :rolleyes:
"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 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 21 April 2011 - 12:54 PM

There are definitely some ladies who frequent the forums. But they're vastly outnumbered by the gentlemen, so perhaps they don't speak up often (or don't disclose their gender). [ That said, ladies...you are welcome in this community. The guys are friendly. And if they aren't, just let me know ;) ] Chris

#7 Stefan

Stefan

    Moderator

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

Posted 21 April 2011 - 05:14 PM

Nice said Chris, appairently two people totally agreed according to the Posted Image button :D
"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

#8 Hinnie

Hinnie

    New Member

  • Members
  • Pip
  • 9 posts

Posted 22 April 2011 - 09:39 AM

The ability to simultaneously send two engines missing in the choice, therefore I can not participate in your poll

#9 Stefan

Stefan

    Moderator

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

Posted 22 April 2011 - 09:45 AM

The ability to simultaneously send two engines missing in the choice, therefore I can not participate in your poll

it's possible, it can drive two motors simultaniously.
"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

#10 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 22 April 2011 - 10:02 AM

The ability to simultaneously send two engines missing in the choice

It is preferable to keep a certain level of abstraction, instead of making a custom call for a bunch of users.
What if tomorrow there will be John Smith asking for three motors?

However, relating to high precision positioning, it would be nice if there is some way to keep in sync two o or more motors.
I think this is very far away, at the moment.
Cheers
Biggest fault of Netduino? It runs by electricity.

#11 Stefan

Stefan

    Moderator

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

Posted 22 April 2011 - 10:25 AM

Ahhh like that. it's near to impossible to drive both motors simultaniously with exactly the same speed. DC-motors aren't precise and can't be trusted. But for just some speed (like netduino based vehicles) this is good enough.
"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

#12 Stefan

Stefan

    Moderator

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

Posted 22 April 2011 - 01:00 PM

Ohh it's a tie between: MotorShield.SetState(Motors.Motor1, Directions.Backward, 100); (3 votes [50.00%]) MotorShield.SetState(Motors.Motor1, -100); (3 votes [50.00%]) hmmm appairently there are good reasons for me to doubt between those two options ;)
"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

#13 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 22 April 2011 - 01:11 PM

MotorShield.SetState(Motors.Motor1, Directions.Backward, 100); (3 votes [50.00%])
MotorShield.SetState(Motors.Motor1, -100); (3 votes [50.00%])

I've just voted for the latter - the speed value can include the direction, positive - forward, negative - backward, zero - stop, so it is not necessary to have an extra 'direction' enum. I don't know what modes the used H-bridge supports, IMHO the reasonable use of enum would be to represent possible DC motor modes - running (left or right), coasting (free run) and braking (short circuit), because some of them (coasting, braking) do not have the additional speed parameter.

#14 Stefan

Stefan

    Moderator

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

Posted 22 April 2011 - 01:35 PM

Too bad, the shield only provides the feature to move forward and backward at different speeds.
"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

#15 Stefan

Stefan

    Moderator

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

Posted 22 April 2011 - 07:36 PM

Driver is finished, you can download it here: MotorShieldDriver.zip

Going to make a wiki page this weekend.
"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




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.