Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

stepper motor control using cheep parts

Status
Not open for further replies.

jeremygaughan

New Member
Hi everyone I'm developing a cnc machine but starting with parts that are easy for everyone to get. The H bridges are made from NPN and PNP transistors and a 5v regulator for the microchip all from ratshack, a wallwort 12 volt transformer (that actually reads 18), and a simple program to run the ADC on a 12f675 that I will provide.
The initial idea is turn a pot and get varied speed for forward and backwards rotations on a stepper motor. Then later run two motors to make simple CNC designs.
The first part is to read the pot and subtract that from 127. If it trips a flag when subtracted then forward is called, if it doesn't trip a flag then it calls reverse. Based on how large the resulting value is from the subtraction the speed of the motor is changed.
For example if the ADC value is 100 and I subtract it from 127, the flag will not be tripped... The resulting value will be 27 and I'll use that in my delay to keep the coil turned on for some short corresponding amount of time. If the value from the ADC is 25 then the result after subtraction will be 112. Therefore giving a larger value for my delay and therefore spinning the motor at a slower rate. On the other hand if the value is 225 then I have the value of -98. I'll use the positive value of this number to create my delay therefore varying the speed of the stepper motor, but since the - will cause the flag to trip I will run the motor the other direction. The farther the value from zero the greater the delay and the amount of time that I'll leave the pole charged on the stepper motor, therefore the slower the motor will go.
For example here is the mantra of the program: read ADC, subtract from 127 and save value to delay timer, check flag, call forward or reverse correspondingly, charge first coil, count down delay, charge other coil, count delay, reverse polarity and charge first coil, count down delay, reverse polarity in second coil, count down delay, then continue to reverse and charge coils until ADC value read in a timer 0 interrupt indicates otherwise.
The read of the ADC will be in an occasional tmro interrupt. Fast enough to not notice but slow enough to not interrupt motor operation.

So far I have one H-bridge built and it runs a stepper motor pulled from an old A drive in my computer. I have run it with the 12f675l chip with just a very simple program that makes it go only forward, but it works. The next step is to run it in reverse, then put the ADC components on the board and in the program.

The reason for this post is to see if anyone else is interested in making a CNC machine that can do simple things like for example draw things with a pencil. I can't think of anything else to do with a 2D CNC yet. But all ideas are welcome and building partners as well. When the 3D machine starts I'll start another thread. l
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top