584,805 active members*
5,223 visitors online*
Register for free
Login Register
HEIDENHAIN Forum
Open Source Controller Boards > PIC Open source Servo Driver Schematics development?
Page 1 of 5 123
Results 1 to 20 of 91
  1. #1
    Join Date
    Mar 2004
    Posts
    8

    Question PIC Open source Servo Driver Schematics development?

    Hi Everyone!
    I like this forum, it gives great advices about building machines, specially the meckanical part. What we need here is a good DIY servo driver. Of course open source schematics. The open source program is already available, Emc for instance. It is not wery likely that this gonna happen soon, but we have to push this idea around. Until money is in question, noone will give any half made
    servo driver projekt in public domain. But it will happen in near future, because the technological changes. Everything becomming more affordable. In July 2000 Nuts&Volts there was published a cnc retrofit for a small tabletop mill. The electronics uses Pic chips. From the picture I can see 3 chips, one marked as Pic. It talks about another converter board not pictured. They use Pitman motors14204 continous torq is 26onc/inch. More info is on www.jrkerr.com There is a software for serial port cnc retrofit.
    Now my question is, can it be made something simular, for first time with smaller motors and put in public domain?
    The first clock in the world was made in China in 10Th century. But only the story survived, because the emeror kept it secret. Lather in 15th century the Italians made a clock and a watch, which a monk took it to the Cheneese emperor. He was amused, they newer see anything like that. Since the first clock was made the industrial revolution started. Can you imagin the world here all the medicine would be available and free? It wouldn't be sick people.
    So lets start our industrial revolution in making an open source servo driver.
    Thank you for your support!

  2. #2
    Join Date
    Mar 2003
    Posts
    6855
    Welcome to the site.

  3. #3
    Join Date
    Apr 2004
    Posts
    169
    I have a half finished design I'm willing to contribute. Has been tested and works but needs more testing, a few rough edges smoothed over and documentation.

    Features: Avr microcontroller - much more power than a pic (1 controler can cope with 3 axises) and only a few dollars more.
    LCD and Key pad to enter PID values and jog without controller connected.
    Seperate driver board with 3 18200 hbridge driver chips giving 3 amps at 36 volts.

    Attached are Eagle PCB files for the Controller and motor driver boards. If there is any interest I'll rustle up the source code to go with them.
    Attached Files Attached Files

  4. #4
    Join Date
    May 2003
    Posts
    550
    the great thing about this site is that sooner or later at least two people have a similar idea.... and contribute.

    I've been playing with a pic based servo driver for a while. Microchip.com have Application notes on the subject. Still early days. Have a working board but no step direction input yet. Used 18245's so thats 3a 55v. I'll see if I can tidy it up a bit and put it here but It's not going to be of much use right now.

    Went down a dead end trying to use a stepper motor as an encoder. Got a small stepper and a pic to produce encoder signals from a turning 1.8 degree stepper, but it only works reliably for fairly slow speeds. After that it's a dirty signal which looses position, which defeats the object somewhat. A hobby priced source of encoders would be nice.

    One thing that was interesting while looking at J Kerr servo stuff and having the Microchip AN's with the sample circuits on the desk is that they're *very* similar. Maybe a product of the components but....

    Rutex appear to use the Pic in thier product too in much the same way.

  5. #5
    Join Date
    Jun 2003
    Posts
    125
    I'm very interested in a DIY servo controller. So Tachus42, I would love to see the source code and any info you would have to make reproduction easier. What is the max encoder pulse rate in your design? Oh, and if anyone wants me to host their controller design on my webpage, I would be more than happy do so.

    David B.

    www4.ncsu.edu/~dsbloomf

  6. #6
    Join Date
    Mar 2004
    Posts
    37
    I too have been playing and have completed a PIC based microstepping controller that I will be sharing shortly. I am just finishing up the Visual Basic front end that allows it to be programmed from the computer.

    For a DIY project I stayed away from any of the IC based chopper controllers and did everything discreetly. This way I am not bound to a maximum current. If I need more current I just up my FET rating. I am running my hardware on my prototype machine 60 V @ 8Amps. My board supports Unipolar / Bipolar steppers and a Servo motor with and encoder input. I have not played with servos yet but I too read the PIC article. I want to get servos working as well but I am not sure how the STEP/DIR inputs are used with a servo. Do people just actually use the servo like a stepper? A step pulse steps the servo one small increment.

    fyffe55 you are right that a small stepper is not good as a position encoder. It is too slow and the output stops when the motor stops moving. I posted earlier about using a small stepper as a jog encoder and in this mode it works great. I use the small stepper motor to replace a mechanical hand crank. Turn the small stepper motor and the axis moves the requested direction. Good for quick manual positioning without a computer connected. You can make a better position encoder by drilling a disc with a hole every 0.9 degrees and using an IR RX/TX pair. The encoder resolution can be increased by using a standard 4X decoding or gearing so the encoder wheel spins faster than the motor or both.

    As for the J Kerr board, one thing I learned a long time ago is that inspiration comes from many places and things will be copied if it will make money.

  7. #7
    Join Date
    Apr 2004
    Posts
    678
    Greg: Yes, it's quite common that servo drives take step/dir input. All I have does that. Internally it counts the desired-position value up/down based on step/dir. This means the drive must do the torque, velocity and position loops computations internally. With a voltage input drive often doing just the first or the two first.

    And the step/dir servo can take pulses at high speeds. If the motor is not able to follow, it will not loose the end position. It will just loose position on parts of it's journey there. Not like a real stepper where a lost step will never be regained. (Unless by chance it looses the same number of steps going in the other direction.)

    Here is a simple approach to the main components, except step/dir input: http://elm-chan.org/works/smc/report_e.html

  8. #8
    Join Date
    Mar 2004
    Posts
    37
    Thanks that makes sense ES. The motor will resolve its final position based on commanded number of steps, direction and the encoder feedback. I guess there is probably no need to set an acceleration profile in the computer front end, you just feed the step pulses as fast as the controller can accept. In my case probably only 80 KHz or 160 kHz. So to say it another way the controller uses the constantly arriving step pulses to dynamically set a position to reach and uses the PID algorithm to get there. Is there any type of feedback the controllers and PCs use so that the front end controller will stop sending step pulses until the commanded position is reached?

    ie goto x = 3, y = 2 then wait until it gets there before sending x = 4, y = 1

    I will read the document you mentioned.

  9. #9
    Join Date
    Apr 2004
    Posts
    169
    Ok source code for my servo controller in the attached file.
    It's probably not very clear whats going on at a first look - i didn't comment the code with other viewers in mind. Basically all the important stuff is handled by the interupt handlers at the top of pid.c. The SIG_OVERFLOW0 handler gets excuted at a 40kHz rate and reads the encoders and updates a 8 bit postion.
    The SIG_OVERFLOW2 handler runs at 400 Hz or every 2.5ms and transfers the 8 bit encoder and target counts into their 32 bit equivalents and then calls DoPID where the PID algorythm takes place and the PWM drive to the motors is updated.

    The SIG_INTERRUPT0-2 interrupts are excuted on the falling edge of a step pulse and read the corresponding direction input and update 8 bit target postion.

    The rest of the code Initialises the timers and Interrupts etc and Drives the LCD reads the keypad does the menu etc.
    Attached Files Attached Files

  10. #10
    Join Date
    Jun 2003
    Posts
    125
    tachus42,
    Do you want me to put this on my webpage so it can be referred to more easily? I am trying to learn as much as I can about AVR's, and this looks like a fun project.

    David B.

    www4.ncsu.edu/~dsbloomf

  11. #11
    Join Date
    Apr 2004
    Posts
    169
    David feel free to put it up on page jusr credit me, Stephen Dredge ( not that i think the code is that worthy)
    The code was compiled with the gcc-avr http://winavr.sourceforge.net/
    And I use pony prog to program the avr http://www.lancos.com/prog.htm with the (STK200/300) parallel port interface descibed on the pony prog page.
    The LCD Port will connect to a standard 2 * 16 LCD with a ribbon cable and the keypad is a 4*4 matrix.

  12. #12
    Join Date
    Apr 2004
    Posts
    678
    Quote Originally Posted by Greg Fill
    Thanks that makes sense ES. The motor will resolve its final position based on commanded number of steps, direction and the encoder feedback. I guess there is probably no need to set an acceleration profile in the computer front end, you just feed the step pulses as fast as the controller can accept.
    Yes, and no. Let's say you want to mill a large circle. Then you feed in all the pulses as fast as possible. The motors will start out in the right direction. But very soon the 'puter will be done feeding in all the pulses and the desired position will again be where it started. But the slow motors/mechanics will all the time try to move towards the desired position. So you will not get a circle, but just a small doodle.
    That's the "no". You need to wait out at least some of each incremental movement.
    The "yes" is that each incremental movement can be pulsed out as fast as your controller can receive them. As the pulses are not used to control the motor, there is little constraint in the timing. This makes it possible to put less realtime constraints on the PC doing the machine control task. It can output a bunch of pulses in succession, and do other computational tasks interrupting the pulse stream.
    Quote Originally Posted by Greg Fill
    In my case probably only 80 KHz or 160 kHz. So to say it another way the controller uses the constantly arriving step pulses to dynamically set a position to reach and uses the PID algorithm to get there. Is there any type of feedback the controllers and PCs use so that the front end controller will stop sending step pulses until the commanded position is reached?

    ie goto x = 3, y = 2 then wait until it gets there before sending x = 4, y = 1
    The feedback is up to you when you design the drive. You can implement a "move done" as a status output to the PC. But I use them in stepper-emulating mode. That means the PC thinks it feeds a stepper drive. And it calculates each move as for a stepper. But as I wrote, without the timing constraints down to the spacing of each step pulse. If using a move-done output on the drive, the control software must handle this. I don't know about others, but neither EMC nor Mach2 does this.

    One output you should have is a following error output. The drive knows the commanded and the current position. When the difference is greater than a configurable amount, you output a following error. The PC would typically use this as a fault input. It could mean that your axis have met a solid object along the path that should not have been there. Some following error must be allowed, as a PID loop with no error is an infinite improbability.

  13. #13
    Join Date
    Apr 2004
    Posts
    678
    Quote Originally Posted by tachus42
    It's probably not very clear whats going on at a first look - i didn't comment the code with other viewers in mind.
    I've had the doubtful pleasure of reopening my own code years later. That taught me to try to comment for other viewers. :frown:
    You might say I'm not the same as I used to be.

    Thanks for sharing the code. What device do you use?
    Myself I have a fairly full setup for older AVR's (STK500 + ICE200). But the only design that came past the qty. one breadboard stage was with ATtiny15 where the ICE will do nothing.

    Would it be possible to see the schematics in .PDF .GIF or some other easily viewable format?

  14. #14
    Join Date
    Apr 2004
    Posts
    169
    I used a Mega 162 for this design.

    Jpg's attached the schematic's aren't very clear but enough to give the idea, If you want a closer look google for and grab eagle - there is a free version that has become a bit of a defacto standard.

    I think that stepper emulation is the only sensible way to make a roll your own servo controller unless you really want to be a smarty pants. A modern pc is going to be able to a much better job of motion control than a puny microcontroller can.
    Attached Thumbnails Attached Thumbnails controller layout.jpg   controller schematic.jpg   driver layout.jpg   driver schematic.jpg  


  15. #15
    Join Date
    Jun 2003
    Posts
    125
    ok, it's all up on my webpage now for easy viewing. Tachus, if you have any pictures of your assembled board it would really help out. Right now the page looks pretty anemic

    http://www4.ncsu.edu/~dsbloomf/Steve...vo%20Drive.htm

  16. #16
    Join Date
    Apr 2004
    Posts
    169
    I must be one of the few people on the planet without a digital camera but give me a few days and I'll see what I can do.

  17. #17
    Join Date
    Mar 2004
    Posts
    222
    I don't know if you guys have seen this, I actually
    posted this before but here it is again.

    Just trying to contribute somehow.

    EDIT: I just found out it's already been posted, sorry!
    mhel
    "This is intentionally left blank."

  18. #18
    Join Date
    Jun 2003
    Posts
    125
    tachus,
    Any updates? As soon as you can get me some pictures I'll post them on my page with the rest of the info.

    Thanks,
    David B.

    www4.ncsu.edu/~dsbloomf

  19. #19
    Join Date
    Apr 2004
    Posts
    169
    Sorry for the low quality pic's it's the best i can do at the moment.
    Attached Thumbnails Attached Thumbnails 007.bmp   010.bmp   017.bmp   020.bmp  


  20. #20
    Join Date
    Jun 2003
    Posts
    125
    WOW, thanx alot. I'll post them on my webpage ASAP. I've been working on my own PWM output servo control with a friend since we felt it was easier than deciphering someone elses code. Right now it's running a servo just fine, but we still have to implement a little better Integral term algorithm and also figure out someway to calcualate the max encoder speed. Right now the encoder section is only 30 lines or so long in assembly and with the 4 or so clocks needed for the interrupt, it should be pretty fast. I also think we're gonna try some AVR overclocking to see just how fast these chips can run.....Keep you posted.

    David B.

Page 1 of 5 123

Similar Threads

  1. Open Source Driver electronics
    By pminmo in forum DIY CNC Router Table Machines
    Replies: 1
    Last Post: 11-22-2009, 09:42 PM
  2. Any ideas for open source CAM package?
    By galacticroot in forum OpenSource Software
    Replies: 26
    Last Post: 10-22-2007, 05:35 PM
  3. Open Source CNC Controller Specification
    By gregmary in forum DIY CNC Router Table Machines
    Replies: 28
    Last Post: 12-05-2005, 04:58 AM
  4. 2nd Generation DeskCNC servo driver released
    By imserv in forum News Announcements
    Replies: 0
    Last Post: 11-25-2004, 01:22 AM
  5. Open source driver designs
    By pminmo in forum CNC Machine Related Electronics
    Replies: 0
    Last Post: 05-05-2004, 03:29 PM

Posting Permissions

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