CNC Programming c++...

Thread Starter

Mil Nik

Joined Nov 26, 2016
12
hi guys im a noob at avr :D i need help:
i wanna programming simple cnc turning machine in code vision(c++,atmega32) with 300rpm motor( max speed ) that moving X,Y,Z aims(it means we need 3 motor3) for pierce 6 hole on something like woodblock !!!
size of woodblock is not important and we want to control the distance of holes with potentiometers... exaple like picture :
 

Attachments

Papabravo

Joined Feb 24, 2006
22,082
Before we even get to the issues of programming, it might be a good idea to understand the mechanics of what we are dealing with.
  1. What kind of motors did you have in mind and how are they arranged to move the tool?
  2. How will the motors command the tool holder to move?
  3. Will the spindle be turning continuously?
  4. What kind of boundaries are there?
  5. How about a schematic diagram of the processor and the interface to the mechanics?
  6. Do you have G-codes that describe how to make the part?
 

MaxHeadRoom

Joined Jul 18, 2013
30,654
As I understand it you want to build your own motion (CNC) control but control it with potentiometers, which is rather a contradiction.
It looks like you do not require interpolated motion so that makes it a little simpler.
The cheapest way would most likely be point-to-point using steppers motors.
There is also a free program available called Mach3 that would do it by control through the P.P. of a P.C.
No point in re-inventing the wheel.
Max.
 

Papabravo

Joined Feb 24, 2006
22,082
As I understand it you want to build your own motion (CNC) control but control it with potentiometers, which is rather a contradiction.
It looks like you do not require interpolated motion so that makes it a little simpler.
The cheapest way would most likely be point-to-point using steppers motors.
There is also a free program available called Mach3 that would do it by control through the P.P. of a P.C.
No point in re-inventing the wheel.
Max.
Well he has CodeVision and an ATMega32 so why does he now want to switch to a PC? There might be export restrictions on PC's, but what do I know about such things?
 

spinnaker

Joined Oct 29, 2009
7,830
As I understand it you want to build your own motion (CNC) control but control it with potentiometers, which is rather a contradiction.
It looks like you do not require interpolated motion so that makes it a little simpler.
The cheapest way would most likely be point-to-point using steppers motors.
There is also a free program available called Mach3 that would do it by control through the P.P. of a P.C.
No point in re-inventing the wheel.
Max.
Mach3 is not free. At least not a version that will do much. The free version is very limited on the number of gcode instructions that can be processed. The free demo version is limited to 500 lines. Certainly enough for very basic experimenting but not enough for anything real world. I have a simple switching PSU and that design is over 4000 lines of gcode.

Linux CNC is free and unlimited.
 

MaxHeadRoom

Joined Jul 18, 2013
30,654
Mach3 is not free. At least not a version that will do much. The free version is very limited on the number of gcode instructions that can be processed. The free demo version is limited to 500 lines. Certainly enough for very basic experimenting but not enough for anything real world. I have a simple switching PSU and that design is over 4000 lines of gcode.
The OP's application appears quite trivial, move point-to-point for 6 holes and drill, 500 lines should be more than enough.
Also the limitations would not really affect this project.
  • Mill & Plasma: 500 line gcode limit (10,000,000 limit after licensing)
  • Kernel Frequency locked at 25kHz (only applicable if using the parallel port driver)
  • Set Next Line function disabled
  • Run From Here function disabled
With my Excello mill I have, I never come anywhere near 500 lines of code.
Max.
 

spinnaker

Joined Oct 29, 2009
7,830
Well he has CodeVision and an ATMega32 so why does he now want to switch to a PC? There might be export restrictions on PC's, but what do I know about such things?

Writing the firmware for interpreting gcode is going to be challenging enough. Adding a UI would really make things difficult. Of course if the TS want a dedicated machine then doing it all in the Atmega should not be too difficult.
 

spinnaker

Joined Oct 29, 2009
7,830
The OP's application appears quite trivial, move point-to-point for 6 holes and drill, 500 lines should be more than enough.
Also the limitations would not really affect this project.
  • Mill & Plasma: 500 line gcode limit (10,000,000 limit after licensing)
  • Kernel Frequency locked at 25kHz (only applicable if using the parallel port driver)
  • Set Next Line function disabled
  • Run From Here function disabled
With my Excello mill I have, I never come anywhere near 500 lines of code.
Max.

I take it you are not milling PCBs or doing any engraving. ;) But you are right looks like the OP has a simple job in mind.
 

ClassOfZero

Joined Dec 28, 2016
114
Linuxcnc (machinekit) on a BeagleBone Black will give you a physically small system, vnc will give you "remote control".

Linuxcnc on a PC is also an option.

GRBL on a arduino board will allow you to send gcode via a usb-serial connection and the arduino board does all the work (no backlash compensation yet).

I'm wondering if the OP actually needs an A axis to do what he requires. Not knowing his actual mechanical setup it's all just speculation. An MPG sounds like a better option than a pot, well in my opinion anyways.

cnczone will be a greater source of information.
 

ClassOfZero

Joined Dec 28, 2016
114
I don't use Mach CNC but have bench-experimented with it enough to get a feel of its capability.
I use motion cards only for CNC, Galil etc.
Max.
Mach 4 (the latest version) the PP driver is a separate component now....They have had a complete rewrite, from my understanding there is very little ( or none) of the Mach 3 codebase that has been migrated into Mach 4.

For a DOS based solution, basically you can go down to a 486DX, TurboCNC is another option, this is free and has unlimited line restrictions.
 

ClassOfZero

Joined Dec 28, 2016
114
Turning machine, I would interpret as a lathe, which conventionally only has a Z & X axis. As the OP mentioned X,Y & Z it left me wondering what his actual intention was.

Yes one can use a mill for basic turning operations, I made a great flycutter that way.

But I do agree that Mach3 or similar would be a suitable way to go, rather than trying to reinvent the wheel. If backalsh comp isn't an issue and limit switches aren't required or you feel you can get away without them (they can be used) I'd tend to go with GRBL.

You could even use a mcu (an intelligent mpg?) to send gcode to a grbl board, have the grbl board do the gcode interpretation and signal generation for the stepper drivers.
 

DNA Robotics

Joined Jun 13, 2014
670
If you get stepper motors & drivers like these...
Stepmotor
http://www.mpja.com/Stepmotor-18deg-NEMA-17-4-Lead/productinfo/32177+MS
Stepmotor Driver
http://www.mpja.com/Stepmotor-Driver-3A-Max-TB6560/productinfo/31306+MS

You just have to set the direction & send pulses to turn them.
If you read your potentiometers with analog input, you can use that number to vary the distance between holes.

Z 200 steps down to drill hole
Z 200 steps up
First X potentiometer number of steps left
Z 200 steps down to drill hole
Z 200 steps up
First X potentiometer number of steps left
Z 200 steps down to drill hole
Z 200 steps up
Y potentiometer number of steps in
Z 200 steps down to drill hole
Z 200 steps up
Second X potentiometer number of steps left
Z 200 steps down to drill hole
Z 200 steps up
Second X potentiometer number of steps left
Z 200 steps down to drill hole
Z 200 steps up
Done
If you kept track of how many steps in each direction, you could send it back to the origin to repeat the operation.
 
Last edited:

ClassOfZero

Joined Dec 28, 2016
114
If you get stepper motors & drivers like these...
Stepmotor
http://www.mpja.com/Stepmotor-18deg-NEMA-17-4-Lead/productinfo/32177+MS
Stepmotor Driver
http://www.mpja.com/Stepmotor-Driver-3A-Max-TB6560/productinfo/31306+MS

You just have to set the direction & send pulses to turn them.
If you read your potentiometers with analog input, you can use that number to vary the distance between holes.

Z 200 steps down to drill hole
Z 200 steps up
First X potentiometer number of steps left
Z 200 steps down to drill hole
Z 200 steps up
First X potentiometer number of steps left
Z 200 steps down to drill hole
Z 200 steps up
Y potentiometer number of steps in
Z 200 steps down to drill hole
Z 200 steps up
Second X potentiometer number of steps left
Z 200 steps down to drill hole
Z 200 steps up
Second X potentiometer number of steps left
Z 200 steps down to drill hole
Z 200 steps up
Done
If you kept track of how many steps in each direction, you could send it back to the origin to repeat the operation.
A pot is going to be a poor choice, better off to use a rotary encoder. With a pot the greater the distance between holes the less resolution you are going to have.
 

MaxHeadRoom

Joined Jul 18, 2013
30,654
If using stepper motors why use an encoder??
Just send a command distance based on the number of steps per inch, this is about the only benefit of steppers over servo's.
Unless you mean as a MPG as a command instrument.
Which is a little crude way of specifying position in the X,Y,Z.

Max.
 

ClassOfZero

Joined Dec 28, 2016
114
hi guys im a noob at avr :D i need help:
i wanna programming simple cnc turning machine in code vision(c++,atmega32) with 300rpm motor( max speed ) that moving X,Y,Z aims(it means we need 3 motor3) for pierce 6 hole on something like woodblock !!!
size of woodblock is not important and we want to control the distance of holes with potentiometers... exaple like picture :
It was in response to the OP wanting use to control the distance.
If you disagree that a rotary encoder would be an inferior option to pots I would like to hear your opinions in this matter. (This is meant as a genuine inquiry as my cnc experience is only as a hobbyist). I mean no disrespect Max, in fact I value your opinion.

I'd just like to qualify I wasn't suggesting using a MPG to drive the stepper motors, but rather an interface. But then again using the manual data interface provided with the previously discussed packages would be an option if one wants to avoid gcode. Tho gcode has the benefit of being reusable. Mach3 also has some useful wizards to accomplish simple tasks.

There is also the consideration that controlling steppers via pots rather than accurate drilling of holes maybe the object of this exercise. Until we hear from the OP I am just thinking aloud. I do think I maybe incorrect in this line of thinking.
 
Last edited:
Top