Phil's Dimmer

I feel your grief .I had purchased a micro mini and was a pita to get it working.

I had thought you were working with the ESP ?
The wemos 8266 or an Esp32 Trump all need for arduino boards unless they are in addition to.

Just to try and understand...

Do the Wemos8266 and Esp32 use completely unrelated processors from the 'classic' Arduino boards, but can be programmed using the Arduino IDE and programming language? This would imply to me that direct register access code from the Atmega processors would not work for those boards. This would mean that direct port reads and writes as well as user-written interrupt coding (as coded for the Atmega) would need to be rewritten. Or am I missing something here?
 
Also when you installed the Arduino IDE a path was created that you should be familiar with =>

C:\Users\YOUR USER NAME\Documents\Arduino

The library & hardware folders are located here .

Once you install the Esp8266 boards or Esp32 from boards manager ,you will find pertinent folders from espressif get installed in the hardware folder.
 
Looks as though a big part of what I've been working would not be of much use to you, it's fairly heavily focused on the Atmega architecture and the IO port structure, timer and interrupt low-level hardware designs. But I suppose that I should look more carefully to see if there is more similarity in the register implementations than I'm assuming.
 
Hi Phil, whilst the ATMega’s and the ESP can be programmed through the Adruino IDE they are very different when you come to writing to registers. I’ve not seen any code at that level that is interchangeable between the two at that level.

The ATMega’s are 8 bit processors and you can write directly to the output register:
PORTD = B0000 1111; would set the output pins [7:4] LOW and [3:0] HIGH.

The ESP8266 is a 16 bit processor and you can’t write directly to the output register. There are two intermediate registers GPIO_OUT_W1TS (Write 1 To Set) and GPIO_OUT_W1TC (Write 1 To Clear).
To output the same as above needs two writes:

WRITE_PERI_REG(PERIPHS_GPIO_BASEADDR + GPIO_OUT_W1TC_ADDRESS, 0xFFF0); or 0xFFFF
This sets [15:4] or [15:0] in the output register to zero and the associated pins LOW.

WRITE_PERI_REG(PERIPHS_GPIO_BASEADDR + GPIO_OUT_W1TS_ADDRESS, 0x000F);
This sets [3:0] in the output register to one and the associated pins HIGH.

What will work for both through the Arduino IDE but is to slow for what you need:
digitalWrite(D7,LOW); through to digitalWrite(D4,LOW);
digitalWrite(D3,HIGH); through to digitalWrite(D0,HIGH);
 
Thanks. That's quite helpful, it might take a lot less modification than I feared. Something to think about for now, especially considering how far down the rabbit hole of handling different processors do I want to go.

--

Phil

Hi Phil, whilst the ATMega’s and the ESP can be programmed through the Adruino IDE they are very different when you come to writing to registers. I’ve not seen any code at that level that is interchangeable between the two at that level.

The ATMega’s are 8 bit processors and you can write directly to the output register:
PORTD = B0000 1111; would set the output pins [7:4] LOW and [3:0] HIGH.

The ESP8266 is a 16 bit processor and you can’t write directly to the output register. There are two intermediate registers GPIO_OUT_W1TS (Write 1 To Set) and GPIO_OUT_W1TC (Write 1 To Clear).
To output the same as above needs two writes:

WRITE_PERI_REG(PERIPHS_GPIO_BASEADDR + GPIO_OUT_W1TC_ADDRESS, 0xFFF0); or 0xFFFF
This sets [15:4] or [15:0] in the output register to zero and the associated pins LOW.

WRITE_PERI_REG(PERIPHS_GPIO_BASEADDR + GPIO_OUT_W1TS_ADDRESS, 0x000F);
This sets [3:0] in the output register to one and the associated pins HIGH.

What will work for both through the Arduino IDE but is to slow for what you need:
digitalWrite(D7,LOW); through to digitalWrite(D4,LOW);
digitalWrite(D3,HIGH); through to digitalWrite(D0,HIGH);
 
Hi Phil, if you want to blink an LED at 1Hz across ten different processors the Arduino IDE is brilliant but slow. Not a problem with faster processors (ESP8266 at 160MHz) but the ATMegas at 16MHz as you know need all the tricks in the book.

Correction: Sorry the ESP8266 is a 32 bit processor not 16 at stated above.

I ment to link a table of registers with the above post: https://esp8266.ru/esp8266-gpio-register/
 
Last edited:
This is getting close to ending up on the back burner. There doesn't seem to be much call for high channel-count AC dimmers. I considered switching to using Wemos for a small number of channels until I noticed it's power requirements. I will continue with certain aspects though, including playing with those floods and with an isolated interface to one or another Arduino oscilloscope design (for observing AC current waveforms without the expense and measurement distortions introduced by isolation transformers). And Wemos controllers are not totally off the table yet.
 
This is getting close to ending up on the back burner. There doesn't seem to be much call for high channel-count AC dimmers. I considered switching to using Wemos for a small number of channels until I noticed it's power requirements. I will continue with certain aspects though, including playing with those floods and with an isolated interface to one or another Arduino oscilloscope design (for observing AC current waveforms without the expense and measurement distortions introduced by isolation transformers). And Wemos controllers are not totally off the table yet.

I didn't think more than a handful of AC was good to do wirelessly with these micros. I like your idea for arduino scope. The Wemos is what I have to stick with as there is no analogWrite for the Esp32 . I hope you consider the Wemos seriously.
 
There doesn't seem to be much call for high channel-count AC dimmers.


After TWeist and I came out with the 96-channel Renzilla controller, I can confirm this statement.

On the other hand, Renzilla was the only controller on the planet that could control AC lights, dumb RGB lights, LEDs, floods, pixels and servos with both Renard and DMX signals feeding the board simultaneously, either wired or wireless.
 
Has anybody used the analogRead function on the Wemos? There are some hints out on the web that there are some difficulties with using the ADC, as (possibly) it's shared with the wifi module for detecting signal strength, and that using the ADC for general purpose use could result in interference between the Wifi and the general ADC usage.
 
I have used analogRead to control a motor's speed .
I seem to recall that I could not use the analogRead function for more than 1 input though .

Code:
    // Motor Control
  int speed = 0;
  int Redsensor = analogRead(14);
 
I have used analogRead to control a motor's speed .
I seem to recall that I could not use the analogRead function for more than 1 input though .

Code:
    // Motor Control
  int speed = 0;
  int Redsensor = analogRead(14);

As far as I can tell by looking at specs and pinout diagrams for the Wemos, there's only one pin that can be used for analog (ADC) input. But does using that pin for analog input interfere with the WiFi channel, or vice-versa? That's not so clear from the forum comments at various sites.
 
Last edited:
Hi Phil, it has been reported that the ADC can return very slightly inconsistent results when measuring a fixed constant voltage such as a cell with no load. Some clever people determined that the modem when powered up causes a slight internal voltage drop which affects the result of the ADC. Powering off the modem is not much use as you are unable to transmit or receive data, the other option is to disable modem sleep such that the modem is always powered, not much fun if your device is battery powered but this gives stable ADC results.

This line in setup does the trick.

Code:
wifi_set_sleep_type(NONE_SLEEP_T);
 
I would suppose that the drop could be determined by measuring the voltage of some fixed reference (external if there isn't an internal one) and a correction applied as determined by the modem state. Is that the only Wemos-intrinsic interaction between the WiFi module and using the ADC to measure external voltages, though?
 
I like your idea for arduino scope.

There are a ton of Arduino Oscilloscope projects that can be found on the internet. I haven't gone through all of them (or even a small fraction of them), but they mostly appear to use one or more of the analog input pins of various ATmega parts for visualizing 0-5V waveforms with little, or no up-front analog interface parts. I'm thinking about creating a (relatively) small PCB with opto-isolator(s) and op-amp circuitry to safely allow safe visualization of AC voltage and current waveforms.

My preference would be to use a small PIC (such as the PIC12F1572 or similar) incorporating ADC modules and sending serial digital data to an Arduino through 4N35 optoisolators. The use of a PIC doesn't fit within the Arduino culture, though. Another approach would be to do the same thing with a conventional serial ADC chip (such as the MCP3001) and several 4N35-type opto-isolators to send digital data back to the Arduino. This would work, although I'd like to be a bit different, and go for a totally analog approach using an IL-300 opto-isolator and a pair fo opto-isolators. Here the analog signal is fairly faithfully passed through the IL-300, and the design would use the ADC in the Arduino (or Wemos) to digitize the signal. This approach would be a bit more expensive (the IL-300 pricing starts at $4.55/each), but this doesn't matter too much when most of the cost would be in the PCB (at low quantities), the 5V DC-DC convertor and connectors.
 
There are a ton of Arduino Oscilloscope projects that can be found on the internet. I haven't gone through all of them (or even a small fraction of them), but they mostly appear to use one or more of the analog input pins of various ATmega parts for visualizing 0-5V waveforms with little, or no up-front analog interface parts. I'm thinking about creating a (relatively) small PCB with opto-isolator(s) and op-amp circuitry to safely allow safe visualization of AC voltage and current waveforms.

My preference would be to use a small PIC (such as the PIC12F1572 or similar) incorporating ADC modules and sending serial digital data to an Arduino through 4N35 optoisolators. The use of a PIC doesn't fit within the Arduino culture, though. Another approach would be to do the same thing with a conventional serial ADC chip (such as the MCP3001) and several 4N35-type opto-isolators to send digital data back to the Arduino. This would work, although I'd like to be a bit different, and go for a totally analog approach using an IL-300 opto-isolator and a pair fo opto-isolators. Here the analog signal is fairly faithfully passed through the IL-300, and the design would use the ADC in the Arduino (or Wemos) to digitize the signal. This approach would be a bit more expensive (the IL-300 pricing starts at $4.55/each), but this doesn't matter too much when most of the cost would be in the PCB (at low quantities), the 5V DC-DC convertor and connectors.

Hey this sounds great Phil .

Will you design this through the likes of Jlpcb as your project and market them orderable directly through the pcb site ?
I thought I had seen where board designers could sell their products and users could order them directly .
 
Any particular suggestions for sources for Wemos? There are a lot of listings on Amazon, mostly oddly-named companies, probably clones, and I'm a bit hesitant to randomly select one.
 
Back
Top