Closed troywweber7 closed 7 years ago
Hi @troywweber7, I don't work a lot with Cylon (I'm a Johnny-Five contributor) but I'm following this issue because I am about to start on an update to Johnny-Five's stepper class and figured we might be able to share some info and ideas.
You won't really need any C for this (unless you are looking to make some changes to firmata). The work required is 100% JS so this is a great way to increase your knowledge. Your Cylon GPIO driver is going to be talking to firmata.js. The stepper protocol between firmata.js and firmata on the Arduino is documented here but that is abstracted away by firmata.js so you won't really need to know it. I just think it helps to understand what's happening at the next layer.
The firmata.js API for stepper is documented in the source. Fortunately it's only 74 lines of code and there are only two methods to worry about: stepperConfig()
and stepperStep()
.
If you create this class you will want to go ahead and support the Big Easy driver, two wire and for wire stepper motors. I say this because all the heavy lifting is handled for you in firmata on the Arduino \o/. You only have to pass in some different configuration commands.
The real work here will be designing an API that exposes all the methods that Cylon users will need to control their stepper without making it too difficult. For that I recommend looking at Johnny-Five's stepper class documentation and source. It's okay to get inspiration from our code (open source FTW)... just make sure you give credit where it's due.
In Johnny-Five we expose 5 getter/setter methodsrpm()
, speed()
, direction()
, accel()
, decel()
. We also expose three other commands: step()
, cw()
(clockwise), and ccw()
. I'd argue that these are the minimum you will need in Cylon but rpm()
and speed()
could be combined into a single frequency()
method. This might be the preferred way for Cylon.
That last statement is based on a comparison between Johnny-Five's motor and servo API's and Cylon's motor and servo API's, I think the Hybrid Group prefers to provide the basics and leave the helper methods as an exercise to the user, whereas Johnny-Five gives the users a lot of helper methods.
However you choose to move forward, I'd say the first and most important step is to design the Cylon Stepper API and get buy-in from the maintainers. Don't start anything until you have that.
Rather than cross-post my response, I've added it to https://github.com/hybridgroup/cylon-gpio/issues/55 and will close this issue in favor of that one. Thanks, everyone!
I would like to use the BigEasyDriver to drive a stepper motor from the Arduino.
I've chosen Cylon over Johnny-Five because, although newer, I believe Cylon has the right structure in place to make the system incredibly extensible and I believe it fits a larger scheme that I have in mind.
What I noticed with Cylon is a lack of support for stepper motors, although Arduino firmata packages exist which can support steppers, one such instance even being configurable to include only the necessary features.
Here is what I'm looking for:
Please NOTE, I can always simply use individual pins to drive the BigEasy, but handling the timing for a stepper motor on the Node.js side is NOT ideal. It is far better to handle the timing for a stepper motor on the Arduino which is why these firmata's which include stepper motor functionality exist.