Hey, I am currently using Itsy Bitsy M0 express, and I was able to output a PWM at 10Hz. When I use battery or a DC-DC converter to power the Itsy Bitsy using BAT pin, the output frequency is 9.7Hz instead of 10Hz. How can I resolve this issue. I hope to hear your response.
Below is the code I used to generate 10Hz.
import time
import board
import pwmio
Trig1 = pwmio.PWMOut(board.D10, frequency=10, duty_cycle=20000)
while True:
Trig1
Itsy Bitsy M0 outputs slight change in frequency when using
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- RainySun
- Posts: 73
- Joined: Thu Nov 18, 2021 2:55 pm
- RainySun
- Posts: 73
- Joined: Thu Nov 18, 2021 2:55 pm
Re: Itsy Bitsy M0 outputs slight change in frequency when us
I would also like to add that when I use battery to power Itsy Bitsy, the output I get is
For 5Hz, I get 4.85Hz
For 10Hz, i get 9.70Hz
For 50Hz, I get 48.49Hz
It looks like it has a factor of 0.97. I have tired making changes to the code but the issue is that with PWMIO, the frequency can only be written in Integers. How can I include the factor of 0.97 in the code? I hope to hear your response.
For 5Hz, I get 4.85Hz
For 10Hz, i get 9.70Hz
For 50Hz, I get 48.49Hz
It looks like it has a factor of 0.97. I have tired making changes to the code but the issue is that with PWMIO, the frequency can only be written in Integers. How can I include the factor of 0.97 in the code? I hope to hear your response.
- Franklin97355
- Posts: 23912
- Joined: Mon Apr 21, 2008 2:33 pm
Re: Itsy Bitsy M0 outputs slight change in frequency when us
What are you using to power the IB when you get 10hz?
- RainySun
- Posts: 73
- Joined: Thu Nov 18, 2021 2:55 pm
Re: Itsy Bitsy M0 outputs slight change in frequency when us
I am using a DC Power Supply with voltage set to 5V, and current limit set to 100mAmp. I have also increased the voltage up to 5.5V to see if it make any difference, and it is still the same.
- adafruit2
- Posts: 22148
- Joined: Fri Mar 11, 2005 7:36 pm
Re: Itsy Bitsy M0 outputs slight change in frequency when us
this is likely due to the chip being off of USB which is how it synchronizes the internal clock. that said, thats a pretty big difference. do you have more than one board to test with?
- RainySun
- Posts: 73
- Joined: Thu Nov 18, 2021 2:55 pm
Re: Itsy Bitsy M0 outputs slight change in frequency when us
Thankful for your response. I have two itsy bitsy M0 Express that I tested with, and both have the same response when using a DC power supply.
I will order ItsyBitsy M4, and test it with a DC power supply. I just realized if ItsyBitsy M4 doesn't have an internal clock (just like Itsy Bitsy M0), wouldn't it have similar response.
I will order ItsyBitsy M4, and test it with a DC power supply. I just realized if ItsyBitsy M4 doesn't have an internal clock (just like Itsy Bitsy M0), wouldn't it have similar response.
- adafruit2
- Posts: 22148
- Joined: Fri Mar 11, 2005 7:36 pm
Re: Itsy Bitsy M0 outputs slight change in frequency when us
yeah it might work :/ the 32u4 and nrf52840 do have xtals!
- RainySun
- Posts: 73
- Joined: Thu Nov 18, 2021 2:55 pm
Re: Itsy Bitsy M0 outputs slight change in frequency when us
For ItsyBitsy M0 Express, is there anything I can do on the coding end to divide by 0.97 factor. For example:
These are the frequency that I will be using.
4.85 / 0.97 = 5Hz (to get the correct frequency output)
9.7 / 0.97 = 10Hz
48.49/ 0.97 = 49.9Hz
How do I divide the 0.97 on the code. I have used PWMIO function but I can only use integers. Can you please help me out with this.
I am sure this will help people out as well to output correct frequency when using a battery for M0 express.
Also, can you please confirm that ItsyBitsy nRF52840 works well with Circuit Python; not sure about ItsyBitsy 32u4.
I hope to hear your response.
These are the frequency that I will be using.
4.85 / 0.97 = 5Hz (to get the correct frequency output)
9.7 / 0.97 = 10Hz
48.49/ 0.97 = 49.9Hz
How do I divide the 0.97 on the code. I have used PWMIO function but I can only use integers. Can you please help me out with this.
I am sure this will help people out as well to output correct frequency when using a battery for M0 express.
Also, can you please confirm that ItsyBitsy nRF52840 works well with Circuit Python; not sure about ItsyBitsy 32u4.
I hope to hear your response.
Please be positive and constructive with your questions and comments.