1

It's been almost a year since the last posting in here covering this topic - are there any newer examples or libraries that you (Joan or anyone) know of that do the acceleration ramp, constant run-rate, and deceleration ramp, together with actual counting of steps? The "in" way to run steppers with the Pi at the moment is to use an external pulse/direction/enable stepper driver that implements microsteps and current control. They all require exact timed pulses that can be ramped in frequency without any timing discontinuities.

I'm trying to run a peristaltic pump and the only way I can get accurate results is to count steps exactly. The pigpio examples show waves being timed by the pigpio system while timed by the Pi and then stopped or acted on once the time expires: this isn't accurate enough to guarantee a known number of steps. Instead I just need the purpose-designed waveform to come to an end and immediately be followed by another waveform of a different frequency without losing any cycles and matching the two waveforms exactly in terms of high/low states at full-cycle boundaries. It's not clear from pigpio documentation how to do this, so I rely on the examples found here and at the pigpio site, which don't ever seem to go there (unless I missed one?)

Ideally there would be a library/example based on the work done in this article on fast approximated stepper pulse generation math (https://www.embedded.com/design/mcus-processors-and-socs/4006438/Generate-stepper-motor-speed-profiles-in-real-time) There is an Arduino library that does just that. Given that DMA is the way around the non-real-time Raspberry Pi, the article's methods could be used to precalculate waves and then run them through pigpio for accurate rendition.

I'd write this myself but after reading the comments here and anywhere else I could find them, I am still not confident that building a long (minutes-long) stepper activation pulse waveform out of multiples wave trains without glitches due to improperly matched waveform segments is something that will work.

  • 1
    "Given that DMA is the way around the non-real-time Raspberry Pi..." -> I don't think this is exactly true, if you mean, you can guarantee complex timings controlled from userspace code. It may be the optimal approach in context, but it is still not carved in the way it can be via an MC like the Arduino dedicated to the task. These are very different tools with different strengths and weaknesses. – goldilocks May 30 '18 at 23:00
1

Steppers are typically driven by stepper driver boards such as the TMC2208. Microcontrollers such as Arduino or Raspberry Pi send pulses to the stepper driver boards to turn the stepper motor. I assume you have already acquired a motor hat or such.

For smoothness, it is ideal to have well behaved acceleration curves for the pulse train sent to a robotic arm so that it doesn't spaz itself to death. However, for peristaltic pumps, you would not need to worry about such curves since you can spread the motion out over time to reduce jerkiness. In fact, lowering the frequency of pulses will give you better torque (stepper torque disappears with speed). Therefore, all you would need is to send the computed number of pulses in a steady slow stream, where "slow" is a compromise between what works and your patience.

If there is a need to send a pulse train instead of a single pulse for each 1.8 degrees of motion, reconfigure your stepper board for microstepping (e.g., 256 microsteps). Then send K*256 pulses for each K*1.8 degrees of motion (provided 256 is your microstep factor).

  • I considered that and have modeled the behavior within the context of an overall process to maintain nutrient solution integrity. Unfortunately, because of mixing and measurement delays, along with pump precision issues, there is actually a time constraint as well as observability issues in development (as you pointed out!) Slow pulses are also noisy and EMI issues which the final product cannot have, so looking for a more sophisticated current-controlled microstepping solution. But we're off topic. I'm asking here about progress in providing PUL/DIR/SEL signals with the Pi! – Eric Novikoff Jun 1 '18 at 0:45
  • Eric, most awesome! I have plans to build my own Pi nutrient mixer. Regarding your noise reduction requirement, perhaps experimenting with microstep configuration might prove helpful (more microsteps, higher frequency). This would allow you to send a long bit banging pulse train of microsteps for each 1.8degree motion and perhaps control EMI with a capacitor. I.e., you'd always send multiples of 256 pulses. I use rpio and plan on simply banging out the individual bits this way. My plan B is to revert to Pi controlling Arduino/RAMPS over serial. Email for more detail. karl@oyamist.com – OyaMist Jun 1 '18 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.