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

Servos with Netduino GO


  • Please log in to reply
11 replies to this topic

#1 QuantumPhysGuy

QuantumPhysGuy

    Advanced Member

  • Members
  • PipPipPip
  • 30 posts
  • LocationKentucky, USA

Posted 01 October 2012 - 02:02 AM

I have a parallax standard servo I am trying to get working with the Netduino Go Shield Base. I currently have the servo connected to 5V, GND, and analog 0.

When I turn the netduino on the servo moves just a bit but once I run the below code, nothing happens. Does anyone know why? I'm fairly new at all of this.

The servo says 0.75-2.25 ms high pulse, 20 ms intervals. So I "think" I have the constructor correct on the PWM.

            ShieldBase shieldBase = new ShieldBase(GoSockets.Socket1);
            PWM servo = new PWM(shieldBase.PWMChannels.PWM_0, 20, 18, PWM.ScaleFactor.Milliseconds, false);

            servo.Start();


#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 01 October 2012 - 03:46 AM

Hi QuantumPhysGuy, If you want the PWM to be high for 2ms, you'll want to set the duration to 2ms instead of 18ms. Also, be sure to upgrade your Shield Base to the latest firmware. There were some PWM bufixes in the newer releases. Chris

#3 QuantumPhysGuy

QuantumPhysGuy

    Advanced Member

  • Members
  • PipPipPip
  • 30 posts
  • LocationKentucky, USA

Posted 01 October 2012 - 03:59 AM

Hi QuantumPhysGuy,

If you want the PWM to be high for 2ms, you'll want to set the duration to 2ms instead of 18ms.

Also, be sure to upgrade your Shield Base to the latest firmware. There were some PWM bufixes in the newer releases.

Chris


Thanks Chris, I update the code to reflect your changes and I updated the Netduino GOs firmware and my shield base. Now I am having another odd issue. When the code executes it takes about 15 seconds for the POTs GO bus to turn on. The shield base is right away, the problem is, after repeated System.Exceptions in mscorlib.dll, the application just crashes...

Any ideas on this?

Here is the modified code:

        private static ShieldBase shieldbase = new ShieldBase(GoSockets.Socket1);

        public static void Main()
        {
            try
            {
                Potentiometer pot = new Potentiometer(GoSockets.Socket7);

                PWM servo = new PWM(shieldbase.PWMChannels.PWM_0, 20, 2, PWM.ScaleFactor.Milliseconds, false);

                servo.Start();
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message + "\n" + ex.StackTrace);
            }
        }

Stack Trace Output:

Exception was thrown: System.Exception
NetduinoGo.ShieldBase::CreatePWM
System.Reflection.MethodBase::Invoke
Microsoft.SPOT.Hardware.PWM::.ctor
Servo.Program::Main


Another odd thing, I have the servo attached to D3, 5V, and GND. It will pulse, about every 5 - 10 seconds.

Edited by QuantumPhysGuy, 01 October 2012 - 04:01 AM.


#4 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 01 October 2012 - 04:20 AM

Any ideas on this?

Just a theory...try moving:
shieldbase = new ShieldBase(GoSockets.Socket1);
...into your main function. The classes may be getting constructed out of order.

Chris

#5 QuantumPhysGuy

QuantumPhysGuy

    Advanced Member

  • Members
  • PipPipPip
  • 30 posts
  • LocationKentucky, USA

Posted 01 October 2012 - 07:12 PM

Just a theory...try moving:

shieldbase = new ShieldBase(GoSockets.Socket1);
...into your main function. The classes may be getting constructed out of order.

Chris


Modified what you suggested. Same result:

            try
            {
                ShieldBase shieldbase = new ShieldBase(GoSockets.Socket1);
                Potentiometer pot = new Potentiometer(GoSockets.Socket7);

                PWM servo = new PWM(shieldbase.PWMChannels.PWM_0, 20, 2, PWM.ScaleFactor.Milliseconds, false);

                servo.Start();
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message + "\n" + ex.StackTrace);
            }
Stack Output:

Exception was thrown: System.Exception
NetduinoGo.ShieldBase::CreatePWM
System.Reflection.MethodBase::Invoke
Microsoft.SPOT.Hardware.PWM::.ctor
Servo.Program::Main

#6 Gutworks

Gutworks

    Advanced Member

  • Members
  • PipPipPip
  • 363 posts
  • LocationOttawa, Ontario

Posted 01 October 2012 - 07:23 PM


PWM servo = new PWM(shieldbase.PWMChannels.PWM_0, 20, 2, PWM.ScaleFactor.Milliseconds, false);


Hi QuantumPhysGuy,

As of the last Shield Base update the PWMChannels enums, PWM_0 to PWM_5 have been disabled. Perhaps try using the newly added enums which better reflect the actual Shield Base pins. (i.e. PWM_PIN_D5)

So try using:
PWM servo = new PWM(shieldbase.PWMChannels.PWM_PIN_D5, 20, 2, PWM.ScaleFactor.Milliseconds, false);


#7 QuantumPhysGuy

QuantumPhysGuy

    Advanced Member

  • Members
  • PipPipPip
  • 30 posts
  • LocationKentucky, USA

Posted 01 October 2012 - 07:34 PM

Hi QuantumPhysGuy,

As of the last Shield Base update the PWMChannels enums, PWM_0 to PWM_5 have been disabled. Perhaps try using the newly added enums which better reflect the actual Shield Base pins. (i.e. PWM_PIN_D5)

So try using:

PWM servo = new PWM(shieldbase.PWMChannels.PWM_PIN_D5, 20, 2, PWM.ScaleFactor.Milliseconds, false);


I was using the incorrect version of the ShieldBase library. Thanks for pointing that out with the enumerator I didn't I have!

#8 QuantumPhysGuy

QuantumPhysGuy

    Advanced Member

  • Members
  • PipPipPip
  • 30 posts
  • LocationKentucky, USA

Posted 05 October 2012 - 12:29 PM

I ran into another odd issue last night using a Servo. I have 4 AA batteries which are supplying 6V of power. I hooked them up to my bread board and ran the VCC and GND to my servo, I have the SIG set to PIN D5 on the Netduino Go. When I sent signals to the servo nothing happened. If I wire the VCC and GND directly to the NGO it worked fine. The servo is rated for 4V - 6V, any idea what would cause this?

#9 carb

carb

    Advanced Member

  • Members
  • PipPipPip
  • 352 posts
  • LocationCrystal River, Florida

Posted 05 October 2012 - 01:46 PM

I ran into another odd issue last night using a Servo. I have 4 AA batteries which are supplying 6V of power. I hooked them up to my bread board and ran the VCC and GND to my servo, I have the SIG set to PIN D5 on the Netduino Go. When I sent signals to the servo nothing happened. If I wire the VCC and GND directly to the NGO it worked fine.

The servo is rated for 4V - 6V, any idea what would cause this?

Do you have the ground for the Netduino and the negative from the batteries tied togther? You have to have a return from the signal back to the Netduino.

Chuck

#10 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1072 posts
  • LocationNorth Yorkshire, UK

Posted 05 October 2012 - 01:47 PM

I ran into another odd issue last night using a Servo. I have 4 AA batteries which are supplying 6V of power. I hooked them up to my bread board and ran the VCC and GND to my servo, I have the SIG set to PIN D5 on the Netduino Go. When I sent signals to the servo nothing happened. If I wire the VCC and GND directly to the NGO it worked fine.

The servo is rated for 4V - 6V, any idea what would cause this?

Did you connect the GND on the Netduino to the GND on the breadboard?

Regards,
Mark

To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter


#11 QuantumPhysGuy

QuantumPhysGuy

    Advanced Member

  • Members
  • PipPipPip
  • 30 posts
  • LocationKentucky, USA

Posted 05 October 2012 - 10:32 PM

Did you connect the GND on the Netduino to the GND on the breadboard?

Regards,
Mark


Yes, that finally fixed, I also put in a 7805 as well.

#12 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1072 posts
  • LocationNorth Yorkshire, UK

Posted 06 October 2012 - 07:15 AM

Yes, that finally fixed, I also put in a 7805 as well.

You might find this post on common grounding useful.

Regards,
Mark

To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter





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.