John,
That’s absolutely correct. Accelstepper is an awesome, amazing library – I have nothing but the highest praise for the work Mike’s done. One of the downsides of having all of that awesomeness, however, is that it does require some math each time a step is taken, and each time you call the run() function. It’s this math, coupled with Arduino’s 8-bit 16MHz speed, that limits the maximum number of steps per second.
With any of the faster 32-bit boards (like Teensy 3.0 – another fantastic product, or chipKIT, or others) the math is done much more quickly, and thus the top speed is correspondingly higher. I have no problem getting 10K or 15K steps/s out of my 80MHz chipKIT boards. (the stepper motor maxes out before the chipKIT does)
Your solution to drop down to quarters steps is _exactly_ the right way to go. When you are moving that fast, microsteps have little positional benefit. Dropping down to ½ steps would produce an even bigger top speed and would probably not hurt your actual positional accuracy at all.
And you are also correct that moving at high step rates will drop your available CPU cycles for other work almost down to zero. You have to be careful of that – another big issue is that reading analog sensors take an enormous amount of time (in the microcontroller’s world anyway) and so if you do analog conversions using the normal Arduino libraries, you’ll have big gaps in the steps (since you can’t be taking steps at the same time as doing analog conversions).
One solution to this problem is to separate out the problem – use one Arduino for moving the motor, and another for taking data and saving to SD. Coordinate them using a higher level protocol – for example, over the USB, coordinated from the PC side.
The problem you are running into (system load partitioning) is a very real-world problem that we as embedded systems engineers have to struggle through every day.
*Brian
Brian Schmalz
// Principal Embedded Systems Engineer |
product development services
Logic PD
T //
612.436.5134
NOTICE: Important disclaimers and limitations apply to this email.
Please see this web page for our disclaimers and limitations:
John,
You will probably have to fiddle with the current level adjustment pot on the Big Easy Driver. What I suggest to people is to create a very slow, steady pulse train (say maybe 4 hz) and, with it set at 16x microstepping, feel the shaft of the motor as you adjust the pot. You’re looking for the sweet spot where every one of the steps feels equal in size and torque. Once you have that running well, you should be able to switch to ¼ and ½ and full step modes using the M1, M2 and M3 pins and see each step sent to the driver create a different size of step. This is most easily measureable by having it do 3200 steps in say 10 seconds. Then just count the revolutions.
As for your other questions, there are lots of things to take into consideration here. Far too many to effectively communicate in an e-mail. But I will be able to say that we’ve tried to design the chipKIT so that it is as close to the Arduino as possible. With a chipKIT UNO32, for example, all shields that work on Arduino will fit right on the UNO32 board. Also, many libraries will ‘just work’ between Arduino and chipKIT. We use the same IDE as Arduino (We’ve forked it and called it MPIDE so that we could use a different C compiler for the PIC32 rather than AVR). No changes are necessary in AccelStepper code to go back and forth between the two platforms.
That said, there are differences, and you will likely need to understand them to make use of both platforms properly. For example, chipKIT32 (and in fact most 32 bit boards) are 3.3V only on their I/O. They are 5V tolerant, but only output 3.3V. This is fine for most shields, but not all. Also, there are lots of libraries that use direct register access on the ARV – these obviously don’t work on any other platform. And MPIDE is currently only compatible with Arduino 0023, not the newer 1.0 or 1.5.
The performance differences between Arduino and the 32-bitters is huge – sometimes considerable more than 20x (depending on the code). For example, I wrote a library for chipKIT that takes advantage of the 80MHz 32-bit PIC32 processor and allows you to output RC servo pulses on every I/O pin simultaneously (all with different values of course), and it still only uses about 10% of the CPU time. (That’s up to 83 I/O pins at once – 83 RC servos going at the same time.) The RAM and Flash are also far, far bigger on the 32-bitters. And they are surprisingly affordable. But the ‘ecosystem’ around each one is far smaller than the Arduino ecosystem, so you have to be willing to figure stuff out more on your own.
It’s a tough call for an educator. It’s easy to get bogged down and frustrated by Arduino, and even more so if you migrate to a compatible, but different, platform.
The bigger 32-bit platforms (Due, chipKIT (backed by Microchip), etc.) are going to be around for quite some time, as they’re really the direction that a lot of people will go over the next couple years. (If you could get a 80Mhz 32-bit Arduino for the same price as your 8-bit 16MHz Arduino, wouldn’t you? Lots of people will.) So the critical mass will be moving in the 32 bit direction, and it will only get more supported and more popular.
My suggestion is to buy a chipKIT board (maybe the uC32? Or a Fubarino SD if you’re into breadboaring) and a Due and maybe some others and just give it a chance- try running your code on each one, and see where things work and where they don’t. You may be surprised how easily things transition.
*Brian
Brian Schmalz
// Principal Embedded Systems Engineer |
product development services
Logic PD
T //
612.436.5134
NOTICE: Important disclaimers and limitations apply to this email.
Please see this web page for our disclaimers and limitations:
http://logicpd.com/email-disclaimer/
--
John,
I sincerely appreciate that you’re trying to understand this stuff – I’d be hard pressed to dig this deep into mechanical things. So way to go.
Let me correct a number of incorrect assumptions in what you’ve written below, and hopefully it will help you make your decision.
1) We (not Digilent, but we the rag-tag developer group that created MPIDE – which does include Digilent, but also includes a large number of other parties) forked MPIDE from Arduino IDE. The only major change we made was that we added the Microchip C compiler in addition to the AVR compiler. So from MPIDE, you can compile the same code for EITHER Arduino (AVR) OR ChipKIT (PIC32), depending on what board you choose.
2) Just because something requires a different compiler does not make it any more or less efficient. The ARM, PIC32, and AVR compilers are all different. However, they all interpret the Arduino sketches exactly the same – in the sense that exactly the same input sketches are used – it’s just the output that’s different (by necessity).
3) There is no hidden subtext about this not being the best way to code. I get very frustrated at the Arduino folks because they seem to keep saying that Arduino is coded in ‘simplified C’ – like it’s some special language or something. It IS NOT. You write a sketch in C++. Normal C++. There are some shortcuts that the Arduino IDE does for you (like header file inclusion, nice core library support, etc.) that makes your sketch code simpler than a ‘normal’ C++ application, however, it’s still just C++. There is no difference. There is no performance slow down (because of the language). Writing a sketch is (if you do it right) _exactly_ as efficient in running as writing a C or C++ program, because that’s exactly what you’re doing. The Arduino IDE uses native compilers. It takes your C/C++ sketch, combines it with the core libraries, links it, and downloads it, just like any C/C++ other compiler would.
4) Like you, I am astonished that Arduino hasn’t come out with more powerful products for lower prices. But that’s not their business model. I’ll leave it at that.
5) As far as why there are library incompatibilities – there can be several sources of issues when you take a library from Arduino and try to run it on a Due or chipKIT or Teensy 3, etc. If the library ONLY uses built-in Arduino core API calls, and it properly uses the built-in pin defines, then it is almost guaranteed to work without any changes. We have seen many, many higher quality libraries (like AccelStepper) run perfectly well (in fact, run WAY better) on chipKIT without any changes. If the library author needed to use specific registers in the low level chip, and bypassed the Arduino core API, then the library will not work on other boards without being tweaked. Sometimes these tweaks are very simple, and sometimes they require re-writing quite a bit of the library. Different libraries will have different reasons for not being compatible. Maybe one library needs 6 PWM outputs in order to be useful – and chipKIT boards only have 5, so it will never run on the chipKIT boards. Maybe a library makes an assumption about how a particular peripheral works, and this works fine for some boards, but for other boards that peripheral is slightly different, and so doesn’t work quite right until the library’s author makes the necessary board or chip specific code changes. (This is a problem even between Arduino AVR boards – like between the UNO, Leonardo, Micro, etc.)
I hope that helps-