PIC-Based Step Generation With Linear Acceleration?

Page 1 of 7 1234 ... LastLast
Results 1 to 20 of 140

Thread: PIC-Based Step Generation With Linear Acceleration?

  1. #1
    Member
    Join Date
    Feb 2006
    Location
    USA
    Posts
    7063
    Downloads
    0
    Uploads
    0

    Default PIC-Based Step Generation With Linear Acceleration?

    Has anyone implemented a good step pulse generator with linear acceleration on a PIC? If so, what kind of step rates can you achieve with a 20MHz PIC?

    Regards,
    Ray L.

    Similar Threads:


  2. #2
    Registered
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    607
    Downloads
    0
    Uploads
    0

    Default

    Well it depends on many factors such as how many axis to move, how far... etc. If it is for single axis or rapid movement, then around 25khz. If you want multi axis movement, you will probably end up at around 15-20khz.

    It also depends on how you program the thing. I'm doing it with assembly all the way.

    PS. forgot to mention that this estimate is for a PIC18. PIC16 would use much longer time as it doesn't have a multiplication instruction.

    Last edited by The Blight; 12-01-2010 at 05:34 PM.


  3. #3
    Registered
    Join Date
    Oct 2005
    Location
    Australia
    Posts
    2392
    Downloads
    0
    Uploads
    0

    Default

    You can do a steprate at 39062 Hz on a PIC 18 with the interrupt every 256 instructions.

    If you are good enough to do 3axis acceleration math *and* control everything with an int of 256 instructions... Well that's a different matter.



  4. #4
    Registered
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    607
    Downloads
    0
    Uploads
    0

    Default

    So far I can do 2 axis in about 250 instructions. 3 axis takes about 400. This is with a maximum amount of steps at 2^32, and up to 2^16 steps per unit.



  5. #5
    Registered
    Join Date
    Oct 2005
    Location
    Australia
    Posts
    2392
    Downloads
    0
    Uploads
    0

    Default

    Is that with all the linear acceleration ramps running?

    I did it with full 3 axis and receiving serial comms on a 18F2221 but it was tight as heck, I had to use some inline assembler and some clever old-school tricks too. It's not for the faint hearted.



  6. #6
    Member Khalid's Avatar
    Join Date
    Apr 2006
    Location
    Pakistan
    Posts
    3498
    Downloads
    0
    Uploads
    0

    Default

    Hi Roman,
    sometime i wish if i had a knowledge like you..

    http://free3dscans.blogspot.com/ http://my-woodcarving.blogspot.com/
    http://my-diysolarwind.blogspot.com/


  7. #7
    Registered
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    607
    Downloads
    0
    Uploads
    0

    Default

    With acceleration on all axis at the same time. And feedrate adjustments (10-100%).

    Because I'm writing everything in assembly, I can tailer the routines for a specific task.

    I'm using a SD card for programs with FAT16 support.

    I have been working on this project for several years now. About 2 times a year I get really inspired and work 8+ hours per day on it for a couple weeks. After that I'm pretty exhausted (it keeps me awake at night), and I end up getting so tired of it that I have to find something else to do for the next 6 months or so.

    One day it will get done!

    Roman, did you post your project here on the zone? I believe I have seen 2 or 3 projects of that kind.



  8. #8
    Registered
    Join Date
    Oct 2005
    Location
    Australia
    Posts
    2392
    Downloads
    0
    Uploads
    0

    Default

    Hi Khalid! I've seen your web pages, you have lots of specialist skills too!

    The_Blight- Doing SD and FAT16 in assembler is pretty hardcore. And I hear you re the getting burnt out thing, I'm sure we've all done that on some jobs when after a few days you just can't stand to look at it! These days I mainly do embedded in C with some inline assembler of the speed critical parts.

    Here's the link to my machine build, there's not a huge amount of info on the electronics but you may find it interesting;
    http://www.cnczone.com/forums/cnc_wo...ll_router.html

    I threw the PIC18 3 axis controller together in a couple of afternoons work, but then I didn't have to do SD and FAT16 with it, just some serial comms and safety routines.

    I'm curious what your 2-axis controller is for? If it's for a PNP machine I have recently started a build for one myself;
    http://www.cnczone.com/forums/rc_rob...p_machine.html



  9. #9
    Registered
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    607
    Downloads
    0
    Uploads
    0

    Default

    Saved your link for later reading Never seen your build before, so I will enjoy it.

    About SD and FAT16, it takes quite a bit of reading to get it to work properly, but it was quite fun too. The sad thing is that I don't make many comments the first time through. So the second time I opened the thing, I had no idea what I had done. After that I made a lot of comments and files explaining whats going on. That takes as much time as the programming itself, and so this is moving along quite slowly. I'm not a programmer at all, and so everything that I know, I have thought myself. I'm pretty sure that if someone doing this for a living saw my code, they would be scratching their head and wondering what the hell I have been thinking. Hehe.

    Now I'm done with all the math routines I will be using except 64-bit square root (did 24-bit but found out that it was not good enough, and had to be expanded for 64-bit and I just got tired of the thing).

    It is actually a 4 axis cnc controller, with 2 spindle controllers. Its for my lathe and mill.

    Nice pick'n'place project! I'm going to be following that one with great interest! I have an engraving machine for PCBs which I had an idea of using as a PNP machine, but never really got anywhere with it.

    Do you still use your controller?



  10. #10
    Registered
    Join Date
    Oct 2005
    Location
    Australia
    Posts
    2392
    Downloads
    0
    Uploads
    0

    Default

    Yep my controller is the main brain inside my CNC machine, it gets used a few times a week.



  11. #11
    Registered
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    607
    Downloads
    0
    Uploads
    0

    Default

    I actually noticed while reading through your topics. Quite impressive builds! Seems like you have some of the same plans as me with this project.



  12. #12
    Gold Member
    Join Date
    Mar 2003
    Location
    United States
    Posts
    2839
    Downloads
    0
    Uploads
    0

    Default

    I use an Actel FPGA for the actual step pulse generation. A PIC24F generates 16-bit velocity commands and an SPI interface feeds them to the FPGA. The FPGA generates interrupt timing back to the PIC to have it update the FPGA with new velocity words every millisecond. This allows for a comfortable 16,000 instructions between ISR updates. The velocities (32K CW and 32K CCW) are evenly spaced because the FPGA produces a frequency directly proportional to the velocity command word.

    Mariss



  13. #13
    Registered James Newton's Avatar
    Join Date
    May 2005
    Location
    USA
    Posts
    1397
    Downloads
    0
    Uploads
    0

    Default

    Ok, so I'm wanting some small uC code to translate 3d lines into step and direction signals for a 3 axis CNC machine and there just doesn't seem to be any... so I'm writing it. Feel free to follow along, post comments, tell me about the syntax error I haven't noticed yet or generally why it won't work and could be done better. It's in a google doc so I can work on it from anywhere; you should be able to view it by clicking on this link:

    docs.google.com/document/d/1HapqposfsgFGLqbPkxlH6VZ2aw7lSAqmXmIXz959Sy4/edit?hl=en

    let me know if you can't see it...



  14. #14
    Registered James Newton's Avatar
    Join Date
    May 2005
    Location
    USA
    Posts
    1397
    Downloads
    0
    Uploads
    0

    Default

    The code is pretty close to working for the case of lines where the X movement is largest. There is a problem with stopping distance calculation. X velocity and Max acceleration should return to there original values at the end of the line and they are overshooting. Any advice appreciated.



  15. #15
    Gold Member
    Join Date
    Mar 2003
    Location
    United States
    Posts
    2839
    Downloads
    0
    Uploads
    0

    Default

    A simple idea is to store the distance taken while accelerating. Once the distance left to go is equal to or less than this value, it's time to decelerate. Force velocity to zero when distance to go is zero. This works so long as the accel and decel slopes are symmetrical.

    A more complex method (allows for accel, velocity and destination to be changed on-the-fly) requires a continuous calculation of a 'predictor' velocity at which deceleration must begin for a given rate of accel. This involves continuously solving a quadratic equation though. :-)

    Mariss



  16. #16
    Registered James Newton's Avatar
    Join Date
    May 2005
    Location
    USA
    Posts
    1397
    Downloads
    0
    Uploads
    0

    Default

    Yeah, if you look at the code, that first method is what I'm doing. I sum up the change in velocity to a variable called sd and when I have fewer than that many steps to travel, I start undoing the changes I made. But for some reason, I'm undoing more than I do...



  17. #17
    Gold Member
    Join Date
    Mar 2003
    Location
    United States
    Posts
    2839
    Downloads
    0
    Uploads
    0

    Default

    See if this flowchart helps. The diagram has 4 states, accel, run at constant vel, decel and stopped. It's what I came up with when I designed the G100 so I know it works.

    Mariss

    Attached Thumbnails Attached Thumbnails PIC-Based Step Generation With Linear Acceleration?-moveaxis-gif  


  18. #18
    Registered babinda01's Avatar
    Join Date
    May 2003
    Posts
    42
    Downloads
    0
    Uploads
    0

    Default

    Hi Guys,

    I have been contemplating a similar project for some time now, and because I am a very accomplished procrastinator, I haven't really got anything to show for my efforts.
    What I have been thinking is along the lines of the early NcPod, the Gcode is compiled on the PC to achieve 1mSec "blocks" of "go to this coordinate" commands, all the ramping etc is handled by the pc's gcode compiler. To take further load off the micro (I was thinking of the Propeller chip by Parallax) I was thinking to modify the gcode compiler further to output pure steps to move in the 1mSec period. I was thinking there are a few advantages to this method - there are a few sources of good gcode compilers based upon the EMC code (look at code.google.com) so a lot of gcodes are implemented. The complete compiled gcode file could be stored on a sd card on the micro's board or could very easily be buffered to the micro in a few different ways from the hoast pc, personally I prefer the sd card as the system could then run without a pc.

    Just my thoughts.

    Andrew



  19. #19
    Registered James Newton's Avatar
    Join Date
    May 2005
    Location
    USA
    Posts
    1397
    Downloads
    0
    Uploads
    0

    Default

    Hi babinda01,

    That is exactly what I want to accomplish with my code; with the exception that I don't really understand the "1mSec block" part of your comment. The link I posted above is to code that does now run some lines from point a to point b in 3 dimensions with step and direction signals from a microcontroller.

    Left to do is debugging, and some means of communicating those points to the uC from the PC. I was thinking of using the minimal G1 command (is it G1? It just specifies the next waypoint) as the protocol. That would make it easy for people to understand.

    You would want to add an SD card interface, but that could be done... code for the purpose is available. See the "See also:" links on this page:
    techref.massmind.org/techref/mem/flash/sd.htm



  20. #20
    Registered babinda01's Avatar
    Join Date
    May 2003
    Posts
    42
    Downloads
    0
    Uploads
    0

    Default

    Hi James,
    What I am thinking, is that you don't even have to worry about ramping on your micro, all the ramps have been taken into acount in the gcode compiler, and you are just telling the micro to issue x amount of steps in this mSec, and all these blocks of steps per mSec are pre compiled to the sd card.

    Andrew



Page 1 of 7 1234 ... LastLast

Posting Permissions

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


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

PIC-Based Step Generation With Linear Acceleration?

PIC-Based Step Generation With Linear Acceleration?