Giter Club home page Giter Club logo

dimmer's People

Contributors

alexsartin avatar bcelary avatar lfchavier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dimmer's Issues

Fading on/off

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?

Zero Cross Pin??

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.

Add ArduinoDocs

  • Make sure to use new folder structure with "extras/docs" for ArduinoDocs files and "src" folder for .h/.cpp
    • Use Nanoshield_LCD as an example
  • Update README
    • Convert README.md (Markdown) to README.rst (ResStructuredText)
    • Use README from Nanoshield_LoadCell as an example.
  • Add library.properties

Dimmer.h issues with ATmega 128

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 ?

Can INT0 replaced with PCINT?

Hi,

Can I replace INT0 with PCINT, as I am using Leonardo and have connected RTC module along with TXD1 and RXD1?
Kindly oblige

50hz problem help please

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.

void set(uint8_t value, bool on) always sets the first dimmer, not the one it called on.

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
  }
}

Could you please share steps to calculate effective power applied to a resistive load over time?

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.

Support ATMEGA128

¡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?

some trouble to use more than 3 dimmers in RAMP MODE.

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

Support for ATtiny85

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.

Issues with ESP8266?

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.

Add lookup table for 50Hz

I want to adapt LUT for 50Hz mains, but can't figure out exactly what equation you were using for it:

static const uint8_t powerToTicks[] PROGMEM = {

The one I have gives similar results but not quiet the same. I am using 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.

Atmega64 support

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.