585,883 active members*
4,924 visitors online*
Register for free
Login
IndustryArena Forum > CNC Electronics > CNC Machine Related Electronics > Low cost "PIC = Micro-controller?"
Results 1 to 11 of 11
  1. #1
    Join Date
    Apr 2006
    Posts
    4

    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

  2. #2
    Join Date
    Apr 2006
    Posts
    402
    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

  3. #3
    Join Date
    Apr 2003
    Posts
    131
    Quote 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.

  4. #4
    Join Date
    Mar 2003
    Posts
    35538
    Quote 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

    UCCNC 2017 Screenset
    http://www.thecncwoodworker.com/2017.html

    Mach3 2010 Screenset
    http://www.thecncwoodworker.com/2010.html

    JointCAM - CNC Dovetails & Box Joints
    http://www.g-forcecnc.com/jointcam.html

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

  5. #5
    Join Date
    Nov 2004
    Posts
    131
    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

  6. #6
    Join Date
    Apr 2006
    Posts
    4
    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

  7. #7
    Join Date
    Apr 2006
    Posts
    402
    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

  8. #8
    Join Date
    Apr 2006
    Posts
    4
    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.

  9. #9
    Join Date
    Apr 2006
    Posts
    402
    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

  10. #10
    Join Date
    Apr 2003
    Posts
    131
    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.

  11. #11
    Join Date
    Mar 2004
    Posts
    1147
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •