Due to high demand expect some shipping delays at this time, orders may not ship for 1-2 business days.
0

QTPY RP; Where are pwmio, board libraries?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

QTPY RP; Where are pwmio, board libraries?

by nornicotine on Tue Oct 26, 2021 12:45 am

Hi, I have Qtpy RP (Stemma) device. Got the drive loaded, xfered the UF2 file, all ok. Using Mu editor, can get the neopixel to blink. But trying to move on, I cannot 'import board' or 'import pwmio', always get not found error. I've looked through all the latest adafruit-circuitpython-bundle-7.x-mpy-20211024\lib files..but cannot find this. Where might these modules be hiding?

As a suggestion, would it not be possible to list everything either; a) alphabetically or b) by board first, then alphabetically? Many cryptic names with all the different boards makes it difficult.

Thanks!
nornicotine
 
Posts: 23
Joined: Sun Apr 03, 2011 12:39 pm

Re: QTPY RP; Where are pwmio, board libraries?

by dastels on Tue Oct 26, 2021 9:04 am

The low level, hardware related modeules (or ones that are implemented in C++ for performance reasons) are part of CircuitPython, not the bundle (and implemented in C++, not Python). What's available varies with the board. You can find the lists of what internal modules are on each board at https://circuitpython.readthedocs.io/en/latest/shared-bindings/support_matrix.html.

What you're reporting is odd, though. The board module is on every board. Can you post the error text that you get in the REPL by trying to import board?

Dave

dastels
 
Posts: 7895
Joined: Tue Oct 20, 2015 3:22 pm

Re: QTPY RP; Where are pwmio, board libraries?

by nornicotine on Tue Oct 26, 2021 12:16 pm

Hi Dave,
also, running Mu 1.1.0.beta.6...
Here is the code, which I copied from some example on the website:

# Write your code here :-)
import time
import board
import pwmio

led = pwmio.PWMOutputDevice(board.A1, frequency=5000, duty_cycle=0)
# led2 = pwmio.PWMOutputDevice(board.A2, frequency=5000, duty_cycle=0)

while True:
for i in range(100):
if i < 50:
led.duty_cycle = int(i*2*65535/100)
# led2.duty_cycle = int(i * 2 * 65535 / 100)
else:
led.duty_cycle = 65535 - int((i - 50) * 2 * 65535/100)
# led2.duty_cycle = 65535 - int((i - 50) * 2 * 65535/100)
time.sleep(0.01)

And here is the REPL output, also is same for pwmio:

Traceback (most recent call last):
File "d:\code.py", line 3, in <module>
import board
ModuleNotFoundError: No module named 'board'
>>>

---------- FINISHED ----------
exit code: 2 status: 0
nornicotine
 
Posts: 23
Joined: Sun Apr 03, 2011 12:39 pm

Re: QTPY RP; Where are pwmio, board libraries?

by dastels on Tue Oct 26, 2021 12:48 pm

Make sure the code is running on your QTPY and not your PC/Mac/etc.

Dave

dastels
 
Posts: 7895
Joined: Tue Oct 20, 2015 3:22 pm

Re: QTPY RP; Where are pwmio, board libraries?

by nornicotine on Tue Oct 26, 2021 4:55 pm

Hi Dave,
Thanks...so I have Mu in the circuit python mode, which I believe is what you were referring to above. So, no more missing board errors.

If I may, (assuming this is another simple thing...); I can see the Qtpy drive, my code is there, I can load it and edit it. When I hit the serial port button in Mu, Mu responds with the error that it cannot find any connected device. That seems odd, your thoughts appreciated.
nornicotine
 
Posts: 23
Joined: Sun Apr 03, 2011 12:39 pm

Re: QTPY RP; Where are pwmio, board libraries?

by dastels on Tue Oct 26, 2021 5:21 pm

That is odd. You see the CIRCUITPY drive?

Dave

dastels
 
Posts: 7895
Joined: Tue Oct 20, 2015 3:22 pm

Re: QTPY RP; Where are pwmio, board libraries?

by nornicotine on Tue Oct 26, 2021 5:55 pm

Yes, I can see the drive, add/delete/rename files, etc.

I've tried resetting...that does not help.

I also just tried the neopixel blink sketch; copied it into mu, saved to drive CIRCUITPY (D:).
Neopixel blinks appropriately.
When I click on Serial button (Mu), it responds with cannot find attached device.

This is from Mu log:

2021-10-26 15:38:13,738 - mu.interface.main:1038(show_message) DEBUG: Could not find an attached device.
2021-10-26 15:38:13,738 - mu.interface.main:1039(show_message) DEBUG: Please make sure the device is plugged into this computer.

It must have a version of MicroPython (or CircuitPython) flashed onto it before the REPL will work.

Finally, press the device's reset button and wait a few seconds before trying again.
2021-10-26 15:38:16,838 - mu.modes.base:474(toggle_repl) INFO: Toggle REPL on.
2021-10-26 15:40:28,023 - mu.logic:1413(show_admin) INFO: Showing admin with logs from C:\Users\setup\AppData\Local\python\mu\Logs\mu.log

Interestingly, while all this is going on (ie, the blink program works and I can edit it, change color of the neopixel) the little icon to the left of the cog wheel (lower right corner) shows nothing connected, there is a small red circle with a white X through it. Weird...
nornicotine
 
Posts: 23
Joined: Sun Apr 03, 2011 12:39 pm

Re: QTPY RP; Where are pwmio, board libraries?

by dastels on Wed Oct 27, 2021 9:56 am


dastels
 
Posts: 7895
Joined: Tue Oct 20, 2015 3:22 pm

Re: QTPY RP; Where are pwmio, board libraries?

by nornicotine on Wed Oct 27, 2021 1:36 pm

Hi Dave,
Not sure if you're implying or actually know something is amiss here, so your remark is not so helpful. If its something obvious, please let me know.
Using Windows 8.1; drivers already installed, without issue. I followed the directions as best I could.
I've tried 2 different Qtpy's, same results. So its not the device.
When I plug a Qtpy in, windows immediately recognizes the circuitpy drive, without issue.
Possible bug?
nornicotine
 
Posts: 23
Joined: Sun Apr 03, 2011 12:39 pm

Re: QTPY RP; Where are pwmio, board libraries?

by dastels on Wed Oct 27, 2021 3:33 pm

Everything sounds like it should work based on what I know (I don't use Mu). Are you running the latest version of Mu? If so, maybe try a previous version.

Another thing to check is to see if you can get the REPL/Serial using a terminal emulator. I don't know what's available on Windows, there must be something like telnet, minicom, etc. If you can, then it's a pretty solid indication that it's something related to Mu.

Dave

dastels
 
Posts: 7895
Joined: Tue Oct 20, 2015 3:22 pm

Re: QTPY RP; Where are pwmio, board libraries?

by nornicotine on Thu Oct 28, 2021 12:12 pm

So, programming the Qtpy seems normal; I was able to get it to function as I wanted even without the serial monitor.

I'll see what I can find regarding another serial monitor...

Otherwise, we can close this issue; thank you for your help.
nornicotine
 
Posts: 23
Joined: Sun Apr 03, 2011 12:39 pm

Re: QTPY RP; Where are pwmio, board libraries?

by hagent on Thu Nov 11, 2021 10:06 am

Hello, I've been having the same problem with the pwmio library. I'm working with the CPE code on this page: https://learn.adafruit.com/adafruit-cir ... thon-servo

I'm running CircuitPython 7 and it looks to me as if pwmio is not present in the libraries. I replaced the pwmio library with the pulseio library and got the code to run.

I replaced these 2 lines in the code in the "Continuous Servo Code" program:

import pwmio
pwm = pwmio.PWMOut(board.A2, frequency=50)

With these lines:

import pulseio
pwm = pulseio.PWMOut(board.A2, frequency=50)

Tom Hagen

hagent
 
Posts: 2
Joined: Sun Jan 13, 2019 4:36 pm

Please be positive and constructive with your questions and comments.