Controlling stepper motor with atteched encoder


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Feb 2013
    Posts
    8

    Default Controlling stepper motor with atteched encoder

    Hi, I just tried, and failed, to post my first thread. Apparently I got logged out (maybe because I took 1.5 hrs to compile the message, kids, life, etc)

    Here is it, but shorter version:

    Hello, I am a newbie, trying to drive a stepper using encoder, need to be 100% sure where motor is at all times. I have steppers. . .lots of them, so really want to use what I have. . . .lot's of them :-)

    AVAGO HEDS-5545 encoders on Vexta 6 wire Stepper, driving as Bipolar
    I have been able to get the stepper moving just fine. . .slow, no speed ramping , but working just the same

    I am using the standard amazon driver "
    L298N Stepper Motor Driver Controller Board Module", happy to get something else if i need

    (http://www.amazon.com/gp/product/B00...0?ie=UTF8&psc=)

    To the chase, I am looking for a point in the right direction, I don't seem to be able to find any Pic-Basic code that shows the driving of a stepper, with encoder feedback. I am also looking to display the encoder info to a LCD (Jameco #618003 DISPLAY,LCD,PARALLEL,16X2)

    Here is a dump of my software/Hardware:
    Micro-code Studio Version 4.0.0.0
    MeLabs Programmer Version 4.50
    (Lab X-1 not that i am using it here, I just have it)
    I Have these MCU's:
    Pic16f877a
    Pic 18f452
    Pic18f458

    If anyone can point me in the right direction (if it's anything like my medicine cabinet when I need a band-aid. . .it's probably right under my nose. . .my wife says men can't find anything) I would really appreciate it. BTW, my coding skills are very aged, use to write stuff 20 yrs ago, 5 kids and 80 hr work weeks later . . . not so much).

    I truly appreciate any pointers, direction to look or otherwise, that I get from you fine folks. I also want to pre-thank people for not pouncing on me if in fact i am guilty of bad search engine skills, not lazy, just frustrated

    All the best
    John aka "Camcompco"

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: Controlling stepper motor with atteched encoder

    Hi John, welcome to the forum!

    How do you plan to feed the position value? By a keypad or via serial com.

    I have written a code for driving stepper motor (that was few years ago) and position was fed via serial com. The code didn't use close loop but I will be happy to modify it for reading the encoder and turn it from open loop to close loop system

    Let me know how many pulses per turn is your optical encoder and a little more on your project.

    Cheers

    Al.
    All progress began with an idea

  3. #3
    Join Date
    Feb 2013
    Posts
    8


    Did you find this post helpful? Yes | No

    Default Re: Controlling stepper motor with atteched encoder

    Hi Arrati (Al)
    first off, thanks for the quick comments.

    Well, i happen to have an idea for something that will have to move a given predefined distance in a pattern, not unlike out CNC friends, but my motions will be fixed from a given starting point, for example:

    Move (by rotating a acme lead screw) a table to the right (x-axis) 100mm, then forward vie a different stepper/encoder (y-axis) 25mm, stay there for 5 seconds, reverse the y-axis direction 25mm, go further right (x-axis) 50mm, repeat the y-axis movement as before, do this a few more steps (further x and y movements) then return to home, wait until something happens elsewhere (mechanical trigger from other event) and repeat entire process over and over.

    I plan on introducing sensors to actually trigger when the y-axis movements stop (they won't be 25mm always, they may be a function of a sensor (contact) being triggered, but the x axis movements will be constant.

    This has to be an independent system, no "PC" interface allowed. In essence, it has to be a self contained unit that contains MCU, motors and the ability to know if a step was missed to keep going to "predefined" location. I will also have to introduce contacts so the movement can stop when the appropriate y-axis movement has taken place. The encoder has 400cpr.

    thanks again!!!

    Also, thanks for the kind welcome!!

  4. #4
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: Controlling stepper motor with atteched encoder

    Hi John, I am posting a working snippet for moving a stepper controlled by an optical encoder. The encoder is fed to Timer1 which act as a 16 bits counter and using DT interrupt on overflow it will stop the motor when position is reached. I have commented the code but if something is not clear please just ask!.

    Hope you will find the code usefull as a base to start building your own.

    Cheers

    Al.
    Attached Files Attached Files
    All progress began with an idea

  5. #5
    Join Date
    Feb 2013
    Posts
    8


    Did you find this post helpful? Yes | No

    Default Re: Controlling stepper motor with atteched encoder

    Thanks for this. . .very excited to get home and give it a good look!!!
    simply great that you take the time out to help a chap thousands of miles away. . . . .

    I can't help but imagine that there are many others that will gain from this dialogue as well

    Again, thanks!!!!

    John (Camcompco)


  6. #6
    Join Date
    Feb 2013
    Posts
    8


    Did you find this post helpful? Yes | No

    Default Re: Controlling stepper motor with atteched encoder

    Sorry Al, maybe a dumb question here, but will I need to see these "include" files to understand things fully, just asking in the hopes that is the answer is yes you can attach them so when I get home i will better be able to look at things.

    INCLUDE "DT_INTS-14.bas" ; Base Interrupt System
    INCLUDE "ReEnterPBP.bas" ; Include if using PBP interrupts

    thanks again!

  7. #7
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: Controlling stepper motor with atteched encoder

    Those two include files can be downloaded from Darrel site @ http://www.darreltaylor.com/DT_INTS-14/intro.html
    Place both in the PBP folder.

    Cheers

    Al.
    All progress began with an idea

Similar Threads

  1. Motor Stepper Example
    By Melanie in forum Code Examples
    Replies: 134
    Last Post: - 3rd January 2015, 17:58
  2. Replies: 1
    Last Post: - 15th December 2010, 14:30
  3. Controlling stepper motor with PIC
    By The Master in forum Off Topic
    Replies: 3
    Last Post: - 1st July 2008, 10:21
  4. Stepper Motor Program
    By kiwipiper in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 27th November 2007, 02:56
  5. Stepper Motor troubles
    By Fryin in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 21st March 2007, 01:56

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts