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! > Electronics > General Electronics Discussion


General Electronics Discussion Discuss basic electronics, power supplies and anything else electronic related here.


This forum is sponsored by:

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Ban this user!
Old 04-23-2006, 07:00 AM
Aan Aan is offline
 
Join Date: Apr 2006
Location: Australia
Posts: 4
Aan is on a distinguished road
Low cost "PIC = Micro-controller?"

Good day CNC-Xperts,

It seems that i couldnt understand the difference between PIC & Micro-controller even after i read through some of the links explaining the "Hardware G-code interpreter".
-. I came to conclusion that PIC is only a part of a micro-controller?

Im building a CNC machine but while the mechanical design seems okay, the software and controller part had me wondered whether i can do this or not.

-. Im wondering wether to use the new 68HC11Motorolla or Atmel products for the controller. It's a 2axis(x and y)-1solenoid (z axis) machine.

-. Since im using servo motor, am i right to assume that i'll need 2 encoders and 2 encoder circuit boards to control them?

-. For the software part, can you tell me how to write my own G-code interpreter? is there any example on the site (so far i have only found the www.metalworking.com)? and is it right to assume that every G-code interpreter will be different depending on the type of micro-controller used?

Im thinking of creating an interface which combine an open source CAD software (inkscape), an open source CAM software (cant decide which is best) and the G-code interpreter (write myself?) which compatible with the controller by using Visual Basic. Is that even possible for me? i cant imagine the load of work involved in this.

Cant thank you enough for your time in assisting me. Your reply is highly appreciated.

Regards,
Anthony
Reply With Quote

  #2   Ban this user!
Old 04-23-2006, 07:35 AM
 
Join Date: Apr 2006
Location: Somewhere
Posts: 402
fkaCarel is on a distinguished road

A Pic is a microcontroller. Most microcontrollers nowadays have build in Flash-Rom (Read Only Memory) for program storage, Ram (Random Access Memory) for variable storage and EEProm for storing parametrics.

I do not want to start a Pic/Avr war, but i think the Avr is a more flexible controller, more according to industry software standards. It has a lot and free support and is available in many software compatible sizes.

See a servo motor as a separate microcontroller, the processor interpreting the G-Code, commanding these servo-controllers, with or without feedback to the processor.

If you study G-code, you will see that it generates position commands in time, so straight line positioning is easy. For 2-D commands like tapers and circles, you need to study algorithms, like Bresenham for tapers and goniometry for next position calculation in circles.

This a broad spectrum and you will have to study the needs of each component of the system.

Carel
Reply With Quote

  #3   Ban this user!
Old 04-23-2006, 09:17 AM
dkowalcz's Avatar  
Join Date: Apr 2003
Location: USA
Posts: 118
dkowalcz is on a distinguished road

Originally Posted by Aan
Im thinking of creating an interface which combine an open source CAD software (inkscape), an open source CAM software (cant decide which is best) and the G-code interpreter (write myself?) which compatible with the controller by using Visual Basic. Is that even possible for me? i cant imagine the load of work involved in this.
That is loads of work, even for any one piece of that puzzle. Trust me... If you're building a plotter type device, it's probably tractable, but you'd be months ahead to download and learn to use any of the software that does this already, there are at least a dozen downloadable g-code controllers in common use - which would let you focus on writing the app to glue the CAD/CAM/g-code layer together if you still feel the need to do that.

The de-facto standard interface is step and direction control, as you may already be aware. There are no standards for the various hardware pulse generators that use microcrontrollers and USB/serial/ethernet to communicate.
Reply With Quote

  #4  
Old 04-23-2006, 09:24 AM
ger21's Avatar
Community Moderator
 
Join Date: Mar 2003
Location: Shelby Twp, MI....USA
Posts: 20,448
ger21 is on a distinguished road
Buy me a Beer?

Originally Posted by dkowalcz
That is loads of work, even for any one piece of that puzzle. Trust me...
Yes, trust him. He wrote TurboCNC. www.dakeng.com
__________________
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

  #5  
Old 04-23-2006, 09:49 AM
jerber's Avatar
Gold Member
 
Join Date: Nov 2004
Location: Netherlands
Posts: 140
jerber is on a distinguished road

If you realy want to write your own g-code interperter then you can look at EMC, www.linuxcnc.org, wich is opensource.
I believe it was based on code released by the NIST (some kind of US govermental org.).

As far as I know there is no opensource code around for a g-code interpreter in an embedded aplication.
You can find some free stuff on www.cncdudez.com (from another member of the zone) but no source.

I'm still learning to code for embedded systems but like Carel I prefer Avr over Pic, however most (cnc)hobiests seem to use Pic.

Maybe it's better to get your machine running first with a DIY driver like the UHUservo and software like Mach3 or EMC and then build a g-code iterpreter.

Succes,

Jeroen
__________________
____________________________________
Jeroen
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 04-23-2006, 11:54 AM
Aan Aan is offline
 
Join Date: Apr 2006
Location: Australia
Posts: 4
Aan is on a distinguished road

Thanks for all the reply guys.
Well, if the expert says it's a lot of work that means it REALLY IS a lot of work. I still have a way too LONGGGG way to go to reach that level i guess.
So, im assuming its impossible for me ATM to build my own g-code interpreter.

Question:
-. Assuming im using the DragonBoard controller (by Wytec company and a motorolla brand i think) and write the G-code interpreter, will i be able to use that same interpreter for different kind of motorolla brand? BTW, im running it on Windows only.
-. Do people write different g-code interpreter for different microcontroller? or for other reasons?
-. Is writing a G-code interpreter, with basic G&M functions ONLY (G90, G1, G2, G3, G4, and few M, hard? Since i have played with CodeWarrior software before (a programming language provided by DragonBoard). Am i right to say that i have to create and declare each function (let's say G01) accordingly by e.g setting the PWM bits on and etc. so that it really does the linear interpolation (G01)?

Thanks so much,
Anthony
Reply With Quote

  #7   Ban this user!
Old 04-23-2006, 02:04 PM
 
Join Date: Apr 2006
Location: Somewhere
Posts: 402
fkaCarel is on a distinguished road

Assume G-code is a standard descriptive language for movement. Assume in the memory of your microcontroller is:
1) X 0 ;the controller will position the X-axle to 0 and go to the next line if finished
2) Y 0 ;the same for Y
3) G99 ;G = special command, in this case end of program, goto idle(manual mode)

As positioning commands are executed with the feed or speedrate, you have to calculate a timer interval, to synchronize your program in time. You have to specify each command individually, because all these commands have different behaviour. You don't want the linear interpolation command produce a circle, although you produce in the background a circle with many linear interpolations. You can start with straight lines and expand your code from that point. Writing a G-interpreter is not that difficult, I've done it in 1986. But you first have to learn about the meaning of all the hard- and software components. You don't get linear interpolation by turning PWM bits off and on.

Carel
Reply With Quote

  #8   Ban this user!
Old 04-23-2006, 11:34 PM
Aan Aan is offline
 
Join Date: Apr 2006
Location: Australia
Posts: 4
Aan is on a distinguished road

I have read Kevin Carrol's source code for his G-code compiler and it surprised me with how many lines and commands needed for the "step" section only, not to mention the "setport, setspeed, setcolor" sections. One thing i dont understand from Kevin's compiler is, what language is it written on? C/C++ or others?

I understand the G-code programming. Just recently bought the DeskCNC guidebook. What i dont understand is how to make a brand new controller (lets say motorolla chip/brand) to understand the G-code coding.
Like u mentioned before,
-. G01 X0 Y0, meaning the controller needs to send a signal to the x-axle motor and y-axle motor to run to point 0.
But the controller doesnt understand what G, X, and Y mean. Thus, i need to write a C/C++ programming that understand what 'Gxx', 'X', and 'Y' is, am i right so far?
So can i treat "Gxx, X, and Y" as new variables and create a "class" for each of them?
For example:
if (G01 == true)
MOVE in linear interpolation;

Is it as simple as that? i learn programming before like C++ so i hope im doing the right thing.
Reply With Quote

  #9   Ban this user!
Old 04-24-2006, 01:20 AM
 
Join Date: Apr 2006
Location: Somewhere
Posts: 402
fkaCarel is on a distinguished road

So you read source code and it is absolute Chinese to you, to many lines and you don't know in which language it is written. You understand G-code programming but how a processor executes this, is incomprehendible to you.

Embedded processors can be little miracles, but if don't understand what you're doing, they will punish you with never ending crashes. So buy a development board, write a flash-a-led program and learn. See a program as a building. It is build of bricks. Together they function as a building. Analyse what kind of building you need for an interpreter. Don't worry about the wallpaper of an individual room, it will change in the process. And: nobody will write a program for you and cut and paste is a recipe for disaster.

Carel
Reply With Quote

  #10   Ban this user!
Old 04-24-2006, 10:04 AM
dkowalcz's Avatar  
Join Date: Apr 2003
Location: USA
Posts: 118
dkowalcz is on a distinguished road

IIRC, Kevin Carroll's "Stepster" is in PowerBASIC.

It's not really that tough to write a very simple control. Fundamentally, any motion no matter how complex can be reduced to G01 and G04, the M's basically turn things on and off. If you just want to make it move, a loop to deliver pulses and read encoders is an afternoon's work - maybe a bit more since you want to do it on an embedded uC.

The more you make it do, the bigger it gets. TCNC is 80 000 lines of code.

If you're determined to do this, I'll just point out the big hurdles you'll need to jump:

- You'll need to write some string manipulation routines to break down the "G00 X1.00" coming in, look for errors, and handshake with the host PC. This code is probably the most voluminous.

- The servo loop stuff is pretty simple, I'd be surprised if you couldn't find some canned code here, but allow some time for pretty thorough tuning and testing.

- Lack of hardware floating point is one of the big hassles with microcontrollers. You can get libraries of code for this, but the speed penalty is extreme compared to the CPU in a PC. You might go to a fixed point representation to save computing time, but that means you'll probably end up writing it yourself.

- Timing of all the events can get tricky. You've got to keep an eye on the encoders, update the PWM, keep the serial port alive, break down the next line coming in, etc... The hardware may handle some of this for you, but chances are you'll be writing at least some code to interleave all of it.

- Spend a lot of time determining how the program will be architected beforehand so you don't paint yourself into a corner. For example, I'm not sure defining a class for Y would be the right way to go as it'd be pretty slim on methods - perhaps a class for Value and define X and Y as instances of that class, or a class for the machine state and have X Y Z as public floats. This kind of thing is something that can only come from you since you're writing it.

I think fkaCarel has given you very good advice - write a simple LED flasher or other program and see if you want to go further from there.
Reply With Quote

Sponsored Links
  #11   Ban this user!
Old 04-24-2006, 12:46 PM
 
Join Date: Mar 2004
Location: United States
Posts: 1,147
vacpress is on a distinguished road

also directly of interest is luberth's really cool pi micro stuff. last time i checked out his site, he had a working PIC-based gcode interpreter. Also, somewhere out there on the web, someone has made a full BASIC stamp interpreter. I think it may not do many thing yet, but it does alot..

really, it may be more logical to purchase turboCNC and attempt to make a pulse generator.. Let TCNC do the hard work..

Even with a few years of PIC programming, look at devloping any sort of 'real' gcode interpreter in a microcontroller as a 1-year plus project.. At least I would... The amount of information required is huge, not to mention skills and money..

On top of that, you really should have ample experience with CNC equipment.

How do you expect to devlope a very complex piece of control software for a device you may not have much experience with.. Asking /newbie' questions like 'i want to use servos, do i need an encoder?' in the same paragraph as saying 'i play to write my own PIC based gcode interpreter' is pretty amusing...

A few months of hard work and research, you should be on the right track..

Checkout luberth.. google 'luberth'... then try googling something like

+gcode +basic +stamp

or

+gcode +"basic stamp"

It is worht a shot. Also be advised, if you make a reasonable, working GCODE interpreter with look ahead, constant velocity, etc... you could certainly make some $$ selling it. I would pay upto $150 if it worked well..

to see the competition for such a device, checkout the g100 thing at www.geckodrive.com
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 02:17 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