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

Using PWM with NetduinoPlus2

PWM NetduinoPlus2

  • Please log in to reply
8 replies to this topic

#1 mWalsh

mWalsh

    New Member

  • Members
  • Pip
  • 3 posts
  • LocationUnited States, AZ

Posted 17 June 2013 - 04:06 AM

Hello everyone i am new to netduino and the community,

 

i just bought the ND+2 and am playing with PWM and servo's unfortunately it seems that the brand new 4.3 firmware that just came out has different coding rules than the previous versions if i understand correctly. I have been all over the net researching for the last few hours and all i have figured out so far is that if you guess the wrong frequency your ND+2 is by by and instead of naming just the pin you now have to name the PWM channel? so please if anyone can help im trying to figure out how to code PWM with the netduino plus 2 and the newest firmware and sdk. Thank you in advance for anyones help.

 

-M. walsh



#2 tim c

tim c

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 17 June 2013 - 01:42 PM

See if this works for you: http://sdrv.ms/1al9Ph1

 

NetduinoPWM4.2.zip

 



#3 mWalsh

mWalsh

    New Member

  • Members
  • Pip
  • 3 posts
  • LocationUnited States, AZ

Posted 17 June 2013 - 05:34 PM

Thank you very much Tim for your reply. That is quite a bit of code to go through. just to verify are you using the N+2 with the 4.3 firmware? According to what i found in my research the coding is a little different with PWM for that board and firmware update. When ive figured out your coding you supplied ill update you if i've figured it out. Thank you again.



#4 tim c

tim c

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 18 June 2013 - 03:16 PM

Thank you very much Tim for your reply. That is quite a bit of code to go through. just to verify are you using the N+2 with the 4.3 firmware? According to what i found in my research the coding is a little different with PWM for that board and firmware update. When ive figured out your coding you supplied ill update you if i've figured it out. Thank you again.

 

If you look at the sample NetduinoPWMLED4.2 it tells you how to hook up a simple LED to D10 and GND and uses PWM to cycle the LED brightness. I loaded the project and then changed it to .NET MF 4.3 and it ran fine on my N+2 with 4.3 loaded.



#5 mWalsh

mWalsh

    New Member

  • Members
  • Pip
  • 3 posts
  • LocationUnited States, AZ

Posted 18 June 2013 - 05:25 PM

If you look at the sample NetduinoPWMLED4.2 it tells you how to hook up a simple LED to D10 and GND and uses PWM to cycle the LED brightness. I loaded the project and then changed it to .NET MF 4.3 and it ran fine on my N+2 with 4.3 loaded.

 

Tim,

 

Ok so i ran your example and it worked perfectly i appreciate the time to help. the issue i was running into is in all the beginner tutorials and examples when you declare a PWM variable and assign it to a pin it seems anything 4.2 and prior you can declare just the pin, however with 4.3 you have to declare it as a PWM channel instead that is the source of my confusion because you cant just declare the pin, it needs other information in the constructor as well and as new as i am im not sure what those values should be. The solution that i found to use PWM and not PWM channel was to remove the microsoft PWM .dll and use the secret labs one. however last night when i wanted to use a potentiometer to control servo movement the microsoft and secret labs .dll's conflict for analog input so at this point im pretty stuck. luckily i ordered the 'getting started with neduino' book off amazon today so ill get that and try and make some progress i need some background reading because im not sure whats what yet. thank you for all your help!

 

-M. Walsh



#6 MrGringoPy

MrGringoPy

    New Member

  • Members
  • Pip
  • 8 posts

Posted 08 July 2013 - 12:42 PM

Thanks Tim C for the servo code. I have hundreds of hours tring to get my servo to work.  This is the first code that I found on the internet that works on the NP2.

 

You made my day. 

Thanks.



#7 MrGringoPy

MrGringoPy

    New Member

  • Members
  • Pip
  • 8 posts

Posted 08 July 2013 - 09:40 PM

Hi 

Now I have a new question. 

 

Servo works well with your code Tim, if I conect Yellow to I/O pin 5 and Black to NP2 Ground and Red to Np2 +5v.

 

But if I conect  to  external power the servo, it does not work. Red to external + 6v and Black to external " - ".

I have also tried, Red external +6v and Black external " - " plus I have linked the external " - " to the NP2 Ground so as to use a common " - ".  Still does not work.

 

What could be the problem.?  :)

 

My servo is a HS-5645MG .



#8 tim c

tim c

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 09 July 2013 - 01:32 PM

Hi 

Now I have a new question. 

 

Servo works well with your code Tim, if I conect Yellow to I/O pin 5 and Black to NP2 Ground and Red to Np2 +5v.

 

But if I conect  to  external power the servo, it does not work. Red to external + 6v and Black to external " - ".

I have also tried, Red external +6v and Black external " - " plus I have linked the external " - " to the NP2 Ground so as to use a common " - ".  Still does not work.

 

What could be the problem.?  :)

 

My servo is a HS-5645MG .

This thread might help.

 

http://forum.arduino...?topic=117673.0

 

I have not hooked up a server to external power alone. I have always used this: http://www.adafruit.com/products/815



#9 brunovk

brunovk

    New Member

  • Members
  • Pip
  • 1 posts

Posted 21 August 2013 - 12:12 PM

Hi,

I would like to use the pwm output to generate a Mhz puls (for testing purposes). If it would go up to 60Mhz it would be great but I could only found somewhere on this forum that 'greater then 10Mhz' should be possible.

 

I'm using NetduinoPlus2 with firmware V4.2.2.2

Using the code:

 PWM pwmSignalOut = new PWM(PWMChannels.PWM_PIN_D5, 2000,1000, PWM.ScaleFactor.Nanoseconds, false);   pwmSignalOut.Start(); I can go to approx 500Khz

 

How can i change this to Mhz range?

 

Kind regards  







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.