Shop OBEX P1 Docs P2 Docs Learn Events
NEW Stepper Driver in Spin - 13.34 Revolutions Per Second — Parallax Forums

NEW Stepper Driver in Spin - 13.34 Revolutions Per Second

idbruceidbruce Posts: 6,197
edited 2011-01-09 10:18 in Propeller 1
Hello Everyone

I just want to say that I have been studying stepper motor documentation of all sorts for approximately three years, but within this last week, I really learned a lot about controlling the pulse input. I want to thank all those who helped me gain a better understanding of the Propeller, counters, and various other items. THANK YOU!!!!!!!!

Today I humbly submit a new sample for your viewing pleasure. It is a stepper motor pulse input driver. It will drive a 2000 microstep drive to rotate a stepper motor at a speed of 13.34 revolutions per second. That ought to make some of you stepper motor fans very happy. It is written entirely in Spin for your easy comprehension, but as JonnyMac recently educated me through example, this driver would be able to obtain greater speed if ported to PASM.

Bruce

Comments

  • John AbshierJohn Abshier Posts: 1,116
    edited 2011-01-08 16:19
    in updateTimer the line: waitcnt(clkfreq / TIX_DLY + cnt) ' do tix delay
    is not the best way. It introduces error while calculating the argument for waitcnt. See page 62 of Propeller Education Kit Labs: Fundamentals

    John Abshier
  • idbruceidbruce Posts: 6,197
    edited 2011-01-08 16:23
    John

    Look at the Copyright. That is Parallax code.

    Bruce
  • John AbshierJohn Abshier Posts: 1,116
    edited 2011-01-09 08:21
    The copyright is just a comment. The waitcnt is still an approximation. Page 60 of Propeller Education Kit Labs: Fundamentals is also Parallax code.

    John Abshier
  • idbruceidbruce Posts: 6,197
    edited 2011-01-09 09:40
    John

    I have documentation also. Parallax uses this type of example in a lot of their documentation. Please refer to the WAITCNT reference on page 325 in the Propeller Manual. I looked for your reference but you must be using an early version.

    Bruce
  • idbruceidbruce Posts: 6,197
    edited 2011-01-09 10:10
    John

    I found your reference in version 1.1, you should update to 1.2. Anyhow, yes it is stated that it introduces error. However, I truly have no desire to create a time clock or time keeping application. I just went to the OBEX, grabbed a timer, and through it in with my code to have a fairly reliable clock handy. If I want or need VERY accurate time, I would use a DS1302 or a DS1307 real time clock. For the the example code that I provided, I am sure that is sufficient for 99.999999% of the people that might look at it.

    Bruce
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2011-01-09 10:13
    Bruce,

    John is not saying you are to blame for that piece of code but is just stating a fact that it will produce an error, even if small. I am sure it is OK to use code like that in many applications, it just depends on the accuracy required by the user. I would try to understand why it might be a problem, it will be more helpful than defending that method.

    Graham
  • idbruceidbruce Posts: 6,197
    edited 2011-01-09 10:18
    Graham

    Okay, I agree. I don't see him actually blaming me for the code. And yes, PEKitLabs V1.1 does state that it introduces error. And yes, it should be considered when creating a time clock or time keeping application. And finally yes, I agree with your statement:
    it just depends on the accuracy required by the user

    Bruce
Sign In or Register to comment.