-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bts7960: Add new device package #447
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add an example and a smoke test? Each driver has an example in the examples directory and a smoke test in the Makefile.
bts7960/bts7960.go
Outdated
} | ||
|
||
// New returns a new motor driver. | ||
func New(lEn, rEn, lPwm, rPwm machine.Pin, pwm machine.PWM) *Device { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you define and use a PWM interface instead of using machine.PWM
? It is called differently on other chips.
For example, with the following interface:
type PWM interface {
Channel(pin machine.Pin) (channel uint8, err error)
Set(channel uint8, value uint32)
Top() uint32
}
func New(lEn, rEn, lPwm, rPwm machine.Pin, pwm machine.PWM) *Device { | |
func New(lEn, rEn, lPwm, rPwm machine.Pin, pwm PWM) *Device { |
} | ||
|
||
// Left turns motor left. | ||
func (d *Device) Left(speed uint32) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, what about Clockwise
/ Counterclockwise
? No strong opinion from me, but it might be easier to understand. (I don't know this motor though so I don't know which terminology makes sense).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed ur comments |
First of all, thanks for working on this. SO if you look at both the L293x and the BTS7960, it can be noted that they are both H-bridges and as a result have essentially the same sort of way that you connect to them and use them. As the Wikipedia page says:
The only difference is that the BTS7960 has a connection to enable separately the forward direction from the reverse direction. I would suggest basically copy the structure/format of the L293x driver. Of course rename the pins, and then implement the same API in the manner that the BTS7960 requires. I propose that we define type Motoring interface {
Forward()
ForwardWithSpeed(speed uint32)
Backward()
BackwardWithSpeed(speed uint32)
Stop()
} In the case of the In the case of the This will make it possible to use either the BTS7960 or the L293X with a minimal amount of code changes. Last comment, the L293X driver does not try to configure the PWM for the user: This is part because not every board has the same PWM implementation, even though they expose the same interface. Just seems like it simplifies things for users. What do you think? If it seems like a good idea, I can go back to the L293x and make sure it is doing the same thing. |
Hey |
Added support for bts 7960 motor driver.
It is based on the C++ code from this library: https://github.com/luisllamasbinaburo/Arduino-BTS7960