guild icon
Toit
#Unkown Error in trying to initate PWM
Thread channel in help
Alexx Kaos
Alexx Kaos 12/19/2023 03:51 PM
HI guys, just trying to get set up with Toit right now. I've loaded up the example pwm script, but it's throwing an UNKNOWN ERROR 0x102(258).
I know the Pin is correct (it works with the basic standard led blink script), and is pwm compatible (from upython and arduino projects).

I'm using a seeed XIAO esp3-c3, GPIO#10

import gpio import gpio.pwm main: led := gpio.Pin 10 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

And the monitor outputs:

[jaguar] INFO: program aecc3774-fdf7-fc6a-1e25-b3c397b6481f started E (2734368) ledc: freq_hz=1000 duty_resolution=16 ****************************************************************************** Decoding by jag, device has version <2.0.0-alpha.126> ****************************************************************************** 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 led_pwm.toit:6:16 ****************************************************************************** [jaguar] ERROR: program aecc3774-fdf7-fc6a-1e25-b3c397b6481f stopped - exit code 1
(edited)
floitsch
floitsch 12/19/2023 03:53 PM
We might be doing something wrong ok the C3... :😦:
floitsch
floitsch 12/19/2023 03:57 PM
We are trying to find one, but we might only have them at the office ..
Alexx Kaos
Alexx Kaos 12/19/2023 03:57 PM
Haha, I'm not surprised. I know using the fringe boards makes things like this harder. Thanks for the help
floitsch
floitsch 12/19/2023 03:59 PM
I'm currently not at the computer but I will later look at the code and try to see if something obvious is wrong.(edited)
floitschfloitsch
I'm currently not at the computer but I will later look at the code and try to see if something obvious is wrong.(edited)
Alexx Kaos
Alexx Kaos 12/19/2023 04:00 PM
Very cool, thank you. I'll play around with the BLE until then
👍1
Alexx Kaos
Alexx Kaos 12/19/2023 06:28 PM
FYI, turning up the frequency to 10kHz got it working. For my use case I want to work in the 9-36Hz range, but I guess I can make that work with on/off timers and tasks.
floitsch
floitsch 12/19/2023 06:29 PM
You should be able to handle 9-36hz in software. Yes
floitsch
floitsch 12/19/2023 06:37 PM
What are you trying to drive with the pin?
Maybe there is another good way?
Alexx Kaos
Alexx Kaos 12/19/2023 08:20 PM
Blinking LEDs. THe most basic of functions :🙃: (LEDs are 3W, so their being driven by a PNP transistor).

I wanted to use the PWM to have non-locking functions for BLE control (change frequency, brightness etc). I just discovered the tasks which seem like a slightly more advanced asyncio function from upython though, which may be able to handle my use case for now
floitsch
floitsch 12/19/2023 08:21 PM
Why do you want to run it at such a low frequency?
floitschfloitsch
Why do you want to run it at such a low frequency?
Alexx Kaos
Alexx Kaos 12/19/2023 10:05 PM
It's a flicker-light stimulation device for brain wave entrainment. The effective studied frequenceies are 9-36Hz.
floitsch
floitsch 12/19/2023 10:06 PM
Ok. That makes more sense :🙂:
floitsch
floitsch 12/19/2023 10:07 PM
If you need very precise timings it might be worth looking whether the i2s can be run at this low speed.
floitsch
floitsch 12/19/2023 10:07 PM
(probably not, but you worth checking).
floitschfloitsch
If you need very precise timings it might be worth looking whether the i2s can be run at this low speed.
Alexx Kaos
Alexx Kaos 12/19/2023 10:11 PM
My guess is that the brain is too slow for that level of precision, we already have an auto-correcting 80ms 'synchronization window' of stimuli. But I'll explore that option if the first round of tests turns out promising.
16 messages in total