bbcmicrobit / bbcmicrobit/micropython

set_analog_period changes PWM period for all PWM pins.

Open
#644 3 comments 1 reaction 0 assignees View on GitHub
docs
Dominant language
C
Stars
646
Forks
290
PR merge metrics
No merged PRs in 30d

Description

I'm making a synthesizer project, and for it I need to have several different PWM signlas.
The problem is when you call set_analog_period() on one of the pins it changes it for all PWM pins. Here's an example of the code, that I used to track this:

`
pin0.set_analog_period(2)
pin0.write_analog(250)
pin1.set_analog_period(3)
pin1.write_analog(250)
val = 2

while True:
val = 5-val
pin1.set_analog_period(val)
pin1.write_analog(250)
sleep(2000)
`

The output on pin0 and pin1 in this case is identical, although I only call set_analog_period() on pin1.

If that's not the issue, and you can only change global period, I think this should be highlighted in the documents, as it's far from obvious since it's a pin's method and not microbit's.
In this case, is there a way to have several pwm signals with different periods?

Thanks!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the provided set_analog_period() and write_analog() sequence on the micro:bit, then inspect the API behavior and documentation for PWM periods. Determine whether independent periods are supported; done means either separate PWM periods work as requested or the global-period limitation and available alternatives are clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
embedded-iot
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.