Zero-Cross Detection, AC Motors, and Bluetooth issue

Why not ?

The turn-on has to be matched to the line frequency.

An ssr has a zero crossing detector built in. Is that what you are referring to ?
SSRs are designed for line frequency so how does the PWM signal conflict with that ?

A "zerocrossing" SSR won't allow a turn-on till AC is zero.
That's so there won't be a turn-on spike radiating noise.

So what your saying then is that with an SSR, no matter what you do , you only half two possible speeds, 50% (half cycle)or 100% fullcycle) ?

What kind of device do you need to "chop" the AC sinewave so it turns on and off whenever you want, anywhere in the cycle ? Is that an IGBT application ?

raschemmel:
So what your saying then is that with an SSR, no matter what you do , you only half two possible speeds, 50% (half cycle)or 100% fullcycle) ?

With a zerocrossing SSR, the two possible speeds are: Full On or Full Off.

With a SSR that can be turned on "at random", phase control is possible, but that SSR turn-on has to be synchronized with the line frequency.

That looks like a two-digit DCBA switch ? (that could be replaced with an array , right ?
Current limiting resistor for U1 is 15k ?
I can build this circuit easily (breadboard < 1 hour, perf-board soldered , 1 to 2 hours) but if someone else who can't build the circuit needed something that can do this and they wanted to buy one what would they be looking for (google search keyword) ?
(AC MOTOR SPEED CONTROL ?)

It's a good demo and tutorial . I liked the video showing the phase control switching on more or less of the sinewave.

The code wouldn't compile so I had to rearrange it a little bit to get it to compile:

BEFORE

//     ***  Triac_03  ***
//
//  It's Working!  17 NOV 2012
//  gateEnable output lags 
//  Triac_cue [zc] by 1-4 msec
//  via DIPSW1,2 
//

byte gateEnable = 3;     // alias output
byte DIPSW1 = 4;         // alias input
byte DIPSW2 = 5;         // alias input
byte GatePulseTime = 1;  // at or near Alt start
int timesel;
volatile boolean zeroCrossed = false;  // flag

void setup()
{
  pinMode(DIPSW1, INPUT);
  pinMode(DIPSW2, INPUT);
  pinMode(gateEnable, OUTPUT);
  attachInterrupt(0,Triac_cue,RISING); // Ext_Int on D2
}

void loop ()
{
  if (zeroCrossed == true)
  {triacTrigger();}
}
// ----- The Interrupt -----
void Triac_cue ()
{zeroCrossed = true;   //  !!!}

void triacTrigger ()
{
  DIPread();
  delay (GatePulseTime);
  digitalWrite(gateEnable, HIGH);   
  delay (1);
  digitalWrite(gateEnable, LOW);
  zeroCrossed = false;  // flag reset
}

void DIPread ()
{
  GatePulseTime = 1;
  timesel = digitalRead(DIPSW1);
  if (timesel == HIGH)
  {GatePulseTime = GatePulseTime + 1;}
  timesel = digitalRead(DIPSW2);
  if (timesel == HIGH)
  {GatePulseTime = GatePulseTime + 2;}
}

AFTER

 //     ***  Triac_03  ***
//
//  It's Working!  17 NOV 2012
//  gateEnable output lags 
//  Triac_cue [zc] by 1-4 msec
//  via DIPSW1,2 
//

byte gateEnable = 3;     // alias output
byte DIPSW1 = 4;         // alias input
byte DIPSW2 = 5;         // alias input
byte GatePulseTime = 1;  // at or near Alt start
int timesel;
volatile boolean zeroCrossed = false;  // flag

void setup()
{
  pinMode(DIPSW1, INPUT);
  pinMode(DIPSW2, INPUT);
  pinMode(gateEnable, OUTPUT);
  attachInterrupt(0,Triac_cue,RISING); // Ext_Int on D2
}
void triacTrigger ()
{
  DIPread();
  delay (GatePulseTime);
  digitalWrite(gateEnable, HIGH);   
  delay (1);
  digitalWrite(gateEnable, LOW);
  zeroCrossed = false;  // flag reset
}

void DIPread ()
{
  GatePulseTime = 1;
  timesel = digitalRead(DIPSW1);
  if (timesel == HIGH)
  {GatePulseTime = GatePulseTime + 1;}
  timesel = digitalRead(DIPSW2);
  if (timesel == HIGH)
  {GatePulseTime = GatePulseTime + 2;}
}

void loop ()
{
  if (zeroCrossed == true)
  {triacTrigger();}
}
// ----- The Interrupt -----
void Triac_cue ()
{
zeroCrossed = true;  
}
//  !!!}

raschemmel:
That looks like a two-digit DCBA switch ? (that could be replaced with an array , right ?

It's a DIP array.

raschemmel:
Current limiting resistor for U1 is 15k ?

That's fine, but it IS a power resistor situation.
raschemmel, that IC, U1, is an H11AA1

raschemmel:
if someone else who can't build the circuit needed something that can do this and they wanted to buy one what would they be looking for (google search keyword) ?
(AC MOTOR SPEED CONTROL ?)

For a drill motor it works great, but with a bathroom fan the effect isn't immediately apparent as there's some speed up/down lag (given the characteristics of those motors).
As far as a ready-to-go, off-the-shelf solution - I know naught.

raschemmel, you edited your previous post by adding my sketch from the blog, but I'm not sure why it wouldn't compile for you. You changed the order of the subroutines and placed void loop () near the end. I'm not an expert, but I pasted it there exactly as I wrote and used it.
BUT I did some shoddy text formatting and biffed a brace and semi-colon. (OUCH!)

void loop ()
{
if (zeroCrossed == true)
{triacTrigger();}[/font][/font]

Hey, raschemmel !
It was a BRACING error from when I did some text formatting to tighten up the presentation (to take up less space.)
Thanks for the tip.

That's fine, but it IS a power resistor situation.
raschemmel, that IC, U1, is an H11AA1

P=IE
E= I
R

VACpeak=120 * SQRT(2) =169.7V
VfH11AA1=1.2V
169.7-1.5=168.2V
IH11AA1=50mA= 0.05A
R=168.2/0.05=3364 ohms (MIN)
Let R = 6.8k
IH11AA1= 168.2V/7500=0.224 A

PH11AA1=0.0247 * 168.2=4.16 W
Let R = 7.5k
IH11AA1= 168.2V/7500=0.224 A
PH11AA1=0.224 * 168.2=3.77 W
RH11AA1 = 7.5k/4W

Hey, raschemmel !
It was a BRACING error from when I did some text formatting to tighten up the presentation (to take up less space.)
Thanks for the tip.

I used your previous post to locate the error and correct it.
It was here:

 // ----- The Interrupt -----
void Triac_cue ()
{
zeroCrossed = true;   //  !!!} <===BRACE MASKED BY COMMENT

moved it and

 // ----- The Interrupt -----
void Triac_cue ()
{
zeroCrossed = true;   //  !!!
}  <===COMPILES NOW

Here is the corrected version:

  //     ***  Triac_03  ***
//
//  It's Working!  17 NOV 2012
//  gateEnable output lags 
//  Triac_cue [zc] by 1-4 msec
//  via DIPSW1,2 
//

byte gateEnable = 3;     // alias output
byte DIPSW1 = 4;         // alias input
byte DIPSW2 = 5;         // alias input
byte GatePulseTime = 1;  // at or near Alt start
int timesel;
volatile boolean zeroCrossed = false;  // flag

void setup()
{
  pinMode(DIPSW1, INPUT);
  pinMode(DIPSW2, INPUT);
  pinMode(gateEnable, OUTPUT);
  attachInterrupt(0,Triac_cue,RISING); // Ext_Int on D2
}

void loop ()
{
  if (zeroCrossed == true)
  {triacTrigger();
}
}
// ----- The Interrupt -----
void Triac_cue ()
{
zeroCrossed = true;   //  !!!
}

void triacTrigger ()
{
  DIPread();
  delay (GatePulseTime);
  digitalWrite(gateEnable, HIGH);   
  delay (1);
  digitalWrite(gateEnable, LOW);
  zeroCrossed = false;  // flag reset
}

void DIPread ()
{
  GatePulseTime = 1;
  timesel = digitalRead(DIPSW1);
  if (timesel == HIGH)
  {GatePulseTime = GatePulseTime + 1;}
  timesel = digitalRead(DIPSW2);
  if (timesel == HIGH)
  {GatePulseTime = GatePulseTime + 2;}
}

You don't have to use one resistor.
I used three in series for value and to spread things out.
(Given equal values and ratings, they add.)
Three 5K 2W resistors are the equiv. of a 15K 6W.

raschemmel:
Can I use it the way I rearranged it or won't that work if it compiled ok that way ?
I assumed it was a bracing error but it seemed faster to rearrange it.
Do you want to post the corrected sketch for others or is my rearranged one ok ?

Yes, the rearrangement should work. The Arduino is smart enough to look for the void loop (), to put it inartfully,
I don't think the order is important, and I've seen others put all their subroutines at the top with the loop there last.
I made the correction at the blog.

Thanks !
I'll look online for an AC MOTOR SPEED CONTROL. I don't think they would call it a dimmer because the dimmers can't handle enough current to drive fan motors.

Ok I had a chance to test the pwm controlled SSR and the result was interesting. Runaway Pancake was correct when he said the ssr would either be ON or OFF but the interesting part is that in between it being on for a SINGLE HALF CYCLE or a SINGLE FULL CYCLE it can be OFF for MANY FULL CYCLES . I tried to take a photo of my scope screen but it didn't come out as expected. Shot 1 shows a single cycle on the left side of the screen. Shot-2 shows a single cycle on the right side of the screen. The trigger is set to Normal so it will only trigger if there is somthing there. The blank space in between the cycle in shot-1 and the cycle in shot-2 is the OFF time which is about 6 to 8 cycles that are OFF. As I increased the duty cycle the OFF PERIOD got smaller and smaller and there were fewer OFF cycles. When using an incandescent light bulb as a load, there is a distinct flickering that becomes less pronounced as the duty cycle increases. The big question is "CAN YOU USE A PWM CONTROLLED SSR TO CONTROL THE SPEED OF AN AC MOTOR ?" and the answer is a definite YES. There are some things that need to be clarified about this. I used an electric corded drill as a load. It is a single speed drill with no HI/LOW switch. I pulled the trigger and slowly turned the pot used to adjust the analog voltage mapped to the pwm pin and the drill motor started turning with a jerky motion on the low duty cycle end. The motor turned slowly (compared to full speed) but it was jerky. I did not see any arcing inside the drill (probably because the ssr was only turning on and off at the zero crossing ) . As I increased the duty cycle the jerkiness diminished and then seemed to be mostly eliminated even at a "medium-low to medium " speed . I was able to hold the drill at a medium-low or medium speed and I could see at least 4 to 5 cycles that were missing between the on cycles . The "jerkines" 'feels" almost like a motor gear-box with a broken or missing tooth on a gear. I turned the lights off to look for arcing through the ventilation vents of the drill but only saw some very dim flashes. At medium or above speed the jerkiness is almost unnoticable in that while it doesn't feel "smooth" , you would be more likely to describe it as "not smooth" than as "jerky". After playing around with it for 5 minutes I was convinced that if I had an AC motor driving something and I needed to control the speed and didn't really care if it was a little jerky , maybe because it was fans or something, I would use a PWM controlled SSR on a temporary basis until I could obtain a proper AC motor speed control. I didn't smell anything coming from the drill that would suggest there was any arcing (you can smell ozone if there is). Clearly it is not the optimum motor speed control but no one can argue that it is controlling the motor speed because it is obviously doing that without question. I would say if you don't have to use the lower 1/3 of the speed range , (meaning you are ok with 30% duty cycle and above ONLY) then I would say go ahead an try it if you have nothing better. I don't see any safety issues so it's really something you need to try to evaluate. After testing it I would be hesitant to agree with Runaway Pancakes' statement that "You can't do that etc..." I would qualify it by saying "You can do that but it isn't the smooth motor speed control that you would want and if you have to listen to it the human body doesn't like to hear something so inconsistent. It can become annoying. I robot wouldn't find it annoying because they are not human and wouldn't understand that a human wants to hear things that are smooth and varying in a smooth fashion, not in a jerky manner. If for example you had a sump pump or an air pump for inflating tires or something like that and you just wanted to slow it down and were not going to sit there and listen to it then you might find it ok. If you needed to slow a motor down because you absolutely could not use it at full speed then you would probably be happy to have anything that can get the job down, even if it was not the smoothest speed controller. I did not have any AC fans to use as test loads but I will see if I can find one to try.

I appreciate your lengthy disclosure, but I really don't think that this haphazard, hit-or-miss coincident approach viz. lopping off alternations and cycles unpredictably deserves the "definite YES" that you have bestowed on it.
You can slow your car down by pulling a plug wire that way.
(People around here go to great pains to get by without resistors, too.)
If it makes you happy as either a curiosity or as some desperation measure, fine.

I associate "control" with efforts and results that are purposeful, predictable, sustainable and sound.

I will likely have nothing more to add in the matter, it would only drag down my karma to posts ratio.

I appreciate your lengthy disclosure, but I really don't think that this haphazard, hit-or-miss coincident approach viz. lopping off alternations and cycles unpredictably deserves the "definite YES" that you have bestowed on it.
You can slow your car down by pulling a plug wire that way.
(People around here go to great pains to get by without resistors, too.)
If it makes you happy as either a curiosity or as some desperation measure, fine.

I associate "control" with efforts and results that are purposeful, predictable, sustainable and sound.

Ok, duly noted and your opinion is appreciated. In keeping with that opinion, I would point out that I never recommended using anything like this for a car. I said it might work for fans but I don't think I suggested it would be ok for anything. I agree with your statement about control. I offered my observations. I will modify my statement to retract the "definite YES" to "if you have no other options.." if that makes you feel better. I don't think I tried to sell the idea as anything approaching "optimum" or even normal. If I sounded too positive for your sensibilities then I'm sorry but I didn't feel that I was trying to defend my original suggestion to use an SSR, simply stating that I tested it and it was not what I had hoped but on the other hand I can not in all honesty say that it flat out didn't work. I made it clear it was choppy. I made it clear it was "chopping off cycles". I concealed nothing and misrepresented nothing.
I didn't recommend using it but clearly said if you have no other means , you could get by temporarily while you look for better options.

After playing around with it for 5 minutes I was convinced that if I had an AC motor driving something and I needed to control the speed and didn't really care if it was a little jerky , maybe because it was fans or something, I would use a PWM controlled SSR on a temporary basis until I could obtain a proper AC motor speed control.

I appreciate your feedback, but I think the above statement of mine made it clear this is not any kind of an acceptable solution for any long term basis, and while it doesn't as you say deserve the "definite YES", it does prove that you can do that . It just won't be something you want to keep doing. I think your following comment was a bit harsh:

If it makes you happy as either a curiosity or as some desperation measure, fine.

I don't think I deserved that just for trying something you said I couldn't do. As for the karma to post ratio, I could care less. They're not giving out any awards . You already know I am not in any popularity contest. I might even go so far as to say it sounded like you were scolding me for even trying it to see what would happen. When you get to the point where you are flat out discouraging learning, I think you have gone too far. At least now I know the difference between "you can't do that " and " You can do that but it doesn't work very well " . To me , learning that was worth being scolded by you, but I'm not going to lose any sleep over it.

OK, one more won't hurt.
/* Karma points are almost like getting paid, man! (-: */

raschemmel:
I never recommended using anything like this for a car.

It was an analogy.

raschemmel:
I think your following comment was a bit harsh:

If it makes you happy as either a curiosity or as some desperation measure, fine.

No harshness intended.

@fmeroney,

I finally got an AC fan (like the type you see installed in equipment for chassis ventilation) and tried it with the PWM controlled SSR and it was effectively either on (above 224) or off (below 224). Functionally it was not adjustable. There were no issues with the fan making noise but the speed was not constant below 255, it seemed to be speeding up and slowing down but not in any predicable manner. You might as well use a digital pin and just have on or off for x milliseconds .