Flickering 7 segment LEDs using core 0 for scanning

twiereng
Posts: 5
Joined: Thu Jan 10, 2019 8:07 pm

Flickering 7 segment LEDs using core 0 for scanning

Postby twiereng » Fri Mar 08, 2019 1:50 pm

I have a working digital clock program using 7 segment LEDs.

Both cores are used, core 0, set at priority 1, simply scans the LEDs by using 8 GPIO pins to set the 7 segments and then enabling that digit.

Core 1 does everything else.

1. Checks if WiFI is still connected.
2. Checks the RTC to see if a second has passed and then updates the time settings.
3. Reads time and date from Internet (from NTP server).
4. Reads local temperature and humidity from BME280.
5. Reads weather information from Internet.
6. Displays weather information on 4 line LCD.

Everything works except I get ghost segments flickering on randomly, as well as some full digit flicker. In addition I get task watchdog triggered every few seconds, although this does not seem to effect anything. Tight loop in core 0 probably is setting this off, but I need speed there as 8 digits need to be scanned at least every 30 milliseconds.

I suspect the tight loop in core 0 gets interrupted by the wireless radio, which I understand runs on core 0, and this is causing the flickering.

If I swap the tasks, core 0 doing what core 1 did, etc., I have problems with the LCD display. RTC and BME280 run on I2C as well as the LCD. Running these on core 0 causes LCD to malfunction.

Any suggestions?

Thank you,
Theron Wierenga

ESP_Sprite
Posts: 9757
Joined: Thu Nov 26, 2015 4:08 am

Re: Flickering 7 segment LEDs using core 0 for scanning

Postby ESP_Sprite » Fri Mar 08, 2019 8:14 pm

Look at the priorities of your tasks. You probably want the task that does your LEDs to have a high priority. You can also use the I2S peripheral in parallel ('LCD') mode to more-or-less automatically scan your LEDs without using any CPU time.

twiereng
Posts: 5
Joined: Thu Jan 10, 2019 8:07 pm

Re: Flickering 7 segment LEDs using core 0 for scanning

Postby twiereng » Fri Mar 08, 2019 9:27 pm

Changed priority on core 0 from 1 to 0. Flickering remains, perhaps a little worse. Not sure how to do I2S peripheral in parallel ('LCD') mode to more-or-less automatically scan your LEDs without using any CPU time. Can you point me to an explanation. Attached the schematic of my circuit so you can see how I scan.

Thanks, Theron
Attachments
Figure 1.jpg
Figure 1.jpg (633.26 KiB) Viewed 5334 times

mikemoy
Posts: 627
Joined: Fri Jan 12, 2018 9:10 pm

Re: Flickering 7 segment LEDs using core 0 for scanning

Postby mikemoy » Sat Mar 09, 2019 5:04 am

Would you be able to use 2 of these side to side? If so, it would eliminate your timing issues. just use I2C to drive them.
https://www.adafruit.com/product/3107

ESP_Sprite
Posts: 9757
Joined: Thu Nov 26, 2015 4:08 am

Re: Flickering 7 segment LEDs using core 0 for scanning

Postby ESP_Sprite » Mon Mar 11, 2019 9:15 am

Changing the tasks priority from 1 to 0 won't do much, as the tasks get more priority with a *higher* priority number.

Who is online

Users browsing this forum: Baidu [Spider] and 182 guests