circuitar / dimmer Goto Github PK
View Code? Open in Web Editor NEWArduino library to control dimmable lamps and other AC loads (110V / 220V).
License: MIT License
Arduino library to control dimmable lamps and other AC loads (110V / 220V).
License: MIT License
I am using DIMMER_RAMP and dimmer fades nicely when i set numeric value.
If i set dimmer to off()
it turns off lamp instantly.
If i set dimmer to on()
it turns lamp instantly to last value.
How can i fade on/off actions?
Hi,
with an Arduino Mega, is that possible to extend the number of AC dimmer to 20 or more ?
Thanks for your work
Bit hard to find. I finally looked in src/Dimmer.h and all was well. Please update README.md.
Otherwise great library. Thank you, Dev! Found it because the RBDDimmer library had reserved all six of the interrupt vectors on the Arduino MEGA?? Can't confirm at this point but everything now compiles with Dimmer. Oh, also, RBDDimmer's .setPower() function doesn't actually set power but firing_angle, so 100 is 90degrees (full power cycle), 0 is 0degrees, and 50 is 45degrees. Those are the only values that .setPower() is accurate for. If you want correct value everywheree, can map firing_angle like this:
int angle_as_percent = 10000*acos(1-2*(power/100))/100/3.141592; //linearizing such that input from 0% to 100% linearly corresponds to output power 0% to 100%
Ah, wait...that's for 50Hz. Mmm yeah I heard this library assumes a perfect 60Hz? I've got 50, so I will have to deal with that sooner than I'd like, I bet...still good though.
i have also an (solar powered) immersion heater and i want to drive it by a half /full-wave paket control/ Schwingungspaketsteuerung .
It would be great if it could be integrated!
I am using a ZCD circuit controlling a TRIAC. Now I am using Dimmer library for this purpose. It works fine with ATMega 328 but whenever I try to upload the code in ATMega 128 using Arduino IDE this error pops up:
`Arduino: 1.8.4 (Windows 10), Board: "ATmega128, 2.7v, Disabled (default), 16 MHz external"
C:\Program Files (x86)\Arduino\libraries\Dimmer-master\src\Dimmer.cpp: In member function 'void Dimmer::begin(uint8_t, bool)':
C:\Program Files (x86)\Arduino\libraries\Dimmer-master\src\Dimmer.cpp:15:20: error: 'TCCR2A' was not declared in this scope
#define _TCCRxA(X) TCCR ## X ## A
^
C:\Program Files (x86)\Arduino\libraries\Dimmer-master\src\Dimmer.cpp:16:19: note: in expansion of macro '_TCCRxA'
#define TCCRxA(X) _TCCRxA(X)
^
C:\Program Files (x86)\Arduino\libraries\Dimmer-master\src\Dimmer.cpp:157:5: note: in expansion of macro 'TCCRxA'
TCCRxA(DIMMER_TIMER) = TCCRxA_VALUE; // Timer config byte A
^
C:\Program Files (x86)\Arduino\libraries\Dimmer-master\src\Dimmer.cpp:17:20: error: 'TCCR2B' was not declared in this scope
#define _TCCRxB(X) TCCR ## X ## B
^
C:\Program Files (x86)\Arduino\libraries\Dimmer-master\src\Dimmer.cpp:18:19: note: in expansion of macro '_TCCRxB'
#define TCCRxB(X) _TCCRxB(X)
^
C:\Program Files (x86)\Arduino\libraries\Dimmer-master\src\Dimmer.cpp:158:5: note: in expansion of macro 'TCCRxB'
TCCRxB(DIMMER_TIMER) = TCCRxB_VALUE; // Timer config byte B
^
C:\Program Files (x86)\Arduino\libraries\Dimmer-master\src\Dimmer.cpp:19:20: error: 'TIMSK2' was not declared in this scope
#define _TIMSKx(X) TIMSK ## X
^
C:\Program Files (x86)\Arduino\libraries\Dimmer-master\src\Dimmer.cpp:20:19: note: in expansion of macro '_TIMSKx'
#define TIMSKx(X) _TIMSKx(X)
^
C:\Program Files (x86)\Arduino\libraries\Dimmer-master\src\Dimmer.cpp:159:5: note: in expansion of macro 'TIMSKx'
TIMSKx(DIMMER_TIMER) = 0x02; // Timer Compare Match Interrupt Enable
^
C:\Program Files (x86)\Arduino\libraries\Dimmer-master\src\Dimmer.cpp:21:19: error: 'OCR2A' was not declared in this scope
#define _OCRxA(X) OCR ## X ## A
^
C:\Program Files (x86)\Arduino\libraries\Dimmer-master\src\Dimmer.cpp:22:18: note: in expansion of macro '_OCRxA'
#define OCRxA(X) _OCRxA(X)
^
C:\Program Files (x86)\Arduino\libraries\Dimmer-master\src\Dimmer.cpp:160:5: note: in expansion of macro 'OCRxA'
OCRxA(DIMMER_TIMER) = 100 * 60 / acFreq - 1; // Compare value (frequency adjusted)
^
exit status 1
Error compiling for board ATmega128.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.`
Any idea what is the issue ?
Hi,
Can I replace INT0 with PCINT, as I am using Leonardo and have connected RTC module along with TXD1 and RXD1?
Kindly oblige
Hello, sorry for my bad English. I'm using Robotdyn's dimmer module.
I use it with the Dimmer.h library. When I extend the power cables of the lamps, the dimmer feature disappears, it just turns on and off. I think the library is set to 60hz, I need to set it to 50hz. Can someone help? I think it will be fixed at 50hz. Can you upload or send it set to 50hz? Cable length dimmer feature does not work.
Dimmer dimmers[] = {
Dimmer(3, DIMMER_RAMP, RAMP_TIME, POWER_HZ),
Dimmer(4, DIMMER_RAMP, RAMP_TIME, POWER_HZ),
Dimmer(5, DIMMER_RAMP, RAMP_TIME, POWER_HZ),
Dimmer(6, DIMMER_RAMP, RAMP_TIME, POWER_HZ),
Dimmer(7, DIMMER_RAMP, RAMP_TIME, POWER_HZ),
Dimmer(8, DIMMER_RAMP, RAMP_TIME, POWER_HZ),
Dimmer(9, DIMMER_RAMP, RAMP_TIME, POWER_HZ),
Dimmer(10,DIMMER_RAMP, RAMP_TIME, POWER_HZ),
Dimmer(11,DIMMER_RAMP, RAMP_TIME, POWER_HZ)
};
void handleDimming (byte dimmerNumber, byte value) {
if (value == 0) dimmers[dimmerNumber].off(); //This works as intended
else {
//dimmers[dimmerNumber].set(value, true); <-- This one always applies to dimmers[0] regardless of dimmerNumber
dimmers[dimmerNumber].on(); //This works as intended
dimmers[dimmerNumber].set(value); //This works as intended
}
}
Hi, when i try to use the class DimmerControl it´s doesn´t working. And i veryfied that this class is missing on the lib dimmer.h. Could you help me in that?
Could you please share steps to calculate effective power applied to a resistive load over time?
Since local power is 50Hz instead of 60 used in the code:
// Time table to set triacs (50us tick)
// This is the number of ticks after zero crossing that we should wait before activating the
// triac, where the array index is the applied power from 1 to 100, minus one. This array is
// calculated based on the equation of the effective power applied to a resistive load over
// time, assuming a 60HZ sinusoidal wave.
¡Hi!
I just tried to use this library on my board with an ATMEGA128 but did not work. I got the next error:
JELdimmer2\src\JELdimmer2.cpp:7:20: error: 'TCCR2A' was not declared in this scope
#define _TCCRxA(X) TCCR ## X ## A
I was watching some forums about this problem but nobody had the answer. The library can not support this chip?
If this is the problem, could you add support for this chip, please?
Boa tarde:
Antes de mais nada gostaríamos de parabenizar sobre o excelente trabalho em criar a bilbioteca Dimmer.h, já que ha bastante tempo estava buscando algum recurso viável e de fácil utilização para a plataforma Arduino.
Utilizei a sua bilbioteca em alguns scketchs, e notei uma coisa:
No modo NORMAL_MODE, consegui utilizar todos os 10 dimmers e ainda assim mantive incólume a comunicação serial. Porém, ao tentar usar mais de dois dimmers no modo RAMP_MODE, em conjunto com a comunicação serial nativa do arduino, a mesma simplesmente perde a funcionalidade. Até a habilitação do segundo dimmer não tive nenhum problema, mas a partir do terceiro dimmer ele não mais responde. Sabe se haveria algum remédio para este efeito indesejável? Vejo que vocês usaram o TIMER2 na bilbioteca, e até aonde eu sei o uso dele não é usado na USART que controla a serial.
Já percebi que, mesmo antes de usar a bilbioteca de vocês, o uso da serial fica um pouco limitado, independente se usar-se o TIMER1, TIMER2 ou sem o uso do timer ( sem o uso dos timers é bem pior porque a temporização é feita dentro da interrupção gerada pelo sensor zerocross, e sobra muito pouco tempo para o microcontroller executar todas as outras tarefas), tinha esperança que esta sua bilbioteca não tivesse esta mesma limitação (embora ela seja superior aos outros métodos usados até hoje por mim).
Sei que vocês não tem obrigação de darem suporte ao uso dessa biblioteca, mas se puder dar uma dica de como contornar isso, agradeço muito.
Helio
Hello!
Can you help me? I can't make this library work with arduino leonardo and RobotDyn dimmer module. processor ATmega32U4-AU. DIMMER_ZERO_CROSS_PIN - 7.
For larger production runs, Atmega MCU's are often overkill for this application, and so a smaller MCU such as the ATtiny85 would be better suited.
Reserving two pins for communication with external components, three triacs can still be controlled, making this an extremely efficient solution.
Unless existing work on this exists, I'll be forking this repo in order to provide the applicable configuration needed to make this work.
Hi, I have a espNodemcu, can I use this library? Because I get the following error:
"fatal error: util/atomic.h: No such file or directory"
Thanks you.
I want to adapt LUT for 50Hz mains, but can't figure out exactly what equation you were using for it:
Line 48 in da15bc7
acos(1-(2*(level/100)))
to calculate angle and then convert it to delay in microseconds, but it seems to ramp up more gradually, though the overall shape of the curve is the same.Hi Luis,
can you add support for atmega64 chip?
I'm using https://github.com/MCUdude/MegaCore for chip support in Arduino IDE and all works but your library use specific timer registers which not exists for atmega64.
Here is what i see in compile window
/home/rodchyn/sketchbook/libraries/Dimmer/src/Dimmer.cpp: In member function 'void Dimmer::begin(uint8_t, bool)':
/home/rodchyn/sketchbook/libraries/Dimmer/src/Dimmer.cpp:15:20: error: 'TCCR2A' was not declared in this scope
#define _TCCRxA(X) TCCR ## X ## A
^
/home/rodchyn/sketchbook/libraries/Dimmer/src/Dimmer.cpp:16:19: note: in expansion of macro '_TCCRxA'
#define TCCRxA(X) _TCCRxA(X)
^
/home/rodchyn/sketchbook/libraries/Dimmer/src/Dimmer.cpp:157:5: note: in expansion of macro 'TCCRxA'
TCCRxA(DIMMER_TIMER) = TCCRxA_VALUE; // Timer config byte A
^
/home/rodchyn/sketchbook/libraries/Dimmer/src/Dimmer.cpp:17:20: error: 'TCCR2B' was not declared in this scope
#define _TCCRxB(X) TCCR ## X ## B
^
/home/rodchyn/sketchbook/libraries/Dimmer/src/Dimmer.cpp:18:19: note: in expansion of macro '_TCCRxB'
#define TCCRxB(X) _TCCRxB(X)
^
/home/rodchyn/sketchbook/libraries/Dimmer/src/Dimmer.cpp:158:5: note: in expansion of macro 'TCCRxB'
TCCRxB(DIMMER_TIMER) = TCCRxB_VALUE; // Timer config byte B
^
/home/rodchyn/sketchbook/libraries/Dimmer/src/Dimmer.cpp:19:20: error: 'TIMSK2' was not declared in this scope
#define _TIMSKx(X) TIMSK ## X
^
/home/rodchyn/sketchbook/libraries/Dimmer/src/Dimmer.cpp:20:19: note: in expansion of macro '_TIMSKx'
#define TIMSKx(X) _TIMSKx(X)
^
/home/rodchyn/sketchbook/libraries/Dimmer/src/Dimmer.cpp:159:5: note: in expansion of macro 'TIMSKx'
TIMSKx(DIMMER_TIMER) = 0x02; // Timer Compare Match Interrupt Enable
^
/home/rodchyn/sketchbook/libraries/Dimmer/src/Dimmer.cpp:21:19: error: 'OCR2A' was not declared in this scope
#define _OCRxA(X) OCR ## X ## A
^
/home/rodchyn/sketchbook/libraries/Dimmer/src/Dimmer.cpp:22:18: note: in expansion of macro '_OCRxA'
#define OCRxA(X) _OCRxA(X)
^
/home/rodchyn/sketchbook/libraries/Dimmer/src/Dimmer.cpp:160:5: note: in expansion of macro 'OCRxA'
OCRxA(DIMMER_TIMER) = 100 * 60 / acFreq - 1; // Compare value (frequency adjusted)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.