PWM on LED Transformer Has No Output

Hello,
I have a residential LED track light bulb (120VAC) that I am trying to re-purpose. It was intermittent so I replaced it, tore it apart and am using it for a desk lamp. And it works like this. This is it:
http://www.amazon.com/gp/product/B00LTY73SI/ref=oh_aui_search_detailpage?ie=UTF8&psc=1

I am trying to use an arduino PWM with a MOSFET to make a dimmer. The bulb came with a small transformer inside that I assume was overheating because it was cycling (turning off and on repeatedly very slowly). But after taking it apart, putting the transformer in a box with a switch and hanging the light elsewhere it works.

Checking the transformer I see that it outputs 16 VDC under load but nothing without a load. I have an arduino with a PWM skit and a MOSFET that runs a small LED fine. I got the circuit from here:
http://bildr.org/2012/03/rfp30n06le-arduino/

I am trying to switch the 16 vdc side of the transformer.

But when I replace the small LED and resister with the negative (16vdc) side of the bulb to the drain of the MOSFET, common the negative output from the transformer on the arduino and connect the positive (16vdc) bulb and transformer I get:

  1. When 120 VAC is off, the arduino is powered on and serial monitor shows that PWM is at 255 if I turn the 120 VAC on the 16vdc bulb is on.
  2. When the 120 VAC is on , the PWM is 0 and I turn the PWM to 255 the bulb is off until I reset the 120 VAC then the bulb come on.
  3. When I try to dim the bulb with the arduino as soon as the PWM drops below 255 the bulb turns off and I read 0 vdc coming from the transformer.
  4. If I turn the arduino back up to 255 the bulb still is off and transformer output still at 0vdc until I reset the 120 VAC then it comes on.

So, I don’t know much about these little transformers but I assume it has something to do with the transformer going to 0 output with no load.

The bulb is supposed to be dimmable on the AC side but I wanted to stay on the low voltage side to keep it easy and compact.

Anyone want to make an observation and suggestion here?

Thanks
Marc

Here are some picts:

I am trying to use an arduino PWM with a MOSFET to make a dimmer.

Quite simply you can't use a FET with PWM to dim any AC system.

This is because the AC frequency and the PWM are not synchronized and the two beat together.

For controlling AC you need to use a triac triggered by a pulse that is locked to the AC frequency. Once turned on a triac stays on until the current AC cycle ends ( reaches zero ).

Never put AC signals onto a solderless bread board, unless you have a death wish.

Thanks for your reply Grumpy,
I am not trying to dim an AC circuit. I put the MOSFET on the secondary side of the transformer. The 16 volt DC side.

I think the problem is in the kind of transformer it is. It only puts out 16 VDC when the LED is in line. Otherwise the output reads 0.95 VDC when the secondary is open.

I think it has something to do with when the sign wave of the PWM is momentary low and the load is not seen from the transformer the output goes to low and wont come back up until I turn off the primary side of the transformer (120 VAC) and back on again. Then the bulb lights only if the PWM is between 245 and 255.

Hi,
Welcome to the Forum

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html
then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom... :slight_smile:

I don't have the sketch handy right now but it seems to be working fine when I test it with a small LED and a resister. And I can see the output on the serial monitor fading from 0 to 255 and the (small) led dimming off of pin 5.

I think the problem is something to do the transformer secondary going to 0 VDC without a load.

Here you go, I found it here. Go down to BulldogLowell’s post:

One Button Dimmer

I’m using this MOSFET fromAdafruit:
IRLB8721PbF

/*
/*
* Fade.h
* by BulldogLowell (BulldogLowell@gmail.com)
* Created 17-June-2014
*
* adapted from: http://stackoverflow.com/questions/10963194/timed-fading-in-arduino/10966231#10966231
*
* Non-blocking Fade library allows you to set fade level of a pin and the fade speed
* Useful for projects involving LEDs that you use to illuminate around the house
*
* Create a fade object:
*
* fade fadePin(pin, timestep, min, max)
* timeStep is by default 10ms
* min is by default 0
* max is by default 255
*
* example
* fade fadePin(5) is the same as fade fadePin(5, 10, 0, 255)
*
* to change the speed once declared.
* fadePin.writeSpeed(new speed);
* to read the current speed
* fadePin.readSpeed();
*
* fadePin.read() returns the current fade level (_pwmRate);
* fadePin.write(to) defines the new endpoint of the fader;
*
* fadePin.update(); needs to called in the loop
*
* foo.update(time); is for saving time variable if you want to sync Fade objects:
*
* unsigned long a = millis();
* foo.update(a);
* bar.update(a);
* foobar.update(a);
* it is faster than reading millis() and redefining the time every update for each Fade object
*/

#include "Fade.h"
#include <Bounce2.h>

const byte ledPin = 5;
const byte buttonPin = 6;

Fade myLed(ledPin, 15, 0, 255, MILLIS_TIMER);// led1 speed 10 milliseconds(microSeconds)/step; pwm at 10 min and 255 max  (MILLIS_TIMER or MICROS_TIMER)
Bounce myButton = Bounce(); // Instantiate a Bounce object
void setup()
{
  Serial.begin(9600);
  //pinMode(13, OUTPUT);
  myButton.attach(buttonPin);
  myButton.interval(10); // interval in ms
  pinMode(buttonPin, INPUT_PULLUP);
  myLed.begin();
  Serial.println("Setup Complete...");
}

void loop()
{
  static bool activeFading = false;
  static byte lastPressState = HIGH;
  static unsigned long lastMillis = 0;
  static unsigned long displayMillis = 0;
  static byte storedSetpoint = 255;
  static int led1Increment = 5;

  myLed.update();
  myButton.update();
  byte thisPressState = myButton.read();
 
  if (thisPressState == LOW && lastPressState == HIGH)
  {
    lastMillis = millis();  // start timer when button is pressed
    Serial.println("Pressed");
  }
  else if(thisPressState == HIGH && lastPressState == LOW)  //What to do when button is released?
  {
    Serial.println("Released");
    if (!activeFading)
    {
      myLed.setTarget(myLed.getSetpoint() == myLed.getMin()? storedSetpoint : myLed.getMin()); // on off with a simple quick button press
    }
    else
    {
      activeFading = false;  // simply stop fading
    }
  }
  if(thisPressState == LOW && millis() - lastMillis > 1000UL && activeFading == false)
  {
    activeFading = true;  // if you are holding down the button for > 1 sec, start fading
  }
  if (activeFading)
  {
    fadeLight(&myLed, storedSetpoint, led1Increment);
  }
  lastPressState = thisPressState;
  if (millis() - displayMillis > 1000)
  {
    Serial.print("Current Briteness:");
    Serial.println(myLed.getCurrent());
    Serial.print("Current Setpoint:");
    Serial.println(myLed.getSetpoint());
    Serial.println();
    displayMillis += 1000;
  }
}

void fadeLight(Fade* myFade, byte &savedSetting, int &increment)
{
  static unsigned long lastUpdateMillis = 0;
  if (millis() - lastUpdateMillis > 125UL)
  {
    myFade->setTarget(constrain((myFade->getSetpoint() + increment), myFade->getMin(), myFade->getMax()));
    if(myFade->getSetpoint() == myFade->getMin() || myFade->getSetpoint() == myFade->getMax())
    {
      unsigned long catchUpDelay = millis();
      Serial.println("FLIP");
      increment *= -1;
      Serial.println(increment);
      while(millis() - catchUpDelay < 1000UL)  // let's hold here at the peak and trough in order to be able to set to min/max easily
      {
        myFade->update();
      }
    }
    savedSetting = myFade->getSetpoint();
    Serial.println(myFade->getSetpoint());
    lastUpdateMillis = millis();
  }
}

Fade.h:

#ifndef Fade_h
#define Fade_h

#include <Arduino.h>

enum timer{
  MILLIS_TIMER,
  MICROS_TIMER
};

class Fade
{
  public:
    Fade() {};
    Fade(int pin, uint32_t timeStep = 15, uint8_t minVal = 0, uint8_t maxVal = 255, timer timerSelect = MILLIS_TIMER);
    void begin();
    void setTarget(int to);
    void update();
    void update(uint32_t time);
    uint8_t getMin();
    uint8_t getMax();
    uint8_t getCurrent();
    uint32_t readSpeed();
    uint32_t writeSpeed(uint32_t time);
    uint8_t getSetpoint();
  private:
    uint8_t _min;
    uint8_t _max;
    uint8_t _targetFade;
    uint8_t _pwmRate;
    uint32_t _time;
    uint32_t _last;
    uint8_t _pin;
    bool _microsTimer;
};

#endif

Fade.cpp:

#include "Fade.h"
#include <Arduino.h>

Fade::Fade(int pin, uint32_t timeStep, uint8_t minVal, uint8_t maxVal, timer timerSelect)
{
  _pin = pin;
  _time = timeStep;
  _min = minVal;
  _max = maxVal;
  analogWrite(_pin, _min);
  _pwmRate = _min;
  _microsTimer = timerSelect;
}

void Fade::begin()
{
  analogWrite(_pin, _min);
}

void Fade::setTarget(int to)
{
  _targetFade = (uint8_t) constrain(to, _min, _max);

  this->update();
}

void Fade::update()
{
  this->update(_microsTimer? micros() : millis());
}

void Fade::update(uint32_t time)
{
  if (time - _time > _last)
  {
    _last = time;
    if (_pwmRate > _targetFade) analogWrite(_pin, --_pwmRate);
    if (_pwmRate < _targetFade) analogWrite(_pin, ++_pwmRate);
  }
}

uint8_t Fade::getSetpoint()
{
  return _targetFade;
}

uint8_t Fade::getCurrent()
{
  return _pwmRate;
}

uint32_t Fade::readSpeed()
{
  return _time;
}

uint32_t Fade::writeSpeed(uint32_t time)
{
  _time = time;
}

uint8_t Fade::getMin()
{
  return _min;
}

uint8_t Fade::getMax()
{
  return _max;
}

Hi,
This is a current supply, not a voltage supply.


They do not like PWM switching in their output circuit because they already use PWM to provide CONSTANT current, so when you try to switch the load in and out, they have problems, even shutting down.

Tom... :slight_smile:

Thanks Tom,
I thought it was something like that though I don’t know enough to figure it out on my own. I don’t really need a dimmer on my desk light.

I still am going to try and use this for my kids bed light. It’s LED and runs off a very small (sized) wall wart with a nameplate rating of 500ma and 3.5 - 8 volt DC. Although the variable rating of this suggests to me that I might have a similar problem with this also. If I do get this one to work I want to power the Arduino off the same wall wart also. I’m sure this decreases the likelihood of it working by about 80%. LOL

Your diagram shows DC coming out of a transformer. That simply can not happen.

That “transformer” is an inductor. Also note that the 4-pin chip on the bottom near the AC inputs is a bridge rectifier.

Look up the HV9925 chip to get an idea of what a typical GU10 LED bulb circuit looks like.

I only have ONE comment: Look good on that board. There is NO isolation between the primary and secondary - so you are making your Arduino "live" and there is good chance that you may kill yourself.

NEVER play with this kind of circuits unless you have a VERY GOOD understanding on what is happening!

// Per.

Zapro:
I only have ONE comment: Look good on that board. There is NO isolation between the primary and secondary - so you are making your Arduino "live" and there is good chance that you may kill yourself.

NEVER play with this kind of circuits unless you have a VERY GOOD understanding on what is happening!

// Per.

LOL, I have been a certified electrician for 25 years. I'm not going to get "killed" from 120 VAC no matter what I do on this board. And I am only a tinkerer when it comes to electronics, so I make no claim as to any of that. That's why I come here.

I thought that you guys could help me understand what is going on in what I loosely called/call a "transformer". Whatever it is it is changing 120 VAC into a lower voltage DC current. I have read a little before about current regulator IC circuits like Tom mentioned. And I though his post very helpful. I do now realize that what I thought was a small transformer in the board is actually an inductor. Whatever that does. LOL. I remember in trade school we were working with X of L and X of C equations. So I am lightly familiar with inductive reactance.

And I realize that this device is not an isolation transformer. But I have worked with many low voltage monitoring systems of different natures that we often "piggy backed" on top of a single set of contacts.

This is where you tie the negative conductors of to different systems each with their own power supply. As long as you don't complete the circuit with a second bond between system they both remain isolated from the other with no complete circuit path. Should this not be true here also or am I in danger of "killing" myself?

Also I find much of the temperament of some of the posters to this thread rather ridiculing rather than in a helpful tone. Maybe I'm just a snowflake. LOL.

But thanks all the same. It's all been very helpful if somewhat unpleasant.