Electronic Dividing Head using the Arduino

Home Model Engine Machinist Forum

Help Support Home Model Engine Machinist Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.
Chuck: having little knowledge of Electronics etc. Am I correct in assuming that if I obtain all the stuff mentioned in this thread and ask many questions. I will eventually have something which will give me fairly precise divisions for cutting clock wheels. I know I have over simplified this ,but am interested.
Chris

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
 
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
 
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

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:
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
 
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

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
 
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
 
I've made some strides on my Arduino powered dividing head the past few days. Here's a little background for what I am doing. First, the Arduino micro controller.

db5e6546.jpg


Available online for under $30, has 32K memory, numerous analog and digital inputs and outputs, including serial and PWM.

Next, the Sainsmart LCD display and keyboard shield

b829d9dc.jpg


This board is called a shield because it is pin compatible with and piggybacks right on top of the Arduino board. It has a 2 line x 16 character display and 5 input keys plus a reset. The keys are configured like the cursor keys on a PC having a left, right, up, and down as well as a select. So, with this shield in place, the microcontroller can be used with only a power supply and doesn't have to be tethered to a computer. The keys provide input and the LCD provides the display.

Here is the Sainsmart shield mounted on the Arduino...

f89430c6.jpg


The Sainsmart gets its power from the Arduino.

Another picture

93e96bf4.jpg


The Arduino is programmed by hooking it up to your PC through a USB cable. This also provides power to the Arduino board. A free programming environment is available for the PC and allows you to develop programs in a language that looks almost exactly like C. There are a host of standard libraries for interfacing to LCD's, keyboards, wireless, serial devices, and others. You write the programs and compile them on the PC. The compiler then automatically downloads the program to your Arduino. Once the program is loaded on the Arduino, you can decouple it from the computer and run it off a separate power supply from 9 - 12 volts. The program will stay in the Arduino memory even when the power is switched off.

423c8d56.jpg


So this is the basis for controlling my electronic dividing head. The up and down arrow keys will be used to set the number of divisions I want, then the left and right arrow keys will be used to step forward or backward one division at a time. The program I have written will calculate the number of stepper steps need for each division and keep track of the position I'm on. The display shows the number of divisions and the current dividing head position.

I have purchased a stepper driver board that is about the size of a postage stamp and will power a stepper of up to 2 amps, 35 volts. I still have to select the stepper motor I want to use and build the mechanical part of the dividing head. Still have a few challenges ahead of me.

Chuck


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 :) !
 
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
 
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.

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

Carl, plenty of stuff on denouncing. Here is one link. http://arduino.cc/en/Tutorial/Debounce
 
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

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.

/********************* read the buttons **************************/
int read_LCD_buttons()
{
adc_key_in = 0;
do
{
adc_key_in = analogRead(0); // read the value from the sensor
} while( adc_key_in > 1000 );

delay(200); // Debounce delay

// 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 < 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 btnERR; // when all others fail, return this...
}

Chuck
 
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

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
 
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.
 
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
 
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
 
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
 
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.
 
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.

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
 
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!
 
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
 
Back
Top