• Pi Pico Python speed

    From john larkin@3:770/3 to All on Wednesday, February 07, 2024 12:21:04
    Has anyone measured how fast a pico can do things running Python?
    Like, to start, wiggling a port pin as fast as possible?

    I think the micro Python is an interpreter.

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Peter Heitzer@3:770/3 to john larkin on Thursday, February 08, 2024 08:10:20
    john larkin <jl@650pot.com> wrote:
    Has anyone measured how fast a pico can do things running Python?
    Like, to start, wiggling a port pin as fast as possible?

    I think the micro Python is an interpreter.
    Yes, Python is interpreted.
    I found https://wellys.com/posts/board-language_speed/
    I think the performance of Micropython and Circuitpython should be
    almost equal.
    The nice thing is that you can test your code interactively in the
    Python interpreter.


    --
    Dipl.-Inform(FH) Peter Heitzer, peter.heitzer@rz.uni-regensburg.de

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From john larkin@3:770/3 to peter.heitzer@rz.uni-regensburg.de on Thursday, February 08, 2024 16:19:51
    On 8 Feb 2024 08:10:20 GMT, "Peter Heitzer" <peter.heitzer@rz.uni-regensburg.de> wrote:

    john larkin <jl@650pot.com> wrote:
    Has anyone measured how fast a pico can do things running Python?
    Like, to start, wiggling a port pin as fast as possible?

    I think the micro Python is an interpreter.
    Yes, Python is interpreted.
    I found https://wellys.com/posts/board-language_speed/
    I think the performance of Micropython and Circuitpython should be
    almost equal.
    The nice thing is that you can test your code interactively in the
    Python interpreter.

    Cool. We just did a MicroPython loop to raise and lower a port pin 4
    times, brute force inline code, as fast as we could. One up/down cycle
    takes about 14 microseconds on a Pico, with some jitter.

    We'll repeat it in c. I'm guessing that will be 20x faster.

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Bryan@3:770/3 to john larkin on Friday, February 09, 2024 00:37:50
    On 2/8/2024 19:19, john larkin wrote:
    On 8 Feb 2024 08:10:20 GMT, "Peter Heitzer" <peter.heitzer@rz.uni-regensburg.de> wrote:

    john larkin <jl@650pot.com> wrote:
    Has anyone measured how fast a pico can do things running Python?
    Like, to start, wiggling a port pin as fast as possible?

    I think the micro Python is an interpreter.
    Yes, Python is interpreted.
    I found https://wellys.com/posts/board-language_speed/
    I think the performance of Micropython and Circuitpython should be
    almost equal.
    The nice thing is that you can test your code interactively in the
    Python interpreter.

    Cool. We just did a MicroPython loop to raise and lower a port pin 4
    times, brute force inline code, as fast as we could. One up/down cycle
    takes about 14 microseconds on a Pico, with some jitter.

    We'll repeat it in c. I'm guessing that will be 20x faster.


    A little off topic, but do you have any suggestions as to good "I don't
    know squat and I'm old and it doesn't make sense" learn MicroPython
    resources?

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Peter Heitzer@3:770/3 to john larkin on Friday, February 09, 2024 08:17:27
    john larkin <jl@650pot.com> wrote:
    On 8 Feb 2024 08:10:20 GMT, "Peter Heitzer" ><peter.heitzer@rz.uni-regensburg.de> wrote:

    john larkin <jl@650pot.com> wrote:
    Has anyone measured how fast a pico can do things running Python?
    Like, to start, wiggling a port pin as fast as possible?

    I think the micro Python is an interpreter.
    Yes, Python is interpreted.
    I found https://wellys.com/posts/board-language_speed/
    I think the performance of Micropython and Circuitpython should be
    almost equal.
    The nice thing is that you can test your code interactively in the
    Python interpreter.

    Cool. We just did a MicroPython loop to raise and lower a port pin 4
    times, brute force inline code, as fast as we could. One up/down cycle
    takes about 14 microseconds on a Pico, with some jitter.

    We'll repeat it in c. I'm guessing that will be 20x faster.
    I did a quick test yesterday evening using this few lines of code:

    from machine import Pin
    led=Pin(0,Pin.OUT)
    switch=Pin(1,Pin.IN,Pin.PULL_UP)
    while switch.value(): led.toggle()

    GPIO0 was an output driving a LED. On GPIO1 I connected a momentary switch
    to ground. On the output pin I got about 41 kHz until the switch was
    pressed. With an endless loop:
    while True: led.toggle()
    I got 83 kHz.
    I used Micropython v. 1.20; the Pico run at 125 MHz.
    I also noticed some jitter. Normally one would not create a rectangle signal this way but use a PWM channel for that task.

    --
    Dipl.-Inform(FH) Peter Heitzer, peter.heitzer@rz.uni-regensburg.de

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Andy Burns@3:770/3 to Peter Heitzer on Friday, February 09, 2024 11:58:58
    Peter Heitzer wrote:

    john larkin wrote:

    Cool. We just did a MicroPython loop to raise and lower a port pin 4
    times, brute force inline code, as fast as we could. One up/down cycle
    takes about 14 microseconds on a Pico, with some jitter.

    We'll repeat it in c. I'm guessing that will be 20x faster.

    I did a quick test yesterday evening using this few lines of code:
    I got 83 kHz.

    I think if you want the fastest cycle time, you'd use the RP2040's PIO
    state machine, and probably get 62MHz without overclocking, but then
    that's not really testing MicroPython ...

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Peter Heitzer@3:770/3 to Andy Burns on Friday, February 09, 2024 12:09:06
    Andy Burns <usenet@andyburns.uk> wrote:
    Peter Heitzer wrote:

    john larkin wrote:

    Cool. We just did a MicroPython loop to raise and lower a port pin 4
    times, brute force inline code, as fast as we could. One up/down cycle
    takes about 14 microseconds on a Pico, with some jitter.

    We'll repeat it in c. I'm guessing that will be 20x faster.

    I did a quick test yesterday evening using this few lines of code:
    I got 83 kHz.

    I think if you want the fastest cycle time, you'd use the RP2040's PIO
    state machine, and probably get 62MHz without overclocking, but then
    that's not really testing MicroPython ...
    Although the PIO code could be written in MicroPython with the
    decorator @rp2.asm_pio().

    --
    Dipl.-Inform(FH) Peter Heitzer, peter.heitzer@rz.uni-regensburg.de

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Andy Burns@3:770/3 to Peter Heitzer on Friday, February 09, 2024 12:36:29
    Peter Heitzer wrote:

    the PIO code could be written in MicroPython with the decorator @rp2.asm_pio().

    I should get a Pico to play with ...

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From The Natural Philosopher@3:770/3 to Andy Burns on Friday, February 09, 2024 13:53:15
    On 09/02/2024 12:36, Andy Burns wrote:
    Peter Heitzer wrote:

    the PIO code could be written in MicroPython with the decorator
    @rp2.asm_pio().

    I should get a Pico to play with ...


    The worst part is getting a toolchain working: and understanding the
    APIs. If you don't want to use Python.

    Coding the little fuckers is pretty simple after that.


    --
    "What do you think about Gay Marriage?"
    "I don't."
    "Don't what?"
    "Think about Gay Marriage."

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)