2

I have recently started trying to control stepper motors with the Raspberry pi I have succeeded in getting motion. The problem I am having though is that it seems the stepper motor is missing steps and operates very rough. I took my project to a local hacker space here in Chicago "Pumping Station One" to see if the CNC build club could help clue me in on the problem. Their opinion was that certain processes are taking priority and always executing that it may be causing the issue. I hooked my stepper up to an Arduino Uno and the stepper motor performed wonderfully. There was also mention of the Pi not having a RTC on it and the "delay()" function I use in my code for the pulse width might be getting out of sync. Has anyone experienced anything like this before? Is there anything you know of to test these theories? Maybe another explanation?

  • Check my question and answer regarding Realtime use in Pi, and its caveats (esp. the comments). You can't reliably do continuous PWM with RPi. You could get away with half-stepping, or 900ms long PWM sequences, but uninterrupted PWM = microstepping is out of your reach, unless you hack the Linux kernel to generate PWM for you. – SF. Oct 25 '13 at 13:13
1

don't even try to generate PWM pulses using RasPi.

instead, get any cheap microcontroller, connect it to RasPi over usb, i2c or serial and use it as a dedicated (multichannel?) PWM generator. I've build this to control servos from PC, works for RasPi just perfectly.

1

Linux is NOT a real time operating system.

  • It is event based and managed by a stack by either First In First Out or more rarely used Last In First Out.
  • The time it takes for the same event to repeat will always vary depending on the queue size.
  • It is a GPU that can render graphics independently from the secondary ARM, that runs the OS.
  • It has hardware to help with other things like, Audio, Networking and Universal Serial Interfacing. None of which help with real time operations.

Arduino is a micro controller that processes signals in real time.

  • It is entirely designed to read input and generate outputs precisely and in a timely fashion.
  • The hardware is tuned to react to a oscillating crystal so that each cpu cycle takes precisely the same amount of time as the previous one.
  • The MCU has allot of dedicated built in hardware that does specific tasks to help complete CPU cycles on time.
  • Even slight variations due to atmospheric changes won't be noticed by hobbyists and even many professionals.

And unfortunately the GPIO's on the Raspberry Pi are for educational purposes only. To learn programming and some engineering.

Combing the Arduino and Raspberry Pi is a match made in electronics heaven!

The cost of an Arduino, or an Arduino shield for the Pi (Like Alamode) and the Pi is still the cheapest option for a extremely powerful prototyping environment that can be used in production sometimes.

We are talking about prices under USD80 for a full operating system with network connectivity, GPU processing, USB interfacing AND real time MCU for all the specialist hardware requirements. If you look around and price together all the shields for an Arduino the price will exceed and you won't even have a third of the features.

Arduino is very easy to learn and has an abundant library of tutorials and code.

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.