Arduino AC Power Shield!

Actually there is a good amount of spacing between the HV and 5V. I have a few products that have the traces of voltage much closer! Everyone I work with in electronics is very careful and I am used to up to 480V power, so HV doesn't bother me at all, I just know to be careful.

I understand what you mean about doing a seperate box, however then there is no point of a shield at all, the only actual logic on the board is the arduino pins to drive the opto-couplers. Everything else is HV, so those traces are very small and only 5 of them and a few grounds. Maybe I will play around with the idea of a seperate board, I am already building one for a different project.

I personally like the idea of having everything on one circuit. I can put this shield on a arduino and put it in an enclosure and I have 4 circuit control in a very compact package with dimming too.

I like the relay squid, but for simple things it is just too darn expensive for me!

I wasn't talking about trace spacing !

More like:

left side of PCB: safe
right side: hands off

Of course this is hard to do on such a small area.

Ahhh, yes. I am looking into encasing that end in epoxy for that reason. I will let you know how it goes.

Anyone interested in one can buy here http://ryanjmclaughlin.com/arduino/ also post, PM, or email if you have interest in a final version so I know how many to make.

I'm working up a spot-welder of the microwave transformer variety.
It was a 1500 W unit, and I wound on 3 turns of #1 flex welding cable, so the current capability should be useful at 3.1 V off load..
I thought I'd do a cycle counter with a DueMilanove, using one d/o to drive an SSR I had on hand. The SSR uses an optoisolator, so its a safe approach. Still thinking about the way to set a pulse between 0.5 and 3 seconds repeatably.
A 2 line LCD and push button inputs seem a little over the top though....

Brian W

Ryan,

Nice idea, but I agree with the others about mixing the AC with the lower voltage stuff. Many do not know the dangers of AC voltage, and the Arduino is all about experimentation, and making this stuff easy for people just starting out.

Just a suggestion. Build the AC stuff with the opto's on on a 2nd board, then use a small data cable to connect the two. Then the HV section could be put in a external box and protected.

Dale

Makes sense... I am working on a separate board as well. With a remote connection. The shield is working good though, I tested it with some light bulbs last night.

Any thoughts on the AC breakout? Molex connectors? Solder your own? Standard Outlets?

I would use screw terminals, or maybe you could build it into a power strip that uses standard outlets, then the end user does not have to use anything. They are cheaper than any box you could buy.

Dale

Standard Outlets?

Standard sockets for which country? And will the shield work properly on 240V, 50Hz power?

120v 60hz. The board needs to be setup differently for 240v.

If you have the time, I'm curious what would need to be changed for this to work with 240V/50Hz. Are you sill using the same schematic from your other post?

I've been looking at doing some lighting control myself and have been researching building something like this.

Cheers,

hads

I know you are not directing this query to me, but using ONE Arduino digital output to drive a SEPERATE bolt down SSR means you buy just one thing - a 120 volt or a 240 volt SSR at whatever rating you need: 10A, 25A or 40A

This would be a safe, no brainer approach except for one small detail:
opto-isolated zero crossing SSRs don't come cheap.
Sadly.

Brian Whatcott

I agree an SSR would be ideal, except in this particular instance I'd like the ability to dim lighting.

hads,

240V/50Hz... is that 120V on 2 legs? I am not that familiar with that power.

Check out the data sheet for the opto-triac drivers. Intelligent Power and Sensing Technologies | onsemi it has some 240V examples. Basically the same setup with some different resistor values between the opto-coupler and triac. The zero-cross can stay the same, just ensure you adjust the resistor value for the rating of the H11AA1 maybe 50k?

Remember, if you want to switch high current loads with this, your PCB needs to have large traces and a heavy copper layer to handle the current, even though the triac may be rated for 12A make sure the interconnects are as well!

betwys, I agree I use alot of SCR's at work. Like you said, the big downside is cost, and sometimes space. I really built this for someone that needs something low cost and simple to hook up. AC is a strange world.

This circuit is just about the same thing that goes inside a SCR, it is really just making the cost less by breaking it down and giving some more control.

I am working on the final version and am leaning towards a separate board rather than working with a shield. I personally love the shield idea, but I know it can strick some high voltage fears in people.

Here is the current UNTESTED code... let me know if you have any better ideas of doing this... I hope to test this tonight or tomorrow.

/*
  AC Light Control
  
  Ryan McLaughlin <ryanjmclaughlin@gmail.com>
  
  The hardware consists of an Triac to act as an A/C switch and 
  an opto-isolator to give us a zero-crossing reference.
  The software uses two interrupts to control dimming of the light.
  The first is a hardware interrupt to detect the zero-cross of
  the AC sine wave, the second is software based and always running 
  at 1/128 of the AC wave speed. After the zero-cross is detected 
  the function check to make sure the proper dimming level has been 
  reached and the light is turned on mid-wave, only providing 
  partial current and therefore dimming our AC load.
  
  Thanks to http://www.andrewkilpatrick.org/blog/?page_id=445 
    and http://www.hoelscher-hi.de/hendrik/english/dimmer.htm
   
 */
 
#include <TimerOne.h>           // Avaiable from http://www.arduino.cc/playground/Code/Timer1

volatile int i[4], j;               // Variable to use as a counter
volatile boolean zero_cross[4] = {0,0,0,0};  // Boolean to store a "switch" to tell us if we have crossed zero
int AC[4] = {4,5,6,7};          // Setup the AC output pins
int ACenable[4] = {1,1,1,1};    // Enable dimming for this output
int output[4] = {64,64,64,64};  // Create output vars for Dimming level (0-128)  0 = on, 128 = 0ff
int dim = 0;                    // Dimming level (0-128)  0 = on, 128 = 0ff
int freqStep = 65;              // Set the delay for the frequency of power (65 for 60Hz, 78 for 50Hz) per step (using 128 steps)
                                // freqStep may need some adjustment depending on your power the formula 
                                // you need to us is (500000/AC_freq)/NumSteps = freqStep
                                // You could also write a seperate function to determine the freq

void setup() {                                      // Begin setup
  pinMode(AC[0], OUTPUT);                           // Set the Triac pin as output
  pinMode(AC[1], OUTPUT);                           // Set the Triac pin as output
  pinMode(AC[2], OUTPUT);                           // Set the Triac pin as output
  pinMode(AC[3], OUTPUT);                           // Set the Triac pin as output

  attachInterrupt(0, zero_cross_detect, FALLING);   // Attach an Interupt to Pin 2 (interupt 0) for Zero Cross Detection
  Timer1.initialize(freqStep);                      // Initialize TimerOne library for the freq we need
  Timer1.attachInterrupt(output_check, freqStep);   // Use the TimerOne Library to attach an interrupt
                                                    // to the function we use to check to see if it is 
                                                    // the right time to fire the triac.  This function 
                                                    // will now run every freqStep in microseconds.   
  Serial.begin(9600);                                         
}                                                   // End setup
  
void zero_cross_detect() {                 // function to be fired at the zero crossing                           
    zero_cross[0] = 1;                     // set the boolean to true to tell our dimming function that a zero cross has occured
    zero_cross[1] = 1;
    zero_cross[2] = 1;
    zero_cross[3] = 1;
}                                          // End zero_cross_detect

void output_check() {                      // Function will fire the triac at the proper time

for( j=0; j<4; j++ ) {                     // Loop this function for each one of the outputs
  if(zero_cross[j]) {                      // First check to make sure the zero-cross has happened else do nothing
    if(i[j] >= output[j] && ACenable[j]) { // Check and see if i has accumilated to the dimming value we want
      digitalWrite(AC[j], HIGH);             // Fire the Triac mid-phase
      delayMicroseconds(2);                // Pause briefly to ensure the triac turned on
      digitalWrite(AC[j], LOW);              // Turn off the Triac gate (Triac will not turn off until next zero cross)  
      i[j]=0;                              // If we fired the triac, reset the counters
      zero_cross[j] = 0;                   // Reset the zero cross detection
    } else { 
      i[j]++;                              // if nothing is done incriment th counter
    }
  }                                       // End zero_cross check
}                                         // End each loop
}                                         // End output_check function

void loop() {                        // Main Loop
 
  output[0] = 75;                    // Set output values for dimming
  output[1] = 25;
  output[2] = 50;
  output[3] = 100;

  Serial.print("Output Values:   ");
  Serial.print(output[0]);
  Serial.print("\t");
  Serial.print(output[1]);
  Serial.print("\t");
  Serial.print(output[2]);
  Serial.print("\t");
  Serial.print(output[3]);
  Serial.print("\n");
}

ryanjmclaughlin,

Thanks for the pointer, I should have read the data sheet more carefully - you're right the info is there.

To clarify, it's 230-240V/50Hz, used in New Zealand, Australia and the Pacific.

I've done a little work with HV before but not a huge amount, I'd be installing on a separate board in a box isolated from the Arduino. More than happy to work together if you're interested.

Cheers,

hads

hads,

Let me know if you can do any testing. there may be a good resistor combination for both power systems. e-mail me an I can show you some of the designs for the next board. I am used to doing HV, but new at micros.

what is the voltage on the line for you? I know in US what we call 220V is actually 4-conductors... 120V, 120V, Neutral, GND. Is your power the same way? or 240V, Neutral, Ground?

ryanjmclaughlin,

Our 240V is 3 conductor, 240V, Neutral, Ground.

I'll drop you an email regarding testing.

Cheers,

hads

Another red herring (probably) for the person that wants to dim lighting with no drama.....
All the stores carry light dimmers - around 700 watts for around $10.
This is relatively attractive pricing. The potentiometer dimmer control would not be hard to automate with a smoothed analog output, I suspect!

Brian W