CNCzone.com-The Largest Machinist Community on the net!



Home Page Mark Forums Read Today's Posts My Replies Classifieds Reviews Photo Gallery Web Links Share Files Advertise With Us Ad List
Go Back   CNCzone.com-The Largest Machinist Community on the net! > Machine Controllers Software and Solutions > TurboCNC


TurboCNC Discuss TurboCNC controller software here!


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Ban this user!
Old 10-09-2005, 11:12 PM
 
Join Date: Oct 2005
Location: USA
Posts: 4
tyler_derden is on a distinguished road
How does it work?

Question for programming oriented people:

How does CNC software such as TurboCNC calculate the timing for the step /direction outputs for multiple axes- i.e. what sort of math is involved in synchronizing the axes so a circle comes out a circle and a diagonal line comes out a diagonal line with the tiniest possible stair-stepping?

Thanks,

TD
Reply With Quote

  #2   Ban this user!
Old 10-09-2005, 11:37 PM
Lionclaw's Avatar  
Join Date: Jan 2005
Location: USA
Posts: 253
Lionclaw is on a distinguished road

Very good question. I want the answer too so I'll subscribe to this thread

I would guess you could just use the equation of a circle, (x - h)^2 + (y - k)^2 = r^2, h and k being the x and y coords of the center of the circle. With that you can solve for X or Y. From there you can determine the domain and range of the function to figure out which values to substitute.

Just a guess... I enjoy solving those sorts of problems, and I'm sure it'd be an interesting program to write. Hopefully someone who has done it before can give us a concise answer.
Reply With Quote

  #3  
Old 10-10-2005, 07:10 AM
ger21's Avatar
Community Moderator
 
Join Date: Mar 2003
Location: Shelby Twp, MI....USA
Posts: 20,467
ger21 is on a distinguished road
Buy me a Beer?

If you pay the $60 to register it, you'll get all the code for TurboCNC. The math can get very complicated when you factor in the acceleration as well.

You can also get the source code for EMC for free. Check out http://www.linuxcnc.org
__________________
Gerry

Mach3 2010 Screenset
http://home.comcast.net/~cncwoodworker/2010.html

(Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)
Reply With Quote

  #4   Ban this user!
Old 10-10-2005, 10:32 PM
 
Join Date: Oct 2005
Location: USA
Posts: 4
tyler_derden is on a distinguished road

Originally Posted by Lionclaw
Very good question. I want the answer too so I'll subscribe to this thread

I would guess you could just use the equation of a circle, (x - h)^2 + (y - k)^2 = r^2, h and k being the x and y coords of the center of the circle. With that you can solve for X or Y. From there you can determine the domain and range of the function to figure out which values to substitute.

Just a guess... I enjoy solving those sorts of problems, and I'm sure it'd be an interesting program to write. Hopefully someone who has done it before can give us a concise answer.
I believe that TurboCNC and similar programs include this sort of math.

The more you think about it, the more complex it seems. You have to make sure that all axes reach their respective end points at the same time. Say you want to make a diagonal line in a 2 axis system. If the angle were 45 degrees, you'd simply alternate one step in x direction then one step in y direction until you got to the end point.

Now think about an arbitrary angle. Let's say you needed to go a total of 321 steps in the x driection and 751 steps in the y direction to make the line. Presumably you'd step in the y direction a couple steps, then step once in x then go back to stepping in y. You need to figure out where to insert the steps in the x direction so that in the end you land on the desired end point, and so that your line is approximately straight.

321/751=.427430093. So for 1000 steps in y direction, you need to make 427 steps in x direction, with some error (430x10-6). You get even less error if you step 10000 in Y and 4274 in X (30x10-6). Assume that amount of error is low enough. You need to figure out when to insert x steps as you put out y steps so that both will end at the same time.

Now think about making a circle of arbitrary radius... Do you turn it into a polygon then perform the same type of calculations for each side? How many sides? Or is there a way to ensure getting a circle using some other technique?

TD
Reply With Quote

  #5  
Old 10-10-2005, 10:38 PM
ger21's Avatar
Community Moderator
 
Join Date: Mar 2003
Location: Shelby Twp, MI....USA
Posts: 20,467
ger21 is on a distinguished road
Buy me a Beer?

Originally Posted by tyler_derden
If the angle were 45 degrees, you'd simply alternate one step in x direction then one step in y direction until you got to the end point.
If you did that, you'd get a stair step effect, although it would possibly be too small to see. The axis need to move simultaneously, not alternating. And as I mentioned before, throw in acceleration and it gets a LOT harder.
__________________
Gerry

Mach3 2010 Screenset
http://home.comcast.net/~cncwoodworker/2010.html

(Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 10-10-2005, 11:49 PM
 
Join Date: Oct 2005
Location: USA
Posts: 4
tyler_derden is on a distinguished road
I have it partially figured out, I think.

You have to convert it from a distance to a time problem. Essentially, you need to output step instructions independently on the axes so that they reach their final counts at the same time.

For example, lets say we want to move the tool/table along a diagonal line 3000 steps in the x direction and 4321 steps in the y direction. The total distance to travel will be 5260.032708 steps. If you want to complete the trip at a rate of 1000 steps per second (the maximum is a function of motor construction), it will take 5.260032708 seconds. In 5.260032708 seconds, you need to complete 3000 steps on the x axis- i.e. you need 5.260032708 sec/3000 steps=1753.44236 us/step. The y axis requires 1217.31838 us/step.

If you set up a clock that runs at 1 MHz, and two counters, one for each axis, when the x axis counter which is counting the clock pulses reaches 1753, you send out a step instruction to the x axis motor, reset the counter, then resume counting. You do the same at the y axis- only output the step instruction to the y axis motor every time the y axis count reaches 1217. When you have sent 3000 steps on the x axis and 4321 steps on the y axis, you stop.

You can get greater precision by using a higher frequency clock (or lower stepping rate on the motors). If the clock runs at 10 MHz, then the x axis gets a step instruction every time the count reaches 17534 and the y axis gets a step instruction at 12173.

Time to start thinking about circles...

TD
Reply With Quote

  #7   Ban this user!
Old 11-10-2005, 04:23 PM
 
Join Date: Jul 2003
Location: Holmen, WI
Posts: 1,082
samco is on a distinguished road

Wow this brings back memories. I wrote a machine control program in basic about 10 years ago. I wanted to control a small 3 axis machine with stepping motors. I started thinking about using 2 different numbers for each axis - similar to how servos work. One would be where the steppers should be and one would be where the stepper was. if the error between the "should be" and the "where" where off by a step the stepper would be incramented to the next step to match the "should be" - if that made sense. sort of an error differance between the calculated position and the actual position.

It was a pain to get the feed rates to work - exp using basic as there was no time base. I ended up doing a loop and timing it at the start of the program to calculate how big my delay loops would be to calcuate feed rates. \

now circles - the only easy way I could think of doing them at the time was using degrees to wipe around the arc. this made it so the feed worked for me - I would calculat how many degrees per resolution I wanted around the circle and then could calculate how long the delay loop would be between each degree (or fraction of degree depending). I ran a calculation for accelleration and deaccelleration for the arcs and lines - worked pretty well.

nothing ever came of it - when I got back into cnc equipment turbocnc was out and turned circles around what I was trying to do. I was to the point of trying to do some sort of constant velosity calculations so I wouldn't slow down / speed up at each end point. this is where I couldn't spend enough time on it. I figured I would have to read ahead so many end point and figure out how much I would have to slow down for each change in direction.

I will have to see if I can find that program - it would be neet to look though it again.

sam
Reply With Quote

Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -5. The time now is 12:13 PM.





Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO
Template-Modifications by TMS

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361