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 Reversal and API question

C# API PWM common anode Maker Kit REG LED

  • Please log in to reply
3 replies to this topic

#1 OmegaNine

OmegaNine

    New Member

  • Members
  • Pip
  • 2 posts

Posted 22 April 2013 - 09:01 PM

Hey all,

 

I am really new to this, just got my Maker Kit a few days ago.  I am going through the "Getting to know your Netduino" book from Maker Shed using the Ultimate Microcontroller Kit and the book uses common cathode.  The kit I have came with common anode leds, of course the book has no explanation of what the heck is wrong when it doesn't work so I am begging for knowledge here. :D

 

After searching around the site for a while I found that i need to plug the common anode pin in to the +5v on the board, and reverse the PWM values to get them to work correctly.  But I am a lazy guy, and i saw someone mention that there was a way to pass a boolean to the class to have the object do it for you.

 

TLDR: How do I construct a PWM object that will reverse the values for me when using a common anode led?  Also, is there a place to read the API for Micro C#?  I can't just highlight and search like I can in NetBeans or Eclips. 

 

Thanks in advance,

OmegaNine

 

PS - A lot of the explanation was to help others find the answer to this through search since I was not able to.   :P



#2 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 08 May 2013 - 01:07 PM

Just like you said yourself, the constructor accepts a boolean parameter (among others) to invert the PWM but you can also do this in software by just inverting the duty cycle, e.g. duty = (1.0 - duty).

 

If you got 20% duty cycle in non-inverted mode, then on a scope you would see an 80% duty cycle when in inverted mode.

 

If you have a LED with common anode, you won't have to do anything special in h/w as long as the PWM pin can sink the current coming in from the cathodes (check this first). The only difference is that the LED will glow when the PWM output is low while a common cathode LED will glow when the PWM output is high.

 

There's some code attached to this post where you can see how to create PWM outputs:

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

 

Have look at the constructor on line 329+ in LCD1602.cs where the PWM channel used for contrast is inverted.

 

Btw, what does the abbrevation [color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;]TLDR mean?[/color]



#3 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 08 May 2013 - 07:03 PM

Btw, what does the abbrevation TLDR mean?

 
Too long; didn't read  :P

#4 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 08 May 2013 - 07:21 PM

Haha, very convenient expression and just like my posts usually are - I need to practice on keeping it short  :rolleyes:







Also tagged with one or more of these keywords: C# API, PWM, common anode, Maker Kit, REG LED

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.