No.
It is the bit where you link the logic output to the System timer. This requires you to continuously call the digitalWrite function at least every mS.
There is no way you can synchronised this to the zero crossing which is what you need to do.
You have been continuously told this and yet you keep ignoring this. Until you get your head round this fact you are wasting everyone's time.
Then you make the problem 10 times harder to write.
I was not ignoring that, I just don't understand
By not saying that you don't understand you are ignoring me.
The way this forum works is that if you don't understand something you ask.
You need to be able to detect when the zero crossing of the AC waveform you want to control has occurred, and hang all your timing off that.
The simplest way is to get a logic level square wave generated from the AC signal, through an optical isolator.
Then the code needs to enter a loop that waits until the signal changes. This is simple, suppose the signal is coming in on pin 4 then the code:-
while( digitalRead(4) != lastRead) { } // this only exits when pin 4 changes state
lastRead = digitalRead(4);
// now do the delay and then fire the triac
Grumpy_Mike:
You need to be able to detect when the zero crossing of the AC waveform you want to control has occurred, and hang all your timing off that.
Look like we got misunderstanding here.
Ok
I did zero crossing, but just single zerocrossing(I prefer one, because using 3 zcross it change whole my circuit board).
Since I have 3 TRIAC to trigger(3 phase)
so I hang with 1 zerocross input, but need to write 3 output
*NOTE : 3 phase balanced with same load and measured phase before
lets say... for time delay like this
phase A to B 4ms, phase B to C 4ms
A = 0 ms
B = 4 ms
C = 8 ms
code I using :
int lastread = LOW;
unsigned long phaseA;
//unsigned long phaseB;
//unsigned long phaseC;
unsigned const interval = 1;
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 as an output.
pinMode(4,INPUT);
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
while(digitalRead(4) != lastread)
{
digitalWrite(13,(millis()%9)
millis()=phaseA;
if(phaseA-interval>=4UL)
{
digitalWrite(12,(millis()%9)
if(phaseA-interval>=8UL)
digitalWrite(11,(millis()%9)
}
}
lastRead = digitalRead(4)
}
// the loop function runs over and over again forever
void loop()
{
}
Is that code you mean?
I am not sure with timing code one
I have never tried to code 3-phase ac using an arduino, but I do know that 3-phase phase shift is 120 degrees. If a 60 Hz ac signal has a period of 16.6667 mS, and 120 degrees is 1/3 of 360 degrees, I would think that 120 degree phase shift would be t+ 5.5555 mS and t + 11.1111 mS, so the phases would be :
A: t + 0
B: t + 5.5555 mS (120 degree phase shift)
C: t + 11.111 mS B + 120 degree phase shift)
NOT
A: t + 0,
B: t + 4 mS (90 degree phase shift)
and
C: t + 8 mS (B + 90 degree phase shift)
The code in reply #44 is still not having a zero crossing synchronization.
Please read my replies. Their should be nothing in the 'while' braces for the synchronization. You need to do the synchronization EVERY cycle. The code in the setup function is run only once.
Plus what the others have said.
But the problem is how to code it?
By using a state machine and the blink without delay example expanded to three state machines.
Low power factor means you’re not fully utilizing the electrical power you’re paying for
Which is the wrong way round. In fact industrial users are charged a punitive rate for having a poor power factor. If it were not for this extra tariff, or you are a domestic user you would actually be being charged less that the power you are using with a poor power factor.
Mike I kind of think this it wrong first off if the voltage drops you will use more power to do the same work.
If your voltage is 240 volts load 100 amps you use 24000 Watts
Now if the voltage drops your load becomes 106 amps you use 25440 Watts
If you added a bank of caps to keep the voltage to 240 you save money because you used 1440 less watts.
By phase shifting you want change the 90 deg points to a higher level.
Mike I kind of think this it wrong first off if the voltage drops ......
But the voltage doesn't drop it is just out of phase with the current.
An electricity meter only charges for the power projected on the real axis, so you essentially get free power with an inductive load. The electricity companies don't like that so for industrial users they charge extra if the power factor drops below a certain point any time in the billing period, for the whole billing period. This is way more than normal prices hence it is worth industrial users having power factor correction capacitors on site.
For domestic users the equipment you use has power factor corrections fitted in appropriate devices. However, if you remove them then all still works and it costs you next to nothing to run.
Grumpy_Mike:
The code in reply #44 is still not having a zero crossing synchronization.
Please read my replies. Their should be nothing in the 'while' braces for the synchronization. You need to do the synchronization EVERY cycle. The code in the setup function is run only once.
Plus what the others have said.
By using a state machine and the blink without delay example expanded to three state machines.
So... I just add to void loop() function?
pin 4 is for zerocross, hmmm
sorry, its hard for me to under stand
Grumpy_Mike:
Plus what the others have said.
By using a state machine and the blink without delay example expanded to three state machines.
I ever think about that, using blink without delay sample.
but in that sample the duty cycle just for only 50:50 which mean can't use for trigger,
even I use this to start millis() %9) each pulse change, it just work for 1 phase
how I can add 2 others phase?
its so complicated for me since I must manage it in 3 phase.
NO!
I said "say" pin 4. This means it is what ever pin you connect the zero crossing circuit to.
but in that sample the duty cycle just for only 50:50 which mean can't use for trigger,
So you change it. Look programming is not about cut and paste, it is about writing instructions that do what YOU want to do.
even I use this to start millis() %9)
Stop using that statement / method. It is stupid and it will not work for you.
its so complicated for me
I am beginning to think it is too complicated for you with your current state of knowledge. Here we are at post #53 and you appear to have made no progress at all. Get a single phase working first. You think that you have done this but I see no evidence that you have. You have posted no code that will work and the static scope shots you have posted have not shown the expected wave forms.
next 3 phase with 220 AC (fused 2A) with load around 1K - 3K3 ohm
Quite honestly with the competence you have shown so far I would be surprised if you manage to avoid an explosion. Certainly electrocution and a fire are on the cards if you continue without actually learning something.
So lets get things clear. Please post the code and the schematic for what you think is a working single phase, phase angle control. If that works then we can look at how to extend this three phase BUT you must show us that you can understand a single phase system first.
So lets get things clear. Please post the code and the schematic for what you think is a working single phase, phase angle control. If that works then we can look at how to extend this three phase BUT you must show us that you can understand a single phase system first.
int lastread = LOW;
unsigned long phaseA;
//unsigned long phaseB;
//unsigned long phaseC;
unsigned const interval = 1;
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 as an output.
pinMode(12,INPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
while(digitalRead(12) != lastread)
{
digitalWrite(11,(millis()%9));
millis()=phaseA;
if(phaseA-interval>=4UL)
{
digitalWrite(10,(millis()%9));
if(phaseA-interval>=8UL)
digitalWrite(9,(millis()%9));
}
}
lastRead = digitalRead(12)
}
// the loop function runs over and over again forever
void loop()
{
while(digitalRead(12) != lastread)
{
digitalWrite(11,(millis()%9));
millis()=phaseA;
if(phaseA-interval>=4UL)
{
digitalWrite(10,(millis()%9));
if(phaseA-interval>=8UL)
digitalWrite(9,(millis()%9));
}
}
lastRead = digitalRead(12)
}
If you use ISIS Proteus 7, I attached the .DSN file