SSR with PWM vs Digital Pot
#1
Posted 17 February 2011 - 12:07 AM
#2
Posted 17 February 2011 - 07:28 AM
With the PWM frequency high enough (kHz range) the flickering will not be noticeable.1) Using a 220V 40A SSR with DC control that accepts 3.3V (most seem to be 3V-38V). Then use PWM to control the circuit. My concern with this approach is that my house lights will flicker due to the rapid on/off firing of the PWM.
#3
Posted 17 February 2011 - 04:43 PM
#4
Posted 17 February 2011 - 09:18 PM
#5
Posted 26 February 2011 - 10:07 PM
I followed your advice and am controlling in increments of 16.7 ms. So I am passing a duration in 10 increments of 16.7 ms and the period is set to 167 ms. When I use my pot to increment from 1-10 I get totally random progressions. Some increments act as full power, some of the lower increments are higher than the upper increments. It all seems to be totally random. However, each increment does behave the same way each time.
I have tried many different multiples and the closest I got was using 200 ms period and 20 ms increments for the duration. But that gave me a nice progression for increments 0-5 (0 off and 5 full power) but then repeated the same thing for increments 6-10. That just doesn't make any sense to me.
I've pulled the relevant code out and put it below. Any guidance on how get predictable results is very much appreciated.
public class Program
{
static PWM heater = new PWM(Pins.GPIO_PIN_D6);
static AnalogInput mypot = new AnalogInput(Pins.GPIO_PIN_A0);
mypot.SetRange(0, 10);
Thread potthread = new Thread(new ThreadStart(PotThread));
potthread.Start();
private static void PotThread()
{
while (true)
{
const uint period = 166 * 1000 * 1000;
uint duration = (uint)(16.6 * mypot.Read() * 1000 * 1000);
heater.SetPulse(period, duration);
//heater.SetDutyCycle(100);
mylcd.Write(3, mypot.Read().ToString());
Debug.Print(duration.ToString() + "," + period.ToString());
Thread.Sleep(250);
}
}
}
#6
Posted 27 February 2011 - 03:05 PM
This particular application is to control a heater. I ordered an SSR and am testing it with a light bulb as a load. My testing is not going very well and I need some help.
I followed your advice and am controlling in increments of 16.7 ms. So I am passing a duration in 10 increments of 16.7 ms and the period is set to 167 ms. When I use my pot to increment from 1-10 I get totally random progressions. Some increments act as full power, some of the lower increments are higher than the upper increments. It all seems to be totally random. However, each increment does behave the same way each time.
I have tried many different multiples and the closest I got was using 200 ms period and 20 ms increments for the duration. But that gave me a nice progression for increments 0-5 (0 off and 5 full power) but then repeated the same thing for increments 6-10. That just doesn't make any sense to me.
I've pulled the relevant code out and put it below. Any guidance on how get predictable results is very much appreciated.
public class Program
{
static PWM heater = new PWM(Pins.GPIO_PIN_D6);
static AnalogInput mypot = new AnalogInput(Pins.GPIO_PIN_A0);
mypot.SetRange(0, 10);
Thread potthread = new Thread(new ThreadStart(PotThread));
potthread.Start();
private static void PotThread()
{
while (true)
{
const uint period = 166 * 1000 * 1000;
uint duration = (uint)(16.6 * mypot.Read() * 1000 * 1000);
heater.SetPulse(period, duration);
//heater.SetDutyCycle(100);
mylcd.Write(3, mypot.Read().ToString());
Debug.Print(duration.ToString() + "," + period.ToString());
Thread.Sleep(250);
}
}
}
I'm probably totally wrong about how PWM works, but I think you would want to define the following lines before the while, and only update the LCD inside the while loop? Otherwise, I could see the PWM starting, the loop sleeping for 250ms, and then restarting itself, causing what may look like random behavior. Again, I haven't looked at this stuff yet, so I'm not sure if that is what is happening, just a guess.
const uint period = 166 * 1000 * 1000;
uint duration = (uint)(16.6 * mypot.Read() * 1000 * 1000);
heater.SetPulse(period, duration);
//heater.SetDutyCycle(100);
#7
Posted 27 February 2011 - 03:22 PM
#8
Posted 27 February 2011 - 04:20 PM
Edited by acetate, 27 February 2011 - 04:24 PM.
#9
Posted 28 February 2011 - 12:44 AM
It would be great just to be able to set the PWM clock to 1 sec and then use duty cycle to control the percentage. Did the clock rates ever get exposed?
Microsoft is working up a new "common PWM object model" for .NET MF 4.2. We're planning on incorporating it into the v4.1.2 firmware and also exposing the ability to set the core PWM clock speed.
Chris
P.S.
I think what you actually want to do is set the PWM clock to something like 10us and control the duty cycle from there. If you set the clock speed to ~1MHz, you'd get <=1 pulses per second total.
BTW, have you tried to just use the DutyCycle parameter instead?
Chris
#10
Posted 28 February 2011 - 12:54 AM
#11
Posted 28 February 2011 - 05:47 AM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users