New project Triac Dimmer

Hi All,
Anyone is interested to help me finish a project?
I have some work done but have got a lot of problems now and this week must have done and I haven’t got a clue what to do to get this code working.
Please see code attached and diagram. I can pay for finished code if possible.

This is dimmer what it should do:
when powered display show temperature from LM35 sensor.
When encoder button pressed then showing set temperature and in that moment I can turn encoder to set wanted temperature between 10-60C. To write that set temperature to EEPROM I need to push encoder button and program come back to show sensor temperature.
If I hold encoder button longer than 2seconds than I can choose a menu P1, P2, P3, C, F by turning encoder left or right.
once selected option in menu press button to confirm and program goes back to LM35 temperature and in background doing one of the P1-P3 option. C and F is only for choosing temperature in C or F.
P1 is a dimmer
P2 is Pulse
P3 ON/OFF

P1 if temp is lower 2deg C from SET temp then triac dimm (like pwm) from max ON to 75%
if temp is lower 1deg C from set temp then triac dimm (like pwm) from 75% ON to 50%
if temp is exactly as set temp then triac dimm from 50% to 25%
if temp is above set temp+1 then triac is OFF

now when temp is going down:
if temp is between set temp+1 and set tempthen triac dimm from OFF to 25%
if temp is exactly as set temp then triac dimm from 25% to 50%
if temp is lower 1deg C from set temp then triac dimm (like pwm) from 50% ON to 75%
if temp is lower 2deg C from SET temp then triac dimm (like pwm) from 75% ON to MAX

P2 Same criteria as above but switch Triac ON fro 5second and OFF for 3second
if temp is lower 2deg C from SET temp then switch Triac ON fro 5second and OFF for 3second
if temp is lower 1deg C from set temp then switch Triac ON fro 3second and OFF for 5second
if temp is exactly as set temp then triac OFF

P3 If temp is lower then set TRiac is ON
If temp is exactly as set temp triac is OFF
It can be added small hysteresis to stop flickering the bulb.

Please let me know if you want to do that ASAP
My email: danio40@op.pl

arduino driver.pdf (270 KB)

code.txt (12.5 KB)

Triac Zero cross detection.pdf (85.4 KB)

Triac outpu and power supply.pdf (76.4 KB)

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom.. :slight_smile:

I guess this is some sort of school work and Habistat is some fictitious product and you have been given half functioning code to get right.

Anyway, I've had a very quick look and have found instance of where the code does not correspond with the schematic.
E.G. Triac in the code has arduino pin 9 [PB1].
In the schematic, arduino pin 9 [PB1] is allocated to display segment G.

If you want to pay someone to sort it out, it probably should go in this section http://forum.arduino.cc/index.php?board=26.0

Maybe click on "Report Post" and ask a mod. to move it.

You could detect zero crossings and drive an opto-triac via a timer to the big triac…

or perhaps a conventional R - C- diac triac driver with the R being an LDR with an LED driven by a PWM output to illuminate it.

the first is more accurate but more difficult.

regards

Allan

This is a very good start point, check it AC Phase Control

Zero cross detector and opto-isolated trigger circuit for the triac, and a Timer

Thanks for help but this code:

a–;
OCR1A = a; //set the compare register brightness desired.
if (a<65){a=483;}
delay(15);

does only from OFF to MAX in loop
How can I and what to change to drive MIN and MAX or in a half power stay.

I need to know what to change to set light level and what to change for 50Hz (10uss not 8.33us)

the schematic shows dig in and dig out swapped. And the input should have eg a 10k pullup to +5.

And you only get a zero crossing edge once per full cycle, so will have to generate 2 triac trigger pulses per
input edge.

But otherwise OK

regards

Allan.

I'm using my Zero cross detection - diagram at the top attached and it is fine