QTPY RP; Where are pwmio, board libraries?

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
nornicotine
 
Posts: 23
Joined: Sun Apr 03, 2011 12:39 pm

QTPY RP; Where are pwmio, board libraries?

Post by nornicotine »

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!

User avatar
dastels
 
Posts: 15820
Joined: Tue Oct 20, 2015 3:22 pm

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

Post by dastels »

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 ... atrix.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

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

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

Post by nornicotine »

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

User avatar
dastels
 
Posts: 15820
Joined: Tue Oct 20, 2015 3:22 pm

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

Post by dastels »

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

Dave

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

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

Post by nornicotine »

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.

User avatar
dastels
 
Posts: 15820
Joined: Tue Oct 20, 2015 3:22 pm

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

Post by dastels »

That is odd. You see the CIRCUITPY drive?

Dave

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

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

Post by nornicotine »

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...

User avatar
dastels
 
Posts: 15820
Joined: Tue Oct 20, 2015 3:22 pm

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

Post by dastels »

There might be something useful here: https://learn.adafruit.com/adafruit-qt- ... al-console.

Dave

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

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

Post by nornicotine »

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?

User avatar
dastels
 
Posts: 15820
Joined: Tue Oct 20, 2015 3:22 pm

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

Post by dastels »

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

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

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

Post by nornicotine »

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.

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

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

Post by hagent »

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

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”