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

PWM Constructor Trouble


Best Answer hanzibal, 25 May 2013 - 06:22 PM

Hello and welcome to the forum!

Yes, I believe you should use the PWMChannel enum as you suggested yourself, I also noticed this at some point and I think it was introduced with v4.2 of the framework. Take a look at the code attached for the lcd driver class in the below post and you should be able to see how to use PWM. I believe the file is named lcd1602.cs or something like that.

http://forums.netdui...-and-ir-remote/

Good luck! Go to the full post


  • Please log in to reply
3 replies to this topic

#1 alex.c.schultz

alex.c.schultz

    New Member

  • Members
  • Pip
  • 5 posts

Posted 25 May 2013 - 04:42 AM

Hello, 
I'm new to embedded programming but not to .net.
I have a Netduino plus 2 board and I'm going through the tutorials in Chris Walker's intro book but all the examples with PWM objects are failing. Am I looking in the wrong namespace? My only guess is that the constructor has changed since the book was written and now it requires additional parameters. 
 
I've looked at the documentation on MSDN
 
When I try to plug in the other parameters then I get a bug about the 
 
"Pins.GPIO_PIN_D5" being incorrect, Instead it says I should be using the enum: Microsoft.SPOT.Hardware.Cpu.PWMChannel.

 

 

 
As an example I posted one of the samples from the book below:
 
Any help would be greatly appreciated!
 
 

 

public static void Main()
{
 // write your code here
 PWM servo = new PWM(Pins.GPIO_PIN_D5);
 uint firstPosition = 1000;
 uint lastPosition = 2000;
 // move through the full range of positions
 for (uint currentPosition = firstPosition; 
 currentPosition <= lastPosition; 
 currentPosition += 10)
 {
 // move the servo to the new position.
 servo.SetPulse(20000, currentPosition);
 Thread.Sleep(10);
 }
 // return to first position and wait a half second.
 servo.SetPulse(20000, firstPosition);
 Thread.Sleep(Timeout.Infinite);
}

 

I am getting the following errors:

 

'Microsoft.SPOT.Hardware.PWM' does not contain a constructor that takes 1 arguments

 

'Microsoft.SPOT.Hardware.PWM' does not contain a definition for 'SetPulse' and no extension method 'SetPulse' accepting a first argument of type 'Microsoft.SPOT.Hardware.PWM' could be found (are you missing a using directive or an assembly reference?)
 

 



#2 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 25 May 2013 - 06:22 PM   Best Answer

Hello and welcome to the forum!

Yes, I believe you should use the PWMChannel enum as you suggested yourself, I also noticed this at some point and I think it was introduced with v4.2 of the framework. Take a look at the code attached for the lcd driver class in the below post and you should be able to see how to use PWM. I believe the file is named lcd1602.cs or something like that.

http://forums.netdui...-and-ir-remote/

Good luck!

#3 alex.c.schultz

alex.c.schultz

    New Member

  • Members
  • Pip
  • 5 posts

Posted 29 May 2013 - 04:44 AM

Hey thanks for the quick reply. I was able to get it working after looking at your code. much obliged!



#4 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 29 May 2013 - 06:27 AM

Thats great, have fun!




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.