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

The LCD program, which I wrote, requires a stepper controller. A stepper controller provides all the logic necessary to energize the motor coils in the proper sequence and polarity to make it turn in the desired direction. Most stepper controllers also provide current limiting so you don't need to use a specific voltage to get the proper current through the stepper. All the LCD program does is tell the stepper controller when to turn the motor 1 step and in what direction.

Example:

1. Set direction to Forward.
2. Step

The H-Bridger driver is a much lower level device and requires the arduino sketch to provide the stepping logic to the individual coils in the proper sequence to make the motor turn. All the H-Bridge does is amplify the voltage/current and set the voltage polarity. The arduino has to individually tell the H-Bridge which coil(s) to energize and in what polarity.

Example:
1. Energize Coil A, forward.
2. Energize Coil B, Forward,
3. Energize Coil A, Reverse.
4. Energize Coil B, Reverse.
5. Etc...

This is just an example and is not necessarily the right sequence. A different sequence is required to make the motor turn the other direction. You would have to modify the LCD program to incorporate the forward and reverse logic from the "stepper_onestepatatime" sketch to make it work.

Chuck
 
Well that would certainly make sense. I guess I should have said first time Arduino and stepper user, but that was probably evident. Looks like I need to learn some C. Thanks again for the reply and sharing your sketch.
 
If you are truly interested in learning C, in figuring out how to make steppers work at a low level, and expanding your knowledge of steppers and electronics in general, modifying the LCD program and getting it to work would surely be the way to go.

On the other hand, if your main goal is to build an Arduino controlled dividing head, it would be far easier to simply buy the Pololu (or equivalent) stepper controller for under $12 + shipping and hook it up. That is, assuming your stepper motor will run on about 1.5 amps...

http://www.pololu.com/catalog/product/2128

No changes to the LCD program would be necessary, although I do have a newer version that is a little more user friendly.
 
I thought about getting the correct driver just to have it working, and probably will. About 8 or 9 years ago I started with an Oopic microcontroller, not sure if you've heard of them or not.

Anyway I was just getting started with it when I was deployed to Iraq. Long story short, by the time I came back from Iraq support had fallen off to next to nothing. There were some internal issues with the company and it dissolved. It made trying to learn from scratch all but impossible. I tossed it and all the sensors, breakout boards, motors, etc. in a small tote in stuck it on a shelf in the garage.

I've been looking for an excuse to get back into microcontrollers and have been looking at the Arduino for about a year or so, just to make sure this one doesn't fall by the wayside. Your project was the scapegoat I suppose.

It's easy enough to copy a sketch someone has made, but I still don't know enough about the nuts & bolts of why it works like it does. I need to learn at least some C if I'm ever going to.

I've been watching a video series on C++ that's about as Noob friendly as it gets, so I'll pursue that until I know enough to be able to ask an intellegent question.........

Thank again.
 
All of your Oopic sensors and such should be useable with Arduino.

Learning C++ is a worthy goal, but thats a big jump to start. I would start by learning more about Arduino and its programming. There is a HUGE amount of good material on the net for free. The Arduino is programmed in something that is very close to C, but with all the tedious stuff removed

I think one of the best ways to learn is to pick some existing program that you have an interest in, and the dividing head wold be a good one, and read it and study it until its clear. Then try to add some improvements to it. Its lots better to start with a working example than a blank sheet.
 
Being a professional software engineer I have learned more programming languages then I can count, several of them not even in use anymore. Almost all of them I learned through self-study. I agree with Ron the quickest way to start is to read other people's code and figure out what they did while at the same time having a basic reference book on the language near by,
 
cfellows sorry for the thread hi-jack. I'll leave it with this;

I chose the Arduino because it has a ton of support. There are shields and sketches everywhere I look. That's probably the single most important thing to have for someone getting started, short of a mentor standing over your shoulder.

Almost all microcontrollers can use a version of C for programming. If I can learn enough to be usefull it will make it easier to program almost anything I might pickup in the future. I have some lofty future goals that include an Autonomous rover with multiple controllers talking to a main controller to get things done. There seems to be more free learning resources for C++ than most others worth learning. These are the reasons for my choice of C++.

I've actually been looking over sketches, changing bits here and there to see how and what it changes. That's helped get my toes wet. I believe I'm going to buy a programming Arduino book written by Simon Monk. After looking at a few Arduino books I think his might be a decent starting point.

There are a few projects out there using the Arduino that might make a contribution to this site if there were a sub-forum available. I've seen digital scale readers, a DRO, electronic lead screw, and of course this dividing head. Just an idea.
 
C is just another language, C++ just extends it by adding Object Oriented Programming (methods, classes etc). If I mention C below it includes C++.

I think the main thing to understand with learning a new programming language is to get your head around the normal programming constructs (if, do..while, while, switch, if/else, how functions and procedures work.

The next most critical part of learning C is to get your head around pointers and also pointers to pointers. The most useful tip I have read is to think of an * as being a star and when you see it it means the variable starred (stored) at that memory location. Once you get this and how it works with pointers to structures you will set the world on fire. Once you grasp these basics, you can move on to the more advanced concepts of C++ and define classes and their methods. Pull down some open source code like Ghostrscript and work your way through some of the code until you understand what is going on.
 
I have the program set up to work with my rotary table which is 72:1 or my dividing head which is 5:1. The program can easily be changed to work with any ratio and stepper motor combination. Have you tried to load and compile the progam yet? You can download the IDE here:

http://arduino.cc/hu/Main/Software

You can compile programs without an Arduino attached. It will just give you an error when it tries to upload the code to the Arduino.

Chuck

Chuck,

Very nice work, but I have a question if I may, if I wanted to modify your program to use with a 40:1 dividing head and a 90:1 rotary table which variable/s would I need to alter?
is this change correct:

#define stepperDiv 8000.0 // Stepper Resolution
#define rotaryDiv 18000.0


Regards

Paul
 
Chuck,

Very nice work, but I have a question if I may, if I wanted to modify your program to use with a 40:1 dividing head and a 90:1 rotary table which variable/s would I need to alter?
is this change correct:

#define stepperDiv 8000.0 // Stepper Resolution
#define rotaryDiv 18000.0


Regards

Paul

Yes, assuming your stepper motor has 200 steps per revolution. Unfortunately, my program doesn't use ramped acceleration and deceleration so you can probably grow a beard while waiting for that rotary table to reach the next stop... ;D.
 
Thanks Chuck,

Perhaps for the dividing head only then!

Many Thanks

Paul
 
Hi Chuck, i think i have missed something from the thread. Do you have a wiring diagram for the driver to the Arduino Uno. I have the sainsmart setup and single axis tb6560 driver.

Thanks

Paul
 
Hi Chuck, i think i have missed something from the thread. Do you have a wiring diagram for the driver to the Arduino Uno. I have the sainsmart setup and single axis tb6560 driver.

Thanks

Paul

Here's the wiring diagram...

ArduinoDividingHead_zps4ea6ffa1.png


Hope this helps...

Chuck
 
Thanks Chuck that helps me out a lot. The Reset/ Sleep connection is that just specific to pololulu driver? i.e i don't need to worry about that with my TB driver?

Thanks

Paul
 
Chuck,

I have been following your various builds with interest over the last 6 months or so. I am interested in making CNC stepper setup for my rotary table. You mentioned in one of your earlier posts on this topic about posting up a list of components used and plans. I know your busy but did you ever manage to do this and if so where would I find them.
Many Thanks,

Colin
 
Thanks Chuck that helps me out a lot. The Reset/ Sleep connection is that just specific to pololulu driver? i.e i don't need to worry about that with my TB driver?

Thanks

Paul

Yeah, those connections are specific to the A4988.

Chuck
 
Thanks Chuck, code now loaded wires connected to test. Just need to decide whether to mangle up the rotoary table or build something from scratch, the later probably being the bet for now. Thm:
 
Thanks Chuck, code now loaded wires connected to test. Just need to decide whether to mangle up the rotoary table or build something from scratch, the later probably being the bet for now. Thm:

Yeah, if you are planning on using it just for dividing operations like drilling holes or cutting gears, etc., a rotary table really has too high a gear ratio. My dividing head has ratio of 1:5 from motor to spindle. My Arduino program doesn't have stepper acceleration and deceleration, so it's kind of slow, just to make sure it doesn't skip any steps.

Chuck
 
Chuck my rotab has a 90:1 wormdrive which would work out well for this. Chances are i would go with a worm drive on a scratch build as well. With the driver at 3.5amps and use full volts, run bipolar on the windings and keep micro steps down to a minimum then the holding torque should be sufficient for my needs. Not planning to do any fast turning with mine.
 
First of all thanks to Chuck for his arduino stepper motor code in download section. This runs happily on my arduino uno with Sainsmart 1602 LCD. I am waiting for delivery of Pololu DRV8825 and a stepper motor but in meantime am looking to see what spare pins there are available on LCD module. I would like to use the stepper in microstep mode. I think that D11, 12 and 13 are free. On the DRV8825 schematic they are marked as D11/MOSI, D12/MISO and D13/SCK. Does anyone know what they mnemonic mean. The DRV8825 docs say that to get particular microstep values MS1, MS2 and MS3 need to be set HIGH as appropriate. Can this be done by linking them together (as nec) and providing an input from one of the (hopefully) spare digital pins to set them HIGH.

Hope this makes sense.

Many Thanks,

Colin
 

Latest posts

Back
Top