AC dimmer with BTA24-600BW blink light

Hello.

I need help with my circuit. I created circuit like below.


I also upload some code to arduino.

const int ZERO_CROSSING = 2;
const int OUT = 5;
const int POT = A5;

volatile int zeroCrossCount = 0;
int power = 0;

void setup() {
  pinMode(OUT, OUTPUT);
  pinMode(ZERO_CROSSING, INPUT_PULLUP);
  pinMode(POT, INPUT);
  attachInterrupt(digitalPinToInterrupt(ZERO_CROSSING), zeroCross, FALLING);
}

void loop() {
  power = map(analogRead(POT), 0, 1023, 0, 100);
  digitalWrite(OUT, zeroCrossCount < power || power == 100);
}

void zeroCross() {
  zeroCrossCount = (zeroCrossCount + 1) % 101;
}

Unfortunately, despite connecting the system as shown in the drawing, a problem occurred. The bulb that I used as a load (R_LOAD in the picture) blinks after starting the system. The flashing follows a sine wave. Depending on the setting of the "power" variable, the bulb lights up for a shorter or longer time and is turned off for a shorter or longer time - according to the period of the sine wave. Ultimately, my system would work with a 3kW boiler heater or a 2.5kW radiator, so I'm a bit afraid of this flashing. Is it possible to modify the code or connections on the system to make the bulb glow continuously? What could be causing the flashing?

Previously, I created a circuit based on a ready-made SSR component. However, I used analog inputs from Arduino to control it, so I controlled the analogWrite function in the code instead of digitalWrite. It was then possible to set the power in the parameters of this function in the form of an appropriate number. This code allowed me to smoothly control the bulb, which was lit all the time with the power I entered in the Arduino code. The bulb wasn't blinking. Unfortunately, when I connected a larger load to such a system, the voltage measured in the socket every second fluctuated, for example, from 255V to 242V (the device had, for example, 3kW of power). And then again from 242V to 255V in a second. I decided not to use analogWrite because I found that this command was responsible for such fluctuations.

The bulb bliks exactly like that. Blinking periods are different and depends on variable power.
gewYMN6

try these sketches

this project has heater regulation

1 Like

Explain what you want the Arduino to do with this line.

Explain what you want the Arduino to do with this line.

I think what you want is:

 analogWrite(OUT, zeroCrossCount < power || power == 100);`

Ref: analogWrite() - Arduino Reference

Will not the expresion evaluate to 0 or 1, false or true?

If zeroCrossCount is less than or equal to the set power (which translates into the number of crossings through 0), the expression will return TRUE, i.e. a high state. Otherwise, FALSE, i.e. low state. You should also include the option when we have power = 100 and zeroCrossCount = 100. In this case, the Arduino output will be logical zero, although we would expect a high state - that's why we add OR power == 100.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.