Notifications
Clear all

Specifying the frequency of AnalogWrite() for motor control on RP Pico

21 Posts
4 Users
2 Likes
3,145 Views
(@redi45)
Member
Joined: 5 years ago
Posts: 7
Topic starter  

Hey Everyone!

I took a day away from my computer and I return to all these input posts! Thank you soooo much!

In answer to some of your speculation, I really wanted to use Circuitpython or Micropython and tried . I felt they were weak (my opinion, maybe I am wrong / I have been before). I didn't really want to go with Arduino as I am really weak in that area but I am standing on the shoulders of giants: using a snippet here and there.

I'll need a day to digest and do these suggestions. I just wanted to let you know I'm still hangin' in there and appreciating you.

Bo

This post was modified 2 years ago by redi45

   
ReplyQuote
(@redi45)
Member
Joined: 5 years ago
Posts: 7
Topic starter  

@byron The post containing Peter Hinch's github re: Micropython encoders looks like he did a LOT of work on this and I'm going to try it out before I move on to Arduino.

Bo 


   
ReplyQuote
(@redi45)
Member
Joined: 5 years ago
Posts: 7
Topic starter  

@thrandell Thank you Tom! I'm truly grateful for your hard work. I'm trying your code. I'm converting it to my Pololu TB6612FNG breakout. I have 12V motors and, well, it's the motor controller I have. Fingers crossed that this will work.

BTW, I came across this library that can specify PWM and frequency:

https://github.com/khoih-prog/RP2040_PWM

Looking at that as well.

Bo

 


   
ReplyQuote
THRandell
(@thrandell)
Brain Donor
Joined: 3 years ago
Posts: 223
 
Posted by: @redi45

@thrandell Thank you Tom! I'm truly grateful for your hard work.

Hi Bo,

It was more plagiarism then hard work 😉

I wanted to remind you that you'll need to add hardware_pwm to your CMakeLists.txt file.  You add it to the target_link_libraries list.  I'm a command line guy using an Apple Macbook, so I just followed the instructions in the Getting Started with the Raspberry Pi Pico for C/C++ development for the macOS.

I noticed that your motor driver uses a logic voltage between 2.7V and 5.5V so the Pico should work fine.  You can also increase the PWM frequency to 100kHz for a super quiet car ride.

Let me know if you have any problems with the compile and I'll try to help.

 

Tom

To err is human.
To really foul up, use a computer.


   
Inst-Tech reacted
ReplyQuote
THRandell
(@thrandell)
Brain Donor
Joined: 3 years ago
Posts: 223
 

To err is human.
To really foul up, use a computer.


   
ReplyQuote
(@redi45)
Member
Joined: 5 years ago
Posts: 7
Topic starter  

Hi All!

Sorry for the delay in my answering, I got distracted by another shiny thing.

Happens all the time for me.

Anyway, I'll try this out and get back to you -- and thank you for your work!

Bodat


   
ReplyQuote
Page 2 / 2