Code:
//############################################################################ // GPICode - Gcode Interpreter // A four axis step-dir G code interpreter with // software generated linear acceleration ramps // Written by VegiPete picprog.strongedge.net // // HOWEVER, due to PIC18F18K22 memory constraints and the C18 compiler, // this version DOES NOT understand inches or millimeters. // Instead, moves must be specified in STEPS. // Also, feedrate is specified in who knows what. // // See <http://www.linuxcnc.org/docs/2.4/html/gcode_overview.html> for // a more detailed overview of G Code. // // A block is one line of text. // A block consists of one or more words. // A word consists of a letter and a number. // A number can be positive or negative and may contain a decimal. // A number begins with optional '+' or '-' and ends with any non digit. // Extra decimal points are ignored. 12.34.56 = 12.3456 // Extra +/- signs restart the number. +12.3-4.5 = -4.5 // (The number of decimal digits is specified in the config and // excess digits are ignored. // Recognized Words: AFGMNPXYZ // White space is ignored. Lower case is converted to upper. // A line of text ends with a CR and/or a LF. // // Recognized G-Codes: // (Divided into groups, 'x' indicates power-up default) // Modal Group 1: // G00 rapid positioning // G01 linear feed positioning // G02 unrecognized for now // G03 unrecognized for now // G80 x cancel positioning mode // -------- // Modal Group 2: // G17 x XY plane - no effect // G18 no effect // G19 no effect // -------- // Modal Group 6: // G20 x imperial // G21 metric // -------- // Modal Group 3: // G90 x absolute // G91 relative // | power up default // -------- // Non-Modal // G4 pause - P value is number of 1/10 seconds to pause (ie, 10 = 1 second) // G92 set absolute position of any axes found to zero // // X,Y,Z,A recognized axes // F feedrate - inches (or mm) per minute // M (0-255) 3 = relay on // 5 = relay off // 226 = wait for user to cycle E-Stop switch // others ignored // N line number - (0-32767) - ignored // P parameter - (0-255) - applies to G4 // // ( start of comment - remainder of line ignored. // ; start of comment - remainder of line ignored. // // The following are special functions which must be at the start of a block. // / block delete - ignore block if block delete is on. // % turn UART echo ON or OFF (0=OFF, !0=ON) // // The following special purpose comments must be at start of block. // (MS message comment - a 16 character string will be echoed. Extra chars ignored. // (HM perform machine home cycle. // (CF configuration setup/display. // Each of the following words sets the corresponding EEPROM data value. // XYZA - set steps per inch for respective axes (16 bit) // D - acceleration (16 bit) // F - set max feedrate (16 bit) // B - number of sig digits after a decimal point (max 7) // C - block delete enabled if not zero (8 bit) // // The following are the homing config data: (all byte sized) // E - power-up home if not zero // G - homing back-off speed // H - step 1 axis & direction bit pattern // I - step 1 speed // J - step 1 timeout // K - step 1 back-off distance // L - \ // M - \ step 2 // N - / // O - / // P - \ // Q - \ step 3 // R - / // S - / // T - \ // U - \ step 4 // V - / // W - / // // The homing function is highly configurable. Homing occurs as 4 steps. // Each step consists of an axis to home, the direction to home, the speed // to move home, the maximum time to take moving home and the distance to // back away from the home limit switch. These 4 data values are repeated // for each of the 4 homing steps. A fifth data value sets the back-off // speed for all axes. // // Homing for each step involves moving the specified axis in the specified // direction at the specified speed until the limit switch is tripped. The // axis is then reversed at the back-off speed away from the limit switch // until the switch closes again. Finally, the axis is moved the specified // number of steps farther from the switch. // // The bit pattern for each step encodes both the direction and axis for that step. // D is direction bit, AZXY is axis to home // D.AZ..XY - ENSURE ONLY 1 AXIS BIT SET!!!! // 76543210 // 00100000 --> A axis // 00010000 --> Z axis // 00000001 --> Y axis // 00000010 --> X axis // The bit pattern must be given in the config data as a decimal value although // it will be echoed as a hex value. // For example, '(CF H 144' sets the bit pattern for step 1 axis/dir to b'1001000' // which means for homing step 1, move the Z-axis in the negative direction. It is // very important that only one axis bit is set. If no axis bits are set, this // homing step will be skipped. This is usefull, for example, for non-linear // axes. If all 4 axis/dir bit patterns have no axis bits set then no axis homing // will be performed although the homing process will succeed. // // The homing speed is the speed at which the axis moves towards the limit switch. // The speed is steps per second (I think) and is 50 times the specified value. // For example, '(CF U 20' sets the step 4 speed to 1000 steps per second. (Maybe) // Note that the axis will crash stop when the limit switch is hit, so the speed // should not be so high that this instantaneous stop causes problems. // // The timeout in 500ms units ie: the value 12 means 6 seconds timeout // // The back-off distance is the number of steps divided by 10 to reverse away // from the limit switch. For example, '(CF S 50' means to back the step 3 // axis 500 steps away from the limit switch // // Limit Switch / E-Stop wiring: // All limit switches and the E-Stop switch are wired in series using NC // (normally CLOSED) switches. A single analog port is used to read 3 switch // states: nothing, limit hit and E-stopped. Hitting the E-Stop functions the // same as a broken wire and causes the controller to immediately stop generating // step pulses. Each limit switch is wired with a parallel 4.7K resistor. // // Hardware: // Internal RC OSC with 4x PLL enabled // RA0 - Y-Step (PGD) // RA1 - X-Step (PGC) // RA2 - Analog Input // RA3 - !MCLR (Input Only) // RA4 - Z-Step // RA5 - A-Step // // RB4 - // RB5 - RX - Serial in // RB6 - Relay Output // RB7 - TX - Serial out // // RC0 - X-Dir / LCD D4 // RC1 - Y-Dir / LCD D5 // RC2 - Z-Dir / LCD D6 // RC3 - A-Dir / LCD D7 // RC4 - LCD RS / LED - lo for ctrl, hi for data // RC5 - LCD Enable - toggle hi to latch data // RC6 - Limit/EStop Switch Input - Analog // RC7 - Drive Enable // // Version Control: // Up to 0.77 written in assembly - how manly! // 0.80 migration to C and complete rewrite. // 0.81 reduce motion to 24 bits to free up some RAM, make faster // 0.82 removed inch/mm for memory constraints+
See also:
file: /Techref/microchip/bobmotion-source.htm, 7KB, , updated: 2016/11/13 21:12, local time: 2024/12/26 11:47,
owner: JMN-EFP-786,
3.149.29.209:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://techref.massmind.org/Techref/microchip/bobmotion-source.htm"> Source documentation</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Welcome to techref.massmind.org! |
.