Electronic Dividing Head using the Arduino

Discussion in 'Software and Programming' started by cfellows, May 21, 2012.

Help Support HMEM by donating:

  1. Nov 10, 2012 #61

    cfellows

    cfellows

    cfellows

    Well-Known Member Project of the Month Winner

    Joined:
    Aug 26, 2007
    Messages:
    3,891
    Likes Received:
    701
    The short answer is yes, although accuracy is determined by the number of stepper divisions it takes to turn the work spindle one entire revolution. The more steps, the higher the precision and the higher the number of teeth that can be accurately cut. Mine consists of a 200 steps per revolution (sometimes referenced as 1.8 deg per step) coupled to the spindle through a timing belt and pulleys with a 1:5 ratio, which results 1000 stepper steps to complete one complete spindle revolution.

    This gives me dead on precision for any number which divides evenly into 1000. And it is probably close enough for any other number up to at least 50. Increasing the ratio will proportionately increase the number of teeth that can be accurately cut. For example, using a 30:1 worm gear would increase the overall resolution to 6,000. This would probably let you cut anything up to around 300 teeth accurately enough.

    Chuck
     
  2. Nov 11, 2012 #62

    chris

    chris

    chris

    Member

    Joined:
    Mar 13, 2011
    Messages:
    6
    Likes Received:
    0
    Chuck: Thanks for the reply. I went to my local Radio Shack and got the Arduino book. Which will keep me occupied for a few days. I am definately going to pursue this. Chris
     
  3. Nov 11, 2012 #63

    cfellows

    cfellows

    cfellows

    Well-Known Member Project of the Month Winner

    Joined:
    Aug 26, 2007
    Messages:
    3,891
    Likes Received:
    701
    Here is a great series of video tutorials for the Arduino... one of the best I've seen for beginners learning about it. It's a series of 12 or so videos, each pretty short but with enough detail to really help you understand what's going on.

    [ame]http://www.youtube.com/watch?v=fCxzA9_kg6s&list=PL2F6A9BCA925C1F18&feature=plcp[/ame]

    Don't forget the Arduino website which has a wealth of information, particularly these links:

    http://arduino.cc/en/Tutorial/HomePage

    http://www.arduino.cc/playground/

    I'm also more than willing to answer any questions (if I know the answer :confused:). Be careful, though. It's pretty easy to get wrapped up in a whole bunch of other projects which you may or may not have time for!

    One other note. Although I have no personal affiliation with this company, I find they are a good resource for Arduino accessories and electronic parts. Their pices are reasonable and shipping is fast.

    Chuck
     
    Last edited: Nov 11, 2012
  4. Nov 20, 2012 #64

    cwebs

    cwebs

    cwebs

    Well-Known Member

    Joined:
    Sep 12, 2012
    Messages:
    54
    Likes Received:
    13
  5. Mar 31, 2013 #65

    Limo

    Limo

    Limo

    Member

    Joined:
    Dec 15, 2012
    Messages:
    9
    Likes Received:
    1
    Hi Chuck,
    I've been reading your post on the dividing head and decided to follow your example. I know hardly anything about arduino and am starting to learn. I bought an Uno and the Sainsmart display and the pololu driver. I downloaded your text file and loaded it into my uno. It doesn't display the Div and Pos. All that pops up is 1000 and 14400 by using the up and down keys. And it resets good. Maybe I have to get the same board you used?
    Maybe the uno doesn't have the same pin arrangement? Any help you could give would be appreciated. And I greatly appreciate what you have contributed already. I'm going to be driving a sherline RT.(hopefully)

    Wil
     
  6. Apr 2, 2013 #66

    cfellows

    cfellows

    cfellows

    Well-Known Member Project of the Month Winner

    Joined:
    Aug 26, 2007
    Messages:
    3,891
    Likes Received:
    701
    Wil, you have everything you need and the program is working as I designed it. I use my Arduino not only to run my dividing head but also to run my motorized rotary table. The Dividing head has an overall ratio of 1000 steps per revolution and the rotary table has 14400 steps per revolution. So, the first screen that comes up wants me to select either 14400 or 1000 steps depending on which device it's running. The up and down cursor keys select the divisions and pressing the enter key then takes you to the next screen which displays divisions and position. You may have to modify the program for your own dividing head depending on what your gear ratio is and the number of steps per revolution of your stepper motor. Let me know if you have any other questions.

    Chuck
     
  7. Apr 2, 2013 #67

    Limo

    Limo

    Limo

    Member

    Joined:
    Dec 15, 2012
    Messages:
    9
    Likes Received:
    1
    Hi Chuck,
    Yes, the 14400 and 1000 come up on the screen by buttons but my select button does nothing. I will have to watch those videos again and try to figure this out. I don't have this hooked up to anything at this point right now. (except the computer)
    Thanks for replying to me.

    Wil
     
  8. Apr 2, 2013 #68

    de_das_dude

    de_das_dude

    de_das_dude

    Enthusiastic Beginner

    Joined:
    Mar 29, 2013
    Messages:
    6
    Likes Received:
    2

    unfortunately photobucket is a bad image host and none of the pictures are showing up! Even though i can view them after i copy paste their links into the address bar!

    please use imgur if you post any more pictures in the future :) !
     
    gdanielhoracio likes this.
  9. Apr 22, 2013 #69

    cwebs

    cwebs

    cwebs

    Well-Known Member

    Joined:
    Sep 12, 2012
    Messages:
    54
    Likes Received:
    13
    Hi Chuck. I have my Arduino rotary table working using your code but need to add debounce to the buttons. You had any problem with bounce? I am confused with the debounce code. Mostly because 5 of the buttons are realy only one button. Do you have any idea how to add debounce to the code? Thanks, Carl
     
  10. Apr 23, 2013 #70

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,125
    Likes Received:
    334
    Chuck, I know I am late to the party here but it might be worth checking the power specs on the Arduino you are using. When I last played with one, best practice was not to exceed 9 volts because the power supply has a limited life at 12 volts. You might be better off adding a voltage divider off your main power supply to reduce the voltage.

    Carl, plenty of stuff on denouncing. Here is one link. http://arduino.cc/en/Tutorial/Debounce
     
  11. Apr 23, 2013 #71

    cfellows

    cfellows

    cfellows

    Well-Known Member Project of the Month Winner

    Joined:
    Aug 26, 2007
    Messages:
    3,891
    Likes Received:
    701
    Hi Carl,

    There is already some debounce logic in the code. Here is the code snippet that reads the keys. The "delay(200)" command on about the 9th line down provides a 200 millisecond delay for the key to settle down. It's not the most sophisticated debounce logic, but has worked OK for me. I occasionally get a button read error, but that's pretty seldom.

    Chuck
     
    larry1 likes this.
  12. May 3, 2013 #72

    cwebs

    cwebs

    cwebs

    Well-Known Member

    Joined:
    Sep 12, 2012
    Messages:
    54
    Likes Received:
    13
    Hi chuck. It turns out that most of the bounce problems was not bouncing switches but dirty switches. I saw that when I pushed "Right" the divisions would change or the speed would change telling me that there was resistance in the switches changing the voltage divider readings. I got a can of contact cleaner and sprayed the crap out of the switches. That made a big difference and cleaned up the problem. I also got a new 1602 display and tried it. It also worked great. This is not the first time I have had trouble with these type of button switches. Keep your switches clean and covered. Carl
     
  13. May 24, 2013 #73

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,125
    Likes Received:
    334
    Chuck, I hope you don't mind me posting here but I have been playing with an Arduino to do this over the last couple of weeks making my own version of a table controller after getting inspiration for you.

    I finally got the menu system up and working last night but still a long way to go.

    [ame="http://www.youtube.com/watch?v=pFAD4D4-VJM"]http://www.youtube.com/watch?v=pFAD4D4-VJM[/ame]

    I have included an SD card in the mix and hope to be able to build in scripting functionality. I played with a Polou stepper driver but thought my stepper was missing steps when it got hot so I have got a Gecko G251X 3.5 amp controller which I will fire up soon.
     
    larry1, malcolmt and gld like this.
  14. May 26, 2013 #74

    cfellows

    cfellows

    cfellows

    Well-Known Member Project of the Month Winner

    Joined:
    Aug 26, 2007
    Messages:
    3,891
    Likes Received:
    701
    Hey Rod, not a problem. Glad you got something going. The pololu driver does need a heat sink and/or fan cooling. I made a heat sink for mine and never had a problem after that.

    I have great big stepper that I'm going to attach to an Arduino one day and it will require a much bigger stepper driver. First I need to figure out what I'm going to use it for.

    Chuck
     
    malcolmt likes this.
  15. Jun 8, 2013 #75

    cwebs

    cwebs

    cwebs

    Well-Known Member

    Joined:
    Sep 12, 2012
    Messages:
    54
    Likes Received:
    13
    Hi, Chuck. I have finished my Rotary Table project and finaly solved the bounce problem. I tried three differant keyboards and had problems with internal resistance and bounce . Found some
    code that finaly worked. Here is the new code I used.
    Code:
    int read_LCD_buttons()
    {
      adc_key_in = analogRead(0);      // read the value from the sensor 
      delay(5); //switch debounce delay. Increase this delay if incorrect switch selections are returned.
      int k = (analogRead(0) - adc_key_in); //gives the button a slight range to allow for a little contact resistance noise
      if (5 < abs(k)) return btnNONE;  // double checks the keypress. If the two readings are not equal +/-k value after debounce delay, it tries again.
      // my buttons when read are centered at these valies: 0, 144, 329, 504, 741
      // we add approx 50 to those values and check to see if we are close
      if (adc_key_in > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result
      if (adc_key_in < 50)   return btnRIGHT;  
      if (adc_key_in < 195)  return btnUP; 
      if (adc_key_in < 380)  return btnDOWN; 
      if (adc_key_in < 555)  return btnLEFT; 
      if (adc_key_in < 790)  return btnSELECT;   
      return btnNONE;  // when all others fail, return this...
    }
    
    Here are some pictures of the control box.
    http://i268.photobucket.com/albums/jj30/cwebs_photos/004-1.jpg
    http://i268.photobucket.com/albums/jj30/cwebs_photos/001-4.jpg

    There are three switches. Power, Enable, and Reset. I hid the reset next to the fan out of the way.

    I am running the pololu driver using a NEMA 17 Stepper running 1.25 amps. 2:1 into the 8 inch turntable at 72:1. Sounds small but is working very well. I loaded the table with 70# and it turned it with no problems.
    In the back of the box you will see a plug I added to be able to reprogram the chip from the Arduino board. No chip in the Arduino.

    The power supply is a computer psu conected to the 12 volts. I found that if there is a short the psu will shut down fast enought to prevent damage. Don't ask how I know, but, I'll bet your first guess will be right.
    Thanks for the code. I will never be good at coding but I learned alot of code from this project. Carl
     
    larry1 and malcolmt like this.
  16. Jun 8, 2013 #76

    gcude

    gcude

    gcude

    Member

    Joined:
    Jan 9, 2012
    Messages:
    10
    Likes Received:
    0
    Thanks for your update Carl. I look forward to trying your code. I got a SainSmart clone and I'm having trouble with bounce on the keys as well, so hope this works for me as well.

    Gary
     
  17. Jun 8, 2013 #77

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,125
    Likes Received:
    334
    Your control box looks awesome!

    It is not good practice to use delay() as it is a blocking code so nothing happens for the duration. That can create problems. You should save the time with millis() and the last key press in global or static variables and then write some code something like
    Code:
    now = millis();
    if ((now <= lastime + bouncedelay) && adc_key_in == adc_prev_key ){
      return btnNONE;
    else{
       lastime = now;
       adc_prev_key = adc_key_in;
    }
    // rest of code follows
    
    I gotta figure this out and add it to my own code.... This probably has bugs as it stands.
     
    larry1 and malcolmt like this.
  18. Jun 9, 2013 #78

    cwebs

    cwebs

    cwebs

    Well-Known Member

    Joined:
    Sep 12, 2012
    Messages:
    54
    Likes Received:
    13
    Thanks Rod for your comment. However, I don't understand your code as to what it does. I am an old man and while I am a very capable guy C/CPP is my weakest link. As for the code change in my setup I copied it from some one else. It came with a LCD/keypad. Because this code had to be added it tells me this is a common problem. I tried two LCD/keypads and the keypad that I am using and had button press problems with all three.

    BUT, it did get my setup working with no errors as of yet. Until I understand coding better I will have to set buy and wait that delay(). LOL

    Thanks again, Carl
     
  19. Jun 9, 2013 #79

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,125
    Likes Received:
    334
    Carl, delay() will probably work fine. You can run into problems because everything stops when delay() is running so if you are trying to do two things at once using interrupts this can pose a problem. The better alternative is to read the time using millis() which returns the number of milliseconds since reboot and just do nothing until the time period expires. Here is the official Arduino example of denouncing inputs using this method I tried to outline.

    http://arduino.cc/en/Tutorial/Debounce

    In your case, I was trying to return when the debounce delay was not expired before you code was processed to simplify code modifications.

    I will add that using delay() was never good practice on any platform, not just Arduino but it is convenient!
     
  20. Jul 28, 2013 #80

    vidio1

    vidio1

    vidio1

    Active Member

    Joined:
    Aug 9, 2011
    Messages:
    26
    Likes Received:
    2
    I need a little help please. I'm a first time user of an Arduino so bear with me. I have a Uno, Sainsmart LCD shield, but i'm trying to use an H-bridge stepper driver. It uses 4 wires instead of 2 like the Pololu. I tested it through the LCD shield using "stepper_onestepatatime" from the Arduino library. I used pins 2,3,12,13. It works as it should. I thought it might be a simple matter of just adding another "#define stepGo and #define stepDir" to the shetch. No such luck. The LCD program works, but it just causes the stepper to buzz until it gets to where it would go if it were moving, if that makes sense. What else would I need to change? Attached is a copy of what the 2 lines I've added.

    View attachment rotary_controller_copy.zip
     

Share This Page