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

netduino Servo controller


  • Please log in to reply
2 replies to this topic

#1 TareqGamal

TareqGamal

    Member

  • Members
  • PipPip
  • 19 posts

Posted 15 November 2015 - 05:02 PM

Hello Netduino Forum

I have Netduino 3 wifi and I need exactly this project 

it is controlling Servo using netduino 

but I couldn't do it by my Netduino 3 wifi ,

Is it not supported ?

I tried the code provided in this forums many times but it is for previous versions of Netduino and never worked with me.

this is it's link:

http://forums.netdui...ge-3#entry64516

 



#2 TechnoGuy

TechnoGuy

    Advanced Member

  • Members
  • PipPipPip
  • 51 posts
  • LocationCanada

Posted 15 November 2015 - 07:42 PM

Try this:

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

/*
September 28, 2015:

    I found this code at this URL:  https://jamessdixon.wordpress.com/category/netduino/

    All the servo examples (the ones I examined) on the Netduino forums & even on the GHI codeshare space are written for the pre NETMF 4.2/4.3 PWM implementation.
    There's a guy named Chris Seto who wrote something & posted it to GHI & Netduino.  It's OLD.  He's not back with a revised version.
*/

namespace Tryout_Servo
{
    public class Program
    {
        private const uint TILT_SERVO_STRAIGHT = 1500;
        private const uint TILT_SERVO_MAX_UP = 2000;
        private const uint TILT_SERVO_MAX_DOWN = 1000;

        private const uint PAN_SERVO_STRAIGHT = 1500;
        private const uint PAN_SERVO_MAX_LEFT = 750;
        private const uint PAN_SERVO_MAX_RIGHT = 2250;

        private static PWM _tiltServo;
        private static PWM _panServo;
        private static uint _tiltServoCurrentPosition = 0;
        private static uint _panServoCurrentPosition = 0;

        public static void Main()
        {
            SetupServos();
            InputPort button = new InputPort(Pins.ONBOARD_BTN, false, Port.ResistorMode.Disabled);

            while (true)
                if (button.Read())
                    MoveServo();
        }

        private static void SetupServos()
        {
            uint period = 20000;
            _tiltServoCurrentPosition = TILT_SERVO_STRAIGHT;
            _panServoCurrentPosition = PAN_SERVO_STRAIGHT;

            _panServo = new PWM(PWMChannels.PWM_PIN_D5, period, _panServoCurrentPosition, PWM.ScaleFactor.Microseconds, false);
            _panServo.Start();
        }

        private static void MoveServo()
        {
            _panServo.Duration = PAN_SERVO_MAX_LEFT;
            Thread.Sleep(2000);

            _panServo.Duration = PAN_SERVO_MAX_RIGHT;
            Thread.Sleep(2000);

            _panServo.Duration = PAN_SERVO_STRAIGHT;
            Thread.Sleep(2000);


        }
    }
}


- Ian

 

My Current Dev Boards:

  • 3 x Netduino Plus 2
  • 1 x Netduino 3 WiFi

#3 David Weaver

David Weaver

    Advanced Member

  • Members
  • PipPipPip
  • 50 posts
  • LocationBloomington IL

Posted 24 November 2015 - 01:13 PM

Check my post http://forums.netdui.../11567-beerbot/ 

 

The servo code may be helpful.






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.