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 question (in combination with TIP32)


  • Please log in to reply
16 replies to this topic

#1 bramVD

bramVD

    Member

  • Members
  • PipPip
  • 16 posts
  • LocationDen Bosch, NL

Posted 11 December 2012 - 10:29 AM

Hello,

I created the following circuit:
Posted Image
LED STIP = LED STRIP

I’m chancing the duty cycle of the PWM to control the light output of the LED stip.

so in de code I’m setting the duty cycle to 0%.
but there still is a low voltage coming out of the PWM port,
so the PNP is still being triggered, and the LED will still emit light.

How can I fix this? so on a duty cycle of 0% the voltage on the Base of the PNP = 0V.

(DataSheet op TIP32C = PDF)


Bram van Deventer
Posted Image

#2 NooM

NooM

    Advanced Member

  • Members
  • PipPipPip
  • 490 posts
  • LocationAustria

Posted 11 December 2012 - 11:55 AM

your circiut looks kinda wrong. // stupid me.

i made a circiut with an npn (doesent need inverted pwm). you can easly change it to pnp (you have to invert the pwm).

ofc you need to change the resistor value for the 12v, or maybe dont even use one, but i not suggest that (except it runs with 12v)

most likly your problem is the pnp, it needs inverted pwm.

Attached Files



#3 bramVD

bramVD

    Member

  • Members
  • PipPip
  • 16 posts
  • LocationDen Bosch, NL

Posted 11 December 2012 - 12:13 PM

your circiut looks kinda wrong. // stupid me.

i made a circiut with an npn (doesent need inverted pwm). you can easly change it to pnp (you have to invert the pwm).

ofc you need to change the resistor value for the 12v, or maybe dont even use one, but i not suggest that (except it runs with 12v)

most likly your problem is the pnp, it needs inverted pwm.



The led strip in the drawing is infect a RGB strip of 5 meter, drawingabout a 1Amp at 12V, per chanel.

How can i invert the PWM?
Posted Image

#4 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 11 December 2012 - 12:37 PM

How can i invert the PWM?

It is just a logical change (*), normally 0% = off and 100% = on, inverted 0% = on, 100% = off.

(*) The microcontroller allows configuration of PWM polarity, but it is not available in .NET MF classes.

Edit: The polarity parameter is available in PWM class since version 4.2, as pointed out by NooM in the post below. Thanks!

Edited by CW2, 11 December 2012 - 10:08 PM.


#5 bramVD

bramVD

    Member

  • Members
  • PipPip
  • 16 posts
  • LocationDen Bosch, NL

Posted 11 December 2012 - 12:53 PM

It is just a logical change (*), normally 0% = off and 100% = on, inverted 0% = on, 100% = off.

(*) The microcontroller allows configuration of PWM polarity, but it is not available in .NET MF classes.


LOL, that was stupid of mePosted Image.


BUT...
I hooked upthe 3 leads of the RGB strip. Including separate PNPs and resistors.

I wrote a littlescript that enables me to switch between light.
3 duty cycles: 2 set to 0% and 1 set to 100%.

And if I look1 is very bright, the other 2 are dimmed (not off).


Does this means that I don’t need a inverted PWM?
Posted Image

#6 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 11 December 2012 - 07:16 PM

You have got a pnp transistor. When you pull the base down to about 0.7 V below your 12V supply, it will turn ON. When the Netduino output is low 0V - it wil be ON. When the Netduino output is high 3.3V - it will still be ON! If you have to use the pnp transistor as shown, you need to use another transistor (npn) and resistors to get the base to swing up above 11.3V. This will also invert the logic, low - off, high - on. Hope this explains it - Paul EDIT added picture. When NPN is OFF, "pull up" reistor hold the PNP base near to 12V, thus turning it OFF. When NPN is ON, it pulls the base down below 11.3V, turning the PNP ON.

Attached Files



#7 bramVD

bramVD

    Member

  • Members
  • PipPip
  • 16 posts
  • LocationDen Bosch, NL

Posted 11 December 2012 - 07:25 PM

You have got a pnp transistor.
When you pull the base down to about 0.7 V below your 12V supply, it will turn ON.

When the Netduino output is low 0V - it wil be ON.
When the Netduino output is high 3.3V - it will still be ON!

If you have to use the pnp transistor as shown, you need to use another transistor (npn) and resistors to get the base to swing up above 11.3V. This will also invert the logic, low - off, high - on.

Hope this explains it - Paul


Thank you, it explains a lot :)
Posted Image

#8 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 11 December 2012 - 07:33 PM

Thank you, it explains a lot :)


Your welcome!

In case you missed it, I edited my post and added a diagram.
Red lines to show the current flowing.

#9 NooM

NooM

    Advanced Member

  • Members
  • PipPipPip
  • 490 posts
  • LocationAustria

Posted 11 December 2012 - 09:56 PM

It is just a logical change (*), normally 0% = off and 100% = on, inverted 0% = on, 100% = off.

(*) The microcontroller allows configuration of PWM polarity, but it is not available in .NET MF classes.


sure its aviable and works!

PWM ladi = new PWM(PWMChannels.PWM_PIN_17, 1000, 0.5, true); // standard netmf pwm class
//edit: in 4.2 :P
  • CW2 likes this

#10 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 11 December 2012 - 10:01 PM

sure its aviable and works!

Oops! Still living in the past version - thanks for pointing that out Posted Image

#11 bramVD

bramVD

    Member

  • Members
  • PipPip
  • 16 posts
  • LocationDen Bosch, NL

Posted 12 December 2012 - 12:33 PM

You have got a pnp transistor.

If you have to use the pnp transistor as shown, you need to use another transistor (npn) and resistors to get the base to swing up above 11.3V. This

EDIT added picture.
When NPN is OFF, "pull up" reistor hold the PNP base near to 12V, thus turning it OFF.
When NPN is ON, it pulls the base down below 11.3V, turning the PNP ON.


do you have a value of the Resistors?
Posted Image

#12 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 12 December 2012 - 07:40 PM

Hi Bram, I don't have any data to hand, so the following are guesses. The pullup resistor does not have to pass any current (you might even get away without it) I would use something big - say 10K. You have used 220R for the pnp's base, stick with that for now. The npn base should not need much current, try 1K or a bit less if it does not turn on properly. Paul

#13 bramVD

bramVD

    Member

  • Members
  • PipPip
  • 16 posts
  • LocationDen Bosch, NL

Posted 12 December 2012 - 09:52 PM

Hi Bram,

I don't have any data to hand, so the following are guesses.
The pullup resistor does not have to pass any current (you might even get away without it) I would use something big - say 10K.
You have used 220R for the pnp's base, stick with that for now.
The npn base should not need much current, try 1K or a bit less if it does not turn on properly.

Paul


Yaay,

it works perfectly . Thanks!!! (again)Posted Image
Posted Image

#14 bramVD

bramVD

    Member

  • Members
  • PipPip
  • 16 posts
  • LocationDen Bosch, NL

Posted 12 December 2012 - 10:25 PM

Made a mistake in the drawing, but is basically the same:

https://www.circuitl...rip-controller/

Attached Files

  • Attached File  1.png   52.82KB   14 downloads

Posted Image

#15 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 12 December 2012 - 10:43 PM

Hi Bram, Glad it is working. I am a little worried that the led strip has moved in the new circuit. Is this the mistake you mention? If the pnp transistor is connected like this, it may not turn ON fully; if so, it will act as a resistor and will waste some of the power that should be in your LED strip. It would be better to put the pnp above the LED strip, between12V and the strip's +ve terminal. Remember to have fun - Paul

#16 bramVD

bramVD

    Member

  • Members
  • PipPip
  • 16 posts
  • LocationDen Bosch, NL

Posted 13 December 2012 - 08:17 AM

I am a little worried that the led strip has moved in the new circuit.
Is this the mistake you mention?


Yes, thats the mistake.

If the pnp transistor is connected like this, it may not turn ON fully; if so, it will act as a resistor and will waste some of the power that should be in your LED strip.

It would be better to put the pnp above the LED strip, between12V and the strip's +ve terminal.

Remember to have fun - Paul


The strip is really bright at the moment, but I will try to switch the location of the PNP.
maybe it will even be brighter!


The “having fun” part will not be a problemPosted Image

After this works I’m going to implement a 1” OLED screen, a rotary switch and a IR receiver,
all into a little box mounted on the wall, connected to a 5M RGB led stip.


Building a Menu to configure the lights and patterns.Posted Image
Posted Image

#17 bramVD

bramVD

    Member

  • Members
  • PipPip
  • 16 posts
  • LocationDen Bosch, NL

Posted 13 December 2012 - 07:24 PM

Just remembered that the LEDstrip has 1 common 12V and 3 outputs, so theonly what is to control it after the strip.

I put the strip directly one 12V en Ground, and the LEDs were indeed brighterthen when they are in line with the PNP, but it’s hardly noticeable.
so I wil stick with the original plan
Posted Image
Posted Image




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.