PWM and SNTP issues

scargill
Posts: 70
Joined: Sun Nov 02, 2014 8:09 pm

PWM and SNTP issues

Postby scargill » Sat Jun 20, 2015 2:16 pm

So I have a number of questions:

1. The new PWM module.
(a) It does not appear possible to achieve 100% pulse width (100% on). I cannot get past around 90% - I've tried frequencies of 1024 and 500 - makes no difference.
(b) There does not appear to be any function to turn off the PWM - which is a problem as once activated, things like controlling fast serial LEDs on another pin become impossible because of the constant interrupts affecting the timing. Can we please have a stop function so that the PWM can be turned on and off. As the source is not available for this we cannot change this ourselves.

2. The SNTP module.
(a) The simple example in the SDK manual works - on second reading, it picks up the time (first time it just shows a count of 0 and the date 1970). When I add the timezone offset however, it never gets the time and remains at 1970. Can we have a complete example including timezone setting.
(b) Are there plans to add a function to ensure daylight savings (summer/winter time) are taken into account. This is important for an automated installation.

Blackfarmer
Posts: 7
Joined: Tue May 19, 2015 3:43 am

Re: PWM and SNTP issues

Postby Blackfarmer » Sat Jun 20, 2015 6:05 pm

Hi,

(b) Are there plans to add a function to ensure daylight savings (summer/winter time) are taken into account. This is important for an automated installation.


But here it must be considererd, that
1) this should be an option and it must be able to dis-/enabled.
2) changing between the summer and winter time country dependent. Not every country changes there time on the same day.

Best regards
Blackfarmer

costaud
Posts: 138
Joined: Fri Oct 24, 2014 7:40 pm

Re: PWM and SNTP issues

Postby costaud » Tue Jun 23, 2015 4:19 pm

1. The new PWM module.
(a) It does not appear possible to achieve 100% pulse width (100% on). I cannot get past around 90% - I've tried frequencies of 1024 and 500 - makes no difference.
(b) There does not appear to be any function to turn off the PWM - which is a problem as once activated, things like controlling fast serial LEDs on another pin become impossible because of the constant interrupts affecting the timing. Can we please have a stop function so that the PWM can be turned on and off. As the source is not available for this we cannot change this ourselves.


About the PWM issue:
1.Dut to the Algorithm , we can provide up to 90 duty at period 1000us(1KHz)
2.Make sure you choosed 80Mhz SPI clock frequency when downloading the firmware.
3.The param freq has been replaced by period, which ranges from 1000us to 10000us.
4.Set the duty of each PWM channle to ZERO , so that the timer would stop and PWM stops.

scargill
Posts: 70
Joined: Sun Nov 02, 2014 8:09 pm

Re: PWM and SNTP issues

Postby scargill » Tue Jun 23, 2015 5:56 pm

Nice in theory - but if I have a background (callback) job updating a serial LED display - and turn on the PWM - then the serial display output all goes to hell... If I then send 3 zeros to the PWM - the serial display stays messed up - suggesting that something is still happening with the PWM.

scargill
Posts: 70
Joined: Sun Nov 02, 2014 8:09 pm

Re: PWM and SNTP issues

Postby scargill » Tue Jun 23, 2015 8:01 pm

Hi

1. Is there any chance this 90% will improve? Could be worth a bodge to set to 100% manually at full duty.
2. 80Mhz is default.
3. Understand.
4. No. Setting to 0,0,0 is definitely NOT the same has having never used the PWM. I have routines to run serial LEDs - they disable interrupts briefly when narrow pulses are sent out to the LEDs - then re-enable them - I can publish the code.... If I reboot the board - my serial LED works. I then turn that off and enable PWM..... when done with PWM I set the period to 0,0,0 and the serial LEDS will NOT start working properly after that. This is 100% repeatable - something has changed.

Here is the code used to handle serial LEDs - it works perfectly until PWM is introduced. I don't expect it to work while PWM is running but I WOULD expect it to work when PWM is set to 0,0,0.

void SEND_WS_12_0() {
SET_PERI_REG_MASK(PERIPHS_GPIO_BASEADDR, wsBitMask);
__asm__ __volatile__ ("nop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop");
CLEAR_PERI_REG_MASK(PERIPHS_GPIO_BASEADDR, wsBitMask);
__asm__ __volatile__ ("nop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop");
}

void SEND_WS_12_1() {
SET_PERI_REG_MASK(PERIPHS_GPIO_BASEADDR, wsBitMask);
__asm__ __volatile__ ("nop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop");
__asm__ __volatile__ ("nop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop");
CLEAR_PERI_REG_MASK(PERIPHS_GPIO_BASEADDR, wsBitMask);
}

void ICACHE_FLASH_ATTR WS2812OutBuffer(uint8_t * buffer, uint16_t length,uint16_t repetition)
{
uint16_t i;
ets_intr_lock();

for (i = 0; i < 2; i++)
WRITE_PERI_REG(PERIPHS_GPIO_BASEADDR + 8, wsBitMask);
while (repetition--)
{
for (i = 0; i < length; i++)
{
uint8_t mask = 0x80;
uint8_t byte = buffer[i];
while (mask)
{
(byte & mask) ? SEND_WS_12_1() : SEND_WS_12_0();
mask >>= 1;
}
}
}
ets_intr_unlock();
}







costaud wrote:
1. The new PWM module.
(a) It does not appear possible to achieve 100% pulse width (100% on). I cannot get past around 90% - I've tried frequencies of 1024 and 500 - makes no difference.
(b) There does not appear to be any function to turn off the PWM - which is a problem as once activated, things like controlling fast serial LEDs on another pin become impossible because of the constant interrupts affecting the timing. Can we please have a stop function so that the PWM can be turned on and off. As the source is not available for this we cannot change this ourselves.


About the PWM issue:
1.Dut to the Algorithm , we can provide up to 90 duty at period 1000us(1KHz)
2.Make sure you choosed 80Mhz SPI clock frequency when downloading the firmware.
3.The param freq has been replaced by period, which ranges from 1000us to 10000us.
4.Set the duty of each PWM channle to ZERO , so that the timer would stop and PWM stops.

scargill
Posts: 70
Joined: Sun Nov 02, 2014 8:09 pm

Re: PWM and SNTP issues

Postby scargill » Wed Jun 24, 2015 2:18 am

I note you say to use 80Mhz SPI clock speed. It appears from the startup info that I'm using 40Mhz SPI speed. No idea how to change it..

???

costaud wrote:
1. The new PWM module.
(a) It does not appear possible to achieve 100% pulse width (100% on). I cannot get past around 90% - I've tried frequencies of 1024 and 500 - makes no difference.
(b) There does not appear to be any function to turn off the PWM - which is a problem as once activated, things like controlling fast serial LEDs on another pin become impossible because of the constant interrupts affecting the timing. Can we please have a stop function so that the PWM can be turned on and off. As the source is not available for this we cannot change this ourselves.


About the PWM issue:
1.Dut to the Algorithm , we can provide up to 90 duty at period 1000us(1KHz)
2.Make sure you choosed 80Mhz SPI clock frequency when downloading the firmware.
3.The param freq has been replaced by period, which ranges from 1000us to 10000us.
4.Set the duty of each PWM channle to ZERO , so that the timer would stop and PWM stops.

scargill
Posts: 70
Joined: Sun Nov 02, 2014 8:09 pm

Re: PWM and SNTP issues

Postby scargill » Wed Jun 24, 2015 2:46 am

And for today's HIGHLY embarrassing climb-down...

FORGET the GPIO16 issue - nothing to do with the ESP-12s AT ALL.... my friendly PCB designer thoughtfully shorted GPIO16 to RESET to aid with SLEEP !!!

I'll just go away and crawl into a corner...

scargill
Posts: 70
Joined: Sun Nov 02, 2014 8:09 pm

Re: PWM and SNTP issues

Postby scargill » Wed Jun 24, 2015 3:31 pm

I've adjusted my bootloader to ensure 80Mhz SPI speed.
I've adjusted the period to 1000us.
I accept current limit of 90% or thereabouts duty cycle.

HOWEVER... given code that runs a callback to update a serial LED... once you start PWM, even then setting PWM to 0,0,0 something has CHANGED which stops the high speed serial LED from operating properly.

Here is the code for the Serial LED, called at regular intervals in a callback function, you can get serial LEDS to respond utterly reliably, but NOT once the PWM has been started. Hence it would seem we still need a proper PWM.STOP function.



void SEND_WS_12_0() {
SET_PERI_REG_MASK(PERIPHS_GPIO_BASEADDR, wsBitMask);
__asm__ __volatile__ ("nop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop");
CLEAR_PERI_REG_MASK(PERIPHS_GPIO_BASEADDR, wsBitMask);
__asm__ __volatile__ ("nop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop");
}

void SEND_WS_12_1() {
SET_PERI_REG_MASK(PERIPHS_GPIO_BASEADDR, wsBitMask);
__asm__ __volatile__ ("nop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop");
__asm__ __volatile__ ("nop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop""\n\tnop");
CLEAR_PERI_REG_MASK(PERIPHS_GPIO_BASEADDR, wsBitMask);
}

void ICACHE_FLASH_ATTR WS2812OutBuffer(uint8_t * buffer, uint16_t length,uint16_t repetition)
{
uint16_t i;
ets_intr_lock();

for (i = 0; i < 2; i++)
WRITE_PERI_REG(PERIPHS_GPIO_BASEADDR + 8, wsBitMask);
while (repetition--)
{
for (i = 0; i < length; i++)
{
uint8_t mask = 0x80;
uint8_t byte = buffer[i];
while (mask)
{
(byte & mask) ? SEND_WS_12_1() : SEND_WS_12_0();
mask >>= 1;
}
}
}
ets_intr_unlock();
}



costaud wrote:
1. The new PWM module.
(a) It does not appear possible to achieve 100% pulse width (100% on). I cannot get past around 90% - I've tried frequencies of 1024 and 500 - makes no difference.
(b) There does not appear to be any function to turn off the PWM - which is a problem as once activated, things like controlling fast serial LEDs on another pin become impossible because of the constant interrupts affecting the timing. Can we please have a stop function so that the PWM can be turned on and off. As the source is not available for this we cannot change this ourselves.


About the PWM issue:
1.Dut to the Algorithm , we can provide up to 90 duty at period 1000us(1KHz)
2.Make sure you choosed 80Mhz SPI clock frequency when downloading the firmware.
3.The param freq has been replaced by period, which ranges from 1000us to 10000us.
4.Set the duty of each PWM channle to ZERO , so that the timer would stop and PWM stops.

tprochazka
Posts: 3
Joined: Mon Jun 15, 2015 4:22 am

Re: PWM and SNTP issues

Postby tprochazka » Sun Nov 01, 2015 3:33 am

WIth the limitation of the maximum duty cycle to the 90% is impossible to controll RGB led with common anode where I need to 100% HIGH to turn of the LED. Why is your algorithm limited to 90%. It is possible to invert output for this purposeses? There will be not problem with this limitation if will be possible invert HIGH and LOW level for the PWM output.

Who is online

Users browsing this forum: No registered users and 83 guests