587,080 active members*
2,460 visitors online*
Register for free
Login
Results 1 to 10 of 10

Threaded View

  1. #1
    Join Date
    Jan 2011
    Posts
    0

    Linistepper in C

    Hi,

    I've been dreaming for a long time to change some linistepper code just to add a few "features".
    But, i'm nowhere an expert in PIC assembly.
    So, i decide to rewrite linistepper to C. Thanks to Roman Black for good code commenting, making me who's bad in assembly can easily rewrite the thing in C :cheers:

    Whats changed:
    - Move high/low power table from code to EEPROM lookup
    - Ignore ENABLE pin input.
    - Use step signal timeout to switch between low and high power.
    - Store stepping table to EEPROM.
    - Use inline assembly for pwm loop (maintains 333kHz pwm)
    - Disable runtime stepping mode change.
    - Stepping mode is initialized on startup only to improve calculation time between step.
    - Use quadrature input instead of STEP/DIR

    Simply put, this version will drop motor current after ~1 second if there is no signal received in that timeframe. Motor current will go to full power when next stepping is received.

    This 1 second timeout is changeable in source code.

    This linistepper-c also support quadrature input (Phase-A and Phase-B)
    From EMC2 manual:
    type 0: step/dir
    Two pins, one for step and one for direction. make-pulses must run at least twice for each step (once to set the step pin true, once to clear it). This limits the maximum step rate to half (or less) of the
    rate that can be reached by types 2-14. The parameters steplen and stepspace can further lower the maximum step rate. Parameters dirsetup and dirhold also apply to this step type.
    type 2: quadrature
    Two pins, phase-A and phase-B. For forward motion, A leads B. Can advance by one step every time make-pulses runs.
    The good thing with quadrature is your step can be as fast as your parallel-port. With step/dir, each step need to toggle between '1' and '0', so speed is cut by two.

    Also, it's possible to detect a single miss steps with quadrature, as it is a form of Gray-code.

    Btw, the step/dir code is also included in zip, but it's never tested.

    The bad things:

    1) The source code looks "hack"ish. This is due to:
    - My incompetence
    - SDCC workaround.

    2) The code generated by SDCC is slow. It insert BANKSEL instruction every here and there. I've included hand edited assembly generated by SDCC to remove this unnecessary call, just as an example on how to improve further.

    3)It's slower than the original linistepper in asm.
    With linistepper-asm, there's only ~20us delay before it output a new motors' current value.
    With SDCC compiled code, there's around ~50us before it output a new motors' current value.
    By editing the sdcc code and remove unneeded BANKSEL, "thinking" time now drop from 50us to ~30us.

    4)It might have bugs.
    This software is still untested by many, so there's probably a few bugs creeping inside. If you find any, please update it here so we can share the fixes.

    Thanks in advance.
    Attached Files Attached Files

Similar Threads

  1. Linistepper new board
    By salvado in forum Open Source Controller Boards
    Replies: 26
    Last Post: 05-20-2016, 12:33 AM
  2. My linistepper-a true GEM
    By student1616 in forum Open Source Controller Boards
    Replies: 0
    Last Post: 12-02-2008, 05:59 PM
  3. FYI Linistepper Experience
    By flyboy1015 in forum DIY CNC Router Table Machines
    Replies: 6
    Last Post: 11-12-2008, 10:38 PM
  4. 'Lil Linistepper Lathe
    By epineh in forum Mini Lathe
    Replies: 37
    Last Post: 02-24-2008, 03:03 PM
  5. Linistepper
    By tante in forum Open Source Controller Boards
    Replies: 7
    Last Post: 12-19-2005, 04:24 PM

Tags for this Thread

Posting Permissions

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