๐Ÿ“ฃ๐Ÿ“ช ๐Ÿšš Adafruit will not be shipping USPS orders Monday January 20, 2020 ๐Ÿ—“. Expedited USPS orders placed after 11am ET ๐Ÿ•š Friday January 17 will go out Tuesday January 21 ๐Ÿ“ฃ๐Ÿ“ช๐Ÿšš
0

Using PWM to control L298n driver
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Using PWM to control L298n driver

by chizzly on Sun Feb 03, 2019 2:44 am

I am building an inspection robot and have a raspberry pi 3+ with a Adafruit 16-Channel PWM / Servo HAT for Raspberry Pi. I have got servos working however can't seem to be able to control the pwm without ServoKit. when i attempt pwm=PWM(0X40) I get "NameError: name 'PWM' is not defined" I have tried updating the library's and don't have a large programming knowledge base to trouble shoot.

I also I don't know how I would change the direction of the motor because i can't controll the hi and low pins to the L298

chizzly
 
Posts: 3
Joined: Sun Feb 03, 2019 2:36 am

Re: Using PWM to control L298n driver

by adafruit_support_mike on Sun Feb 03, 2019 3:59 am

Post the exact code you're using now (between CODE tags please) and we'll take a look.

adafruit_support_mike
 
Posts: 60177
Joined: Thu Feb 11, 2010 2:51 pm

Re: Using PWM to control L298n driver

by chizzly on Sun Feb 03, 2019 2:29 pm

Code: Select all | TOGGLE FULL SIZE
from adafruit_servokit import ServoKit
pwm = PWM(0x40)
pwm.setPWMFreq(1000)
pwm.setPWM(2, 1024, 3072)

chizzly
 
Posts: 3
Joined: Sun Feb 03, 2019 2:36 am

Re: Using PWM to control L298n driver

by adafruit_support_mike on Mon Feb 04, 2019 1:35 am

Ah.. you're using a library that won't really help you. If you want to control the basic PWM features, you can use the Adafruit_CircuitPython_PCA9685 library:

https://github.com/adafruit/Adafruit_Ci ... on_PCA9685

The folder named 'examples' has sample code that shows how to create the object, set the PWM frequency, and control various channels:

https://github.com/adafruit/Adafruit_Ci ... r/examples

adafruit_support_mike
 
Posts: 60177
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.