execute on power up, not getting the advertised results?

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
uxhamby
Posts: 34
Joined: Thu Nov 14, 2019 9:47 pm

execute on power up, not getting the advertised results?

Post by uxhamby » Wed Apr 15, 2020 4:07 pm

Hi,

Similar to this recent post, I have written a bit of code which I now want to execute on power up but I am not getting the advertised results. I am using rshell to upload my code to a generic ESP32-S board from Ebay.

Code: Select all

from machine import Pin, SPI
import time
from NuovoLedControl import Nuovo7Segment
#Call constructor with DIN , CS , CLK pin. For initial setup pin
segment = Nuovo7Segment(Pin(2), Pin(5, Pin.OUT), Pin(4))
segment.setBrightness(4)
segment.clearDisplay()
dly = 500

for y in range(0, 8):
    segment.setDigit(y, y, True)
time.sleep_ms(2 * dly)




while True:
    for y in range(8, 0, -1):
        segment.setRow(y-1,0b00000000)
        time.sleep_ms(dly)
    time.sleep_ms(dly)

    for y in range(0, 8):
        segment.setRow(y,0b00000001)
    time.sleep_ms(dly)

    for y in range(0, 8):
        segment.setRow(y,0b00001000)
    time.sleep_ms(dly)    

    for y in range(0, 8):
        segment.setRow(y,0b01000000)
    time.sleep_ms(dly)

    x=7
    for y in range(0, 8):
        segment.setDigit(y, x, True)
        x-=1
    time.sleep_ms(5 * dly)

    x=7
    for y in range(0, 8):
        segment.setDigit(y, x, False)
        time.sleep_ms(dly)
        x-=1
#    time.sleep_ms(5 * dly)
My code is to exercise / test max7219 display modules. It works as I would expect when invoked at the repl command line and I am happy with it for my purpose.

To get it to execute on power on, I renamed the file itself to be main.py.

I am never seeing it execute at power on and only seldom does it execute at hard reset, however.

It executes automatically just fine at a soft reset but not hard.

As per the above referenced similar post, I have checked my code for mix of spaces and tabs but I saw only tabs. I ran my code through the mill at tabstospaces.com and believe I have a tab free/spaces only version now but no difference in behaviour.

Where am I going wrong, thoughts or advice?



Thanks,

Brian H.

User avatar
tve
Posts: 216
Joined: Wed Jan 01, 2020 10:12 pm
Location: Santa Barbara, CA
Contact:

Re: execute on power up, not getting the advertised results?

Post by tve » Wed Apr 15, 2020 4:50 pm

I you connect to your board via serial, e.g. miniterm.py, and then press the reset button, what do you see?

uxhamby
Posts: 34
Joined: Thu Nov 14, 2019 9:47 pm

Re: execute on power up, not getting the advertised results?

Post by uxhamby » Thu Apr 16, 2020 4:32 am

I took the dog for a walk and came back fresh to this. I am thinking it may be hardware related.

I had the max7219 powered from an external 5v supply, to spare the usb the load of up to 64 leds. Both p/s grounds are common of course.

I find that if I instead, supply the 7219 from the 5v pin on the ESP32 board, I get much better behaviour as regards starting my code at boot / reset.

User avatar
tve
Posts: 216
Joined: Wed Jan 01, 2020 10:12 pm
Location: Santa Barbara, CA
Contact:

Re: execute on power up, not getting the advertised results?

Post by tve » Thu Apr 16, 2020 5:34 am

Some dogs are amazing problem solvers! :lol:

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: execute on power up, not getting the advertised results?

Post by pythoncoder » Thu Apr 16, 2020 6:47 am

@uxhamby I'm not familiar with the max7219 but in general it is common for problems to occur if the microcontroller and the thing it's controlling are powered from separate sources. If they have a common PSU, at power-up the micro can assume that the subsystem is in a reset condition. With a separate PSU the subsystem might not yet have received power, or it might be in some arbitrary state as a result of previous tests.

These problems can usually be solved, but it adds complexity to the code. A common PSU is easier.
Peter Hinch
Index to my micropython libraries.

uxhamby
Posts: 34
Joined: Thu Nov 14, 2019 9:47 pm

Re: execute on power up, not getting the advertised results?

Post by uxhamby » Thu Apr 16, 2020 3:31 pm

Hi Peter,

Yes, I was reaching the same conclusion myself. Cheers.

Brian H.

Post Reply