guild icon
Toit
#PWM Issues
Thread channel in help
Spruiid
Spruiid 12/12/2024 05:32 PM
Hello,

We’re experiencing issues with sending PWM signals.

We’re using a Walter Board (ESP32-S3) with the demo code provided on the official website, configured to suit our requirements. Below is the code we're using:

import gpio import gpio.pwm main: led := gpio.Pin 2 --output generator := pwm.Pwm --frequency=50 channel := generator.start led channel.set-duty-factor 0.5 sleep --ms=10_000 channel.close generator.close led.close

Software setup:
esp32s3-octo-spiram envelope
Jaguar v1.45.1
SDK version: v2.0.0-alpha.170

Below i'll provide the full Error:
Spruiid
Spruiid 12/12/2024 05:32 PM
E (328) octal_psram: PSRAM ID read error: 0x00000000, PSRAM chipESP-ROM:esp32s3-20210327 Build:Mar 27 2021 rst:0x15 (USB_UART_CHIP_RESET),boot:0x9 (SPI_FAST_FLASH_BOOT) Saved PC:0x403846e6 SPIWP:0xee mode:DIO, clock div:1 load:0x3fce3810,len:0x88 load:0x403c9700,len:0x96c load:0x403cc700,len:0x2504 entry 0x403c9850 E (299) octal_psram: PSRAM ID read error: 0x00000000, PSRAM chip not found or not supported, or wrong PSRAM line mode E (299) esp_psram: PSRAM enabled but initialization failed. Bailing out. [toit] INFO: starting <v2.0.0-alpha.170> [toit] DEBUG: clearing RTC memory: powered on by hardware source [toit] INFO: running on ESP32S3 - revision 0.2 [wifi] DEBUG: connecting [wifi] WARN: connect failed {reason: unknown reason (203)} [wifi] DEBUG: closing [jaguar] WARN: running Jaguar failed due to 'CONNECT_FAILED: unknown reason (203)' (1/3) [wifi] DEBUG: connecting [wifi] DEBUG: connected [wifi] INFO: network address dynamically assigned through dhcp {ip: 192.168.1.18} [wifi] INFO: dns server address dynamically assigned through dhcp {ip: [192.168.1.1]} [jaguar.http] INFO: running Jaguar device 'inverted-function' (id: '60b97c28-386d-44a8-bc4f-b80a1caed762') on 'http://192.168.1.18:9000' [jaguar] INFO: program 2bc4defe-e5b8-655a-b6a2-1b631dd1a028 started E (21677) ledc: freq_hz=50 duty_resolution=20 ****************************************************************************** Decoding by `jag`, device has version <2.0.0-alpha.170> ****************************************************************************** EXCEPTION error. UNKNOWN ERROR 0x102(258) 0: pwm-init_ <sdk>\gpio\pwm.toit:177:3 1: Pwm <sdk>\gpio\pwm.toit:103:12 2: main testing.toit:6:16 ****************************************************************************** [jaguar] ERROR: program 2bc4defe-e5b8-655a-b6a2-1b631dd1a028 stopped - exit code 1
floitsch
floitsch 12/12/2024 05:33 PM
The S3 doesn't support low frequencies with the pwm.(edited)
floitsch
floitsch 12/12/2024 05:35 PM
I will try to find the exact values and update the documentation of the pwm library. I hope I will also find a better way to report the error when I do that.
floitschfloitsch
I will try to find the exact values and update the documentation of the pwm library. I hope I will also find a better way to report the error when I do that.
kurt.renauer
kurt.renauer 12/12/2024 05:40 PM
We already tested successfully PWM with 50Hz earlier this year on Walter (gpio2)? Checked with Oscilloscope and it worked fine. I can't remember the version of the SDK :😦: @Spruiid ?(edited)
floitsch
floitsch 12/12/2024 05:41 PM
Interesting.
I was convinced we ran into a similar issue some time ago. Let me see if I can find it.
(edited)
πŸ‘1
kurt.renauer
kurt.renauer 12/12/2024 05:42 PM
It was a pretest for using Walter as substitute for the old Pycom/Gpy.
floitsch
floitsch 12/12/2024 05:45 PM
If it works on an older SDK we can maybe get it to work again. Last time I looked I couldn't find any way, though.
floitsch
floitsch 12/12/2024 05:46 PM
Hmm. Maybe it's possible by using a different clock as input.
kurt.renauer
kurt.renauer 12/12/2024 05:51 PM
@floitsch do you have a Walter board or a similar one for testing?(edited)
floitsch
floitsch 12/12/2024 05:51 PM
I have an S3
πŸ‘1
kurt.renauerkurt.renauer
We already tested successfully PWM with 50Hz earlier this year on Walter (gpio2)? Checked with Oscilloscope and it worked fine. I can't remember the version of the SDK :😦: <@302263...(edited)
Spruiid
Spruiid 12/12/2024 06:18 PM
I believe we tested on alpha.153, since it was not relevant back then I did not check it though.
πŸ‘1
SpruiidOPSpruiid
I believe we tested on alpha.153, since it was not relevant back then I did not check it though.
kurt.renauer
kurt.renauer 12/12/2024 07:22 PM
is there a way deploy this old SDK version? for pwm testing only ...(edited)
floitsch
floitsch 12/12/2024 07:39 PM
You can always download an older Jaguar
πŸ‘1
floitsch
floitsch 12/13/2024 08:58 AM
I just tried with SDK 152 and 154 and both exhibit the same error.
E (12975) ledc: freq_hz=50 duty_resolution=20
kurt.renauer
kurt.renauer 12/13/2024 10:18 AM
We had definitly positive pwm-tests for server control usage .... hmm? I decided - late August 2024 to replace gpy with Walter because of this sscuessful test ... hmm?
floitsch
floitsch 12/13/2024 10:24 AM
I managed to get it working, but I had to change the C++ primitives. So I don't think it ever worked with Toit.(edited)
floitsch
floitsch 12/13/2024 10:25 AM
floitsch
floitsch 12/13/2024 10:26 AM
Today is my last day before vacation and I won't be able to cleanly fix this now, but it's clearly possible. I will implement this correctly in the beginning of next year.
❀️1
floitschfloitsch
Click to see attachment.
kurt.renauer
kurt.renauer 12/13/2024 10:38 AM
I am absolutely sure that we had a working pwm 50Hz on Walter ... but I am confused now :πŸ™‚:
Thanks a lot for your effort and it is a rather important step for us to get Walter running instead of gpy.
(edited)
kurt.renauer
kurt.renauer 12/13/2024 10:43 AM
@Spruiid please take some time to find out what we did last summer :πŸ˜‰:
kurt.renauerkurt.renauer
I am absolutely sure that we had a working pwm 50Hz on Walter ... but I am confused now :πŸ™‚: Thanks a lot for your effort and it is a rather important step for us to get Walter runni...(edited)
floitsch
floitsch 12/13/2024 11:27 AM
I will see if I can add a (maybe hackish) fix before I leave for vacation.
❀️1
πŸ‘1
floitsch
floitsch 12/13/2024 12:17 PM
I have uploaded a PR.
floitsch
floitsch 01/09/2025 09:14 AM
A fix was committed and will be part of alpha.175.
I have uploaded an envelope for 174 to my drive: https://drive.google.com/file/d/1LLiFIq3up3lFfIJ-W4RaPigN-VS4kZcV/view?usp=drive_link
With Jaguar you can simply jag flash <PATH-TO-ENVELOPE>. (If it's in your current directory use ./<NAME-OF-ENVELOPE (with a ./))
floitschfloitsch
A fix was committed and will be part of alpha.175. I have uploaded an envelope for 174 to my drive: https://drive.google.com/file/d/1LLiFIq3up3lFfIJ-W4RaPigN-VS4kZcV/view?usp=drive...
obetbal
obetbal 01/09/2025 06:49 PM
Thank you. The pwm fix worked. Was the update on espressif updates or toit side?
obetbalobetbal
Thank you. The pwm fix worked. Was the update on espressif updates or toit side?
floitsch
floitsch 01/09/2025 06:52 PM
Toit. We had a bug in the S3 implementation. I'm in the process of adding more hardware tests to cover more variants.
πŸ‘2
27 messages in total