584,833 active members*
5,515 visitors online*
Register for free
Login
Page 3 of 3 123
Results 41 to 54 of 54
  1. #41
    Join Date
    Jul 2012
    Posts
    106

    Re: CNC Indexer (Arduino based)

    Quote Originally Posted by Markovic Slavol View Post
    Why did so many mistakes???
    Can someone give an adequate response and advice?
    Attached text errors.
    Thanks in advance,
    SM


    05.12.2016 at 23:12h Finally, compile succeeded! I used Arduino-1.5.5-r2 ( Slika001.jpg )!
    Those aren't errors those are warnings but yes, they should really be fixed as they reference a deprecated method and future revisions of GCC and or Arduino base code they'll become errors not warnings.

    I find this project has some merit however, using the antiquated LCD and keyboard matrix is considered prehistoric with the introduction of TFT LCD TouchScreen and I'm not talking about those 2.4in hard to read small little things, I'm talking about a 3.95in 320X480 human readable size which cost less than $15.00 shipped on e-bay.

    The top four lines can be dedicated to text in a 10x14 or 15x21 pixel font size so reading is easy even from a distance and the remaining space dedicated to the onscreen keypad and other function buttons.
    Quote Originally Posted by WmCnc View Post
    Hi rooies13,

    No, the way it is it will not work.
    For that you will probably need a full cnc mill, with a 4th axis.
    The mechanical part of this project would work as the 4th axis; but not the Arduino/electronics part.

    Wagner
    I have a friend who has a rotary table running from an Uno connected to his mill and it's got some pretty killer tolerance and precision specifications in a zero-backlash product he made for around $500.00 including the 5in (125mm) 4-jaw self-centering chuck so to say it wont work is a sign of inexperience and lack of vision.

    I've pretty much adopted the 3.95in TFT LCD TouchScreen just because of it's size, I've got a nice Reflow oven, a programmable drill press that can do step-drilling and skip-drilling, they work with steppers or servo's, anything that accepts a step/dir signal is a viable candidate.

    As long as the code can fit in an Uno, anything is possible in an Uno.

  2. #42
    Join Date
    Sep 2009
    Posts
    1856

    Re: CNC Indexer (Arduino based)

    the year it was compiled was a different version of Arduino a lot of changes have happened
    http://danielscnc.webs.com/

    being disabled is not a hindrance it gives you attitude
    [SIGPIC][/SIGPIC]

  3. #43
    Join Date
    Jul 2012
    Posts
    106

    Re: CNC Indexer (Arduino based)

    Quote Originally Posted by daniellyall View Post
    the year it was compiled was a different version of Arduino a lot of changes have happened
    Funny you should say that, I'm using a custom Arduino 1.0.6 built to run under Java 5 that was fixed by a friend, I see no need to update from a known good working to a newer one that is plagued with problems and offers no real benefit or incentive to update.

    Also been updated to a newer avrdude (6.1) and some features of the Arduino 1.5.x have been transplanted so I just enjoy it.

    I have no need to update my hardware just to update my OS just to update Java just to update the Arduino IDE to a version that doesn't work correctly and will never truly be fixed by the Arduino dev-team, you can cry it's outdated and no longer supported but it has no issues so no support is needed and I have yet to find a sketch that I can't compile unless some fool decided to do something non-standard in his implementation that no one else can duplicate.

    Back in the day was newer than I'm using, but it had GCC-4.3.2 or GCC-4.4, mine has GCC-4.8.3, can't update higher cause newer GCC has dropped support for my CPU (they tell me update my hardware cause it wont compile) and I'm tired of fixing other people stupidity so I have yet to hear a valid reason why I should change anything.

  4. #44
    Join Date
    Sep 2009
    Posts
    1856

    Re: CNC Indexer (Arduino based)

    that old saying if it ant broke why bother.
    http://danielscnc.webs.com/

    being disabled is not a hindrance it gives you attitude
    [SIGPIC][/SIGPIC]

  5. #45
    Join Date
    Oct 2006
    Posts
    32

    Re: CNC Indexer (Arduino based)

    ???
    Attached Thumbnails Attached Thumbnails DSC_0001.jpg   DSC_0004.jpg   DSC_0005.jpg  

  6. #46
    Join Date
    Jul 2012
    Posts
    106

    Re: CNC Indexer (Arduino based)

    Quote Originally Posted by Markovic Slavol View Post
    ???
    I have just started examining the code, I am not yet aware how it calculates the number of steps per 360deg yet but I suspect that this error is based on the number of steps required to achieve 10deg and your setup doesn't give you exactly 10deg or there is an error in the code which calculates it incorrectly.

    The hardware portion of the indexer is an important and overlooked factor in the design of an inexpensive indexer product.

    Attached are some pics of some high precision/tolerance harmonic drive indexers with 200W servo motors (equivelent to a 425oz Nema23 stepper motor) that I've made due to help from a friend who helped me build some nice equipment to do this kind of work.

    These harmonic drives have a 72:1 ratio and a 42mm output shaft so strength is not a concern and cost is $135.00 from my friend

    Worm or pinion and ring gears with belt drive to offset the ratio are considered cheap but sacrifice precision and tolerances and usually have backlash which cannot be completely removed.

    Harmonic drives offer zero backlash, available in just about any ratio, can be direct driven and while it may appear to be a little more expensive, they are in fact cheaper to utilize and require less work making them the better choice.

    I'm happy to spend $135.00 for a 72:1 harmonic drive instead of $100.00 (or more) on a a set of gears from an existing indexer or even use an existing indexer because I don't want the issues of backlash and compensation to deal with and I want a simple mounting scheme that requires drilling and taping without having to deal with adjustable pinion or worm gears to correct backlash which constantly require adjustments to maintain tolerances.

    All parts were made on a DIY CNC surface grinder except the chuck adapter plate and drilled and tapped on a Harbor Freight drill press.

    Yes, an HF drill press fitted with a VFD for a single phase motor and a timing belt of 8:1 so low RPM can be achieved without loosing power and high RPM without having to change the belt, a home made tapping head made from the gears I robbed from a B&D cordless screw driver and a quick change arbor system means 100RPM for taping with a small tap is not a problem.

    Most worm gear or ring gear indexers are typically based on 90:1 ratio and while this is a common ratio, it only gives a value that is optimal for precision using a stepper motor which are really only good for about 1500RPM before the loss of torque renders them useless.

    A typical gear setup with stepper motor (90:1).
    360 / 90 = 4 (deg per turn)
    4 / 200 (steps per turn) = 0.020 (deg per step - driver set to full step)
    4 / 400 (steps per turn) = 0.010 (deg per step - driver set to half step)*
    4 / 800 (steps per turn) = 0.010 (deg per step - driver set to quarter step) (not all drivers can do this)
    4 / 1600 (steps per turn) = 0.0025 (deg per step - driver set to eighth step)
    4 / 3200 (steps per turn) = 0.00125 (deg per step - driver set to sixteenth step)
    Anything more than 1/4 step on an indexer with a stepper is too slow and the 1/2 step offers the better speed if the driver is not capable of 1/4th steps.

    I've stopped using gears in favor of inexpensive harmonic drives with the correct ratio, since I use servo's exclusively with a 2500ppr quadrature encoder I have 10,000 steps per revolution which means I have high precision/resolution with motor speeds of 3500RPM is not an issue and allow for electronic gearing to alter the number of steps per revolution for fine tuning.
    360 / 72 = 5 (deg per turn)
    5 / 10000 (steps per turn) = 0.0005 (deg per step - driver set with 1:1 gear ratio)
    5 / 5000 (steps per turn) = 0.001 (deg per step - driver set with 1:2 gear ratio)
    5 / 2500 (steps per turn) = 0.002 (deg per step - driver set with 1:4 gear ratio)
    5 / 2000 (steps per turn) = 0.0025 (deg per step - driver set with 1:5 gear ratio)
    5 / 1000 (steps per turn) = 0.005 (deg per step - driver set with 1:10 gear ratio)*
    5 / 500 (steps per turn) = 0.010 (deg per step - driver set with 1:20 gear ratio)*
    5 / 400 (steps per turn) = 0.0125 (deg per step - driver set with 1:25 gear ratio)
    5 / 250 (steps per turn) = 0.020 (deg per step - driver set with 1:40 gear ratio)
    5 / 200 (steps per turn) = 0.025 (deg per step - driver set with 1:50 gear ratio)

    Another advantage to the electronic gearing in a servo driver is that I can alter the final ratio of a harmonic drive which for example I have one that is 80:1 and I want it to be 72:1, I make the appropriate changes in settings and I have it, something difficult or impossible to do with stepper drivers.


    As a rule, I try to target the 72:1 ratio and if I use stepper motors for someone I'm making one for, I use a driver that is capable of 5th steps so I can get 1000 steps per revolution to maintain precision and speed, not found in the cheap TB6560 drivers which I'm not a big fan of.

    I would consider making the ratio provide the precision and the driver with acceptable resolution, 0.001, 0.002, 0.0025, 0.005 and 0.010 are considered acceptable resolutions but the smaller suffers speed and I've not yet encountered a project that required a precision of 0.005deg so I use this or 0.010deg as my target movement per step and work out the hardware to match.



    Since you don't give the details of your actual indexer hardware I can only conclude that your error is based on your hardware setup and that one step less the value is below 10.00deg and the code has no sanity checks to ensure that 10.00 is not exceeded which is considered bad practice but it's a hobby indexer so does it really matter when you're not dealing with high precision or would you rather it work correctly?



    Because I'm not a fan of the 1602/1604 LCD, over the next couple of weeks I will probably start with a 12864 since I have many of them on hand and in most instances they can be drop in replacements to get the system up and running.

    Then my next order of business is to get it working with a 3.95in TFT Touch, at which time I can consider solving the other issues, the touch will offer greater speed and I can probably switch to a 5in or 7in TFT Touch for that ultimate configuration but until I have something working there's no reason to start examining, rewriting and tweaking the code and time is my only hurdle since I have very little of it.

    Quote Originally Posted by daniellyall View Post
    that old saying if it ant broke why bother.
    The public releases are broke as seen by the plethora of bug-fix requests and this cannot be disputed, the friend who fixed it spent weeks rewriting the java code to solve the problems that everyone complained about, because they provide the tools in a zip file he was forced to recompile them correctly with updated software that solved the tool related issues, what anyone else does for their IDE is up to them and not my place to offer them advice or a solution if it's not working correctly for them except to fix the code and compile it yourself.

    One of the improvement he introduced is with the libraries and syntax, I can no longer call
    Code:
    #include "<Wlcd.h>"
    the reason is simple, it will attempt to load all instances of Wlcd.h which could reside in another library causing all the files of the additional library to be included in your app and either bloating it or breaking it if there is a variance in the code.

    The convention which is considered correct syntax is
    Code:
    #include "<Wlcd/Wlcd.h>"
    which solves the bloating/breaking issues since in any other environment you are required to use this syntax so it makes sense to do it this way in the IDE.


    Properly fixing the issues is the difference between someone who lives and breathes java and someone who's a weekend warrior comfortable in his own environment/platform.

    As my friend so kindly put it, each cook is comfortable with his personal tools of the trade, too many cooks in the kitchen and the cooks keep changing makes for a bad recipe and changing the JDK because some code doesn't work they way they want it to is due to laziness to write the code correctly the first time which only causes other problems to become visible as the JDK is changed and it is less tolerant to the poor programming habits of the previous developers.

    I was amazed to see that adding a single file with 55 lines of code and editing one file I was able to build the IDE 1.0.6 which targets JDK6 in JDK5 (1.5.0) and I know nothing about java, that's when my friend decided to rewrite it so it all worked correctly and I'm thankful he did.

    He also says that extending an existing class is acceptable as long as the class being extended works correctly and is transportable between platforms and this is not always the case as he's shown me code that works correctly in linux doesn't work correctly in OSX or Windows and these variances were not considered when writing the IDE since the work is based on a developer who is comfortable in his own environment/platform and not in java itself.

  7. #47
    Join Date
    Jul 2012
    Posts
    106

    Re: CNC Indexer (Arduino based)

    WOW, this is what I call well written code!!!

    There are so many issues with the library code I just don't know where to begin except first rewrite all the drivers.

    Here's a typical example of a function that isn't properly implemented:
    Code:
    //print the given string to the LCD at the current cursor position.
    void Wlcd::print(char *msg)
    {
    	char *p;
    
    	for(p=msg;*p;p++)
    		write(*p);
    }
    No wonder the thing is plagues with so many warning.
    Code:
    lcd.print("  CNC  Indexer");
    Can any guess what's wrong with this picture?

  8. #48
    Join Date
    Sep 2009
    Posts
    1856

    Re: CNC Indexer (Arduino based)

    this was done a long time ago, please stop your getting a bit rude.
    http://danielscnc.webs.com/

    being disabled is not a hindrance it gives you attitude
    [SIGPIC][/SIGPIC]

  9. #49
    Join Date
    Jul 2012
    Posts
    106

    Re: CNC Indexer (Arduino based)

    Rude???

    Pointing out the code needs major work is being interpreted as rude, different strokes for different folks I guess.

    Here's a 1 minute hack that implements a proper print function (obviously untested since it's written on the fly here)
    Code:
    void print(const char * fmt, ...) /* this should really be printf(const char * fmt,...) but we can't in Arduino IDE */
    {
    	va_list ap;
    	va_start(ap, fmt);
    	prf(fmt, ap);
    	va_end(ap);
    }
    
    void printn(u_long n, int b, int flag, int minwidth)
    {
    	char prbuf[11];
    	register char *cp;
    	int width = 0, neg = 0;
    
    	if (b == 10 && (int)n < 0)
    	{
    		neg = 1;
    		n = (unsigned)(-(int)n);
    	}
    
    	cp = prbuf;
    
    	do
    	{
            *cp++ = "0123456789abcdef0123456789ABCDEF"[(flag & 16) + n%b];
    		n /= b;
    		width++;
    	} while (n);
    	
    	if (neg)
    	{
    		write('-');
    		width++;
    	}
    	while (width++ < minwidth)
    		write( (flag & 2) ? '0' : ' ');
    		
    	do
    	{
    		write(*--cp);
    	} while (cp > prbuf);
    }
    
    void prf(char *fmt, unsigned int *adx)
    {
    	int b, c;
    	char *s;
    	int flag = width = 0;
    	int minwidth;
    
    loop:
    	while ((c = *fmt++) != '%')
    	{
    		if(c == '\0')
    			return;
    		write(c);
    	}
            minwidth = 0;
    again:
    	c = *fmt++;
    	switch (c)
    	{
    		case 'l':
    			goto again;
    		case ' ':
    			flag |= 1;
    			goto again;
    		case '0':
    			if (minwidth == 0)
    			{
    			    /* this is a flag */
    			    flag |= 2;
    			    goto again;
    			} /* fall through */
    		case '1':
    		case '2':
    		case '3':
    		case '4':
    		case '5':
    		case '6':
    		case '7':
    		case '8':
    		case '9':
    			minwidth *= 10;
    			minwidth += c - '0';
    			goto again;
    		case 'X':
                flag |= 16;
                /* fall through */
    		case 'x':
    			b = 16;
    			goto number;
    		case 'd':
    			b = 10;
    			goto number;
    		case 'o': case 'O':
    			b = 8;
    number:
    			printn((u_long)*adx, b, flag, minwidth);
    			break;
    		case 's':
    			s = (char *)*adx;
    			while (c = *s++) {
    				write(c);
    				width++;
    			}
    			while (width++ < minwidth)
    			    write(' ');
    			break;
    		case 'c':
    			write((char)*adx);
    			break;
    	}
    	adx++;
    	goto loop;
    }
    A small update since it's now been tested, a couple of minor modification to this code yielded a working solution, you're permitted to utilize the code or not at your own discretion and fix the other stuff as you see fit.

    Since I'm seen as rude, I guess I'll go off and write a version that properly works for myself since everyone seems to be content using the poorly implemented versions of the software and driver, forgive me for wanting the code to work correctly and sorry for offending anyone.



    The code I have is for the 12864, it has been replaced with the code for the 1602/1604 just for your use, here's the working 3-minute hack, it could still use the removal of the unneeded functions in Wlcd.c/Wlcd.h but obviously any additional work on my part would be grossly unappreciated so good luck to the project and good luck to everyone.

    Indexer.ino
    Code:
    /*****************************************************************************/
    /*                                                                           */
    /*                               CNC Indexer                                 */
    /*                                                                           */
    /*                          Wagner Mello May 2013                            */
    /*                                                                           */
    /*****************************************************************************/
    
    //  v5: May 17 2016 : rewrote Wlcd driver to have a proper print() and minor fixes in the code
    //  v4: July 29 2013 : Bug backlash solved
    //  V3: July 13 2013 : Bug newdeg%360 solved  
    //  V2: July 12 2013 : Bug dJog = 0 solved
    
    #include "Arduino.h"
    
    #include  
    #include 
    #include 
    
    Wlcd lcd = Wlcd(2);
    WStepper stp = WStepper();
    
    #define KRT  1
    #define KUP  2
    #define KDW  3
    #define KLF  4
    #define KSL  5
    
    #define CW   0
    #define CCW  1
    
    /*****************************************************************************/
    
    int Stt;
    
    int Cur;
    int Key;
    
    int Div;
    
    long pStp;                                    // Actual position (Steps)
    long pDeg;                                    // Actual position (Degrees x 1000)
    long cDeg;                                    // Calculated position (Degrees x 1000)
    
    long sRot;                                    // Steps per revolution
    long sBkl;                                    // Backlash (Steps)
    float sVel;                                   // Velocity (Steps/Second)
    float sAcc;                                   // Acceleration (Steps/Second²)
    
    struct Cnf
    {
    	int Mod;                                     // Mode
    	int Stp;                                     // Full steps per revolution 
    	int Mst;                                     // Microstepping mode
    	int Red;                                     // Reduction gears
    	int Mvl;                                     // Maximum velocity (Degrees/Minute)
    	int Acc;                                     // Acceleration (Degrees/Second²)
    	int Bkl;                                     // Backlash (Degres x 1000)
    	int nDiv;                                    // Division mode, number of divisions
    	long dDeg;                                   // Degree mode, step (Degrees x 1000)
    	long dJog;                                   // Jog mode step (Degrees x 1000)
    }Cnf;
    
    
    char mIni[8][17] = 
    { 
    	{"       ..       "},
    	{"      .  .      "},
    	{"     .    .     "},
    	{"    .      .    "},
    	{"   .        .   "},
    	{"  .          .  "},
    	{" .            . "},
    	{".              ."}
    };
    
    char mMdd[5][11] = 
    {
    	{"Division  "},
    	{"Degree    "},
    	{"Jog       "},
    	{"Continuous"},
    	{"Config    "}
    };
    
    char uChr[][8] = 
    {
    	{0x04,0x0a,0x04,0x00,0x00,0x00,0x00,0x00},                // 1 Degree
    	{0x04,0x0e,0x1f,0x15,0x04,0x04,0x04,0x00},                // 2 Up Arrow
    	{0x04,0x04,0x04,0x15,0x1f,0x0e,0x04,0x00},                // 3 Down Arrow
    	{0x00,0x06,0x0c,0x1f,0x0c,0x06,0x00,0x00},                // 4 Left Arrow
    	{0x00,0x0c,0x06,0x1f,0x06,0x0c,0x00,0x00},                // 5 Right Arrow
    	{0x01,0x01,0x05,0x09,0x1f,0x08,0x04,0x00},                // 6 Return
    	{0x06,0x09,0x02,0x04,0x0f,0x00,0x00,0x00}                 // 7 Power 2
    };
    
    
    /*****************************************************************************/
    
    
    void setup()
    { 
    	Stt = 0;
    	Key = 0;
    
    	ReadCnf();
    
    	lcd.init();
    
    	IniUsrChar();
    
    	Cnf.Mod = max(0,min(Cnf.Mod,4));
    	Cnf.Stp = max(1,min(Cnf.Stp,999));
    	Cnf.Mst = max(1,min(Cnf.Mst,999));
    	Cnf.Red = max(1,min(Cnf.Red,999));
    	Cnf.Mvl = max(1,min(Cnf.Mvl,9999));
    	Cnf.Acc = max(1,min(Cnf.Acc,999));
    	Cnf.Bkl = max(0,min(Cnf.Bkl,9999));
    	Cnf.nDiv = max(1,min(Cnf.nDiv,999));
    	Cnf.dDeg = max(1,min(Cnf.dDeg,359999));
    	Cnf.dJog = max(1,min(Cnf.dJog,100000));
    	sRot = (long)Cnf.Stp*(long)Cnf.Mst*(long)Cnf.Red;
    	sBkl = (lround)((float)Cnf.Bkl/360000.0*float(sRot));  
    	sVel = (float)Cnf.Mvl/360.0*float(sRot)/60.0;                                  
    	sAcc = (float)Cnf.Acc/360.0*float(sRot);                                    
    
    	stp.Init(sVel,sAcc);
    
    	f00();
    }
    
    
    void loop()
    {
    	int k;
    	
    	if((k = GetKey()) != 0)
    	{
    		switch(Stt)
    		{
    			case 00:
    				f00();
    				break;
    			case 10:
    				f10();
    				break;
    			case 11:
    				f11(k);
    				break;
    			case 20:
    				f20();
    				break;
    			case 21:
    				f21(k);
    				break;
    			case 22:
    				f22();
    				break;
    			case 23:
    				f23(k);
    				break;
    			case 30:
    				f30();
    				break;
    			case 31:
    				f31(k);
    				break;
    			case 32:
    				f32();
    				break;
    			case 33:
    				f33(k);
    				break;
    			case 40:
    				f40();
    				break;
    			case 41:
    				f41(k);
    				break;
    			case 50:
    				f50();
    				break;
    			case 51:
    				f51(k);
    				break;
    			case 60:
    				f60();
    				break;
    			case 61:
    				f61(k);
    				break;
    			case 62:
    				f62();
    				break;
    			case 63:
    				f63(k);
    				break;
    			case 64:
    				f64();
    				break;
    			case 65:
    				f65(k);
    				break;
    			case 66:
    				f66();
    				break;
    			case 67:
    				f67(k);
    				break;
    			case 68:
    				f68();
    				break;
    			case 69:
    				f69(k);
    				break;
    			case 70:
    				f70();
    				break;
    			case 71:
    				f71(k);
    				break;
    		}
    	}
    }
    
    
    /*****************************************************************************/
    
    
    void f00(void)                               // Start Screen
    {
    	int i,j;
    	
    	lcd.clear();
    
    	lcd.cursor(0);
    	print("  CNC  Indexer");
    
    	for(i = 0; i < 24; i++)
    	{
    		j = ((i<8)?i:((i<16)?7-(i-8):i-16));
    		lcd.cursorTo(1,0);
    		print("%d",mIni[j]);
    	}
    
    	lcd.cursorTo(1,0);
    	print("          Start\6");
    
    	Stt = 10;
    }
    
    
    void f10(void)                               // Mode Screen
    { 
    	char buf[32];
    	
    	lcd.clear();
    
    	sprintf(buf,"Mode:%s?",mMdd[Cnf.Mod]);
    	print(buf); 
    
    	lcd.cursorTo(1,0); 
    	print("\4Bk \2Select\3 \6Ac");
    
    	lcd.cursorTo(0,15); 
    	lcd.cursor(1);
    
    	Stt = 11;
    }
    
    
    void f11(int key)                            // Mode Selection
    {
    	switch(key)
    	{
    		case KUP:
    			Cnf.Mod--;
    			if(Cnf.Mod<0)
    				Cnf.Mod = 4;
    			lcd.cursorTo(0,5);              
    			print(mMdd[Cnf.Mod]);
    			break; 
    		case KDW:
    			Cnf.Mod++;
    			if(Cnf.Mod>4)
    				Cnf.Mod = 0;
    			lcd.cursorTo(0,5);              
    			print(mMdd[Cnf.Mod]); 
    			break;
    		case KLF:
    			f00();                           // Start Screen
    			break;  
    		case KRT:
    		case KSL:
    			SaveCnf();
    			switch(Cnf.Mod)
    			{
    				case 0:f20();break; 
    				case 1:f30();break; 
    				case 2:f40();break;
    				case 3:f50();break;
    				case 4:f60();break;
    			}
    			break;  
    	}
    }
    
    
    void f20(void)                               // Division Edit Screen
    {
    	char buf[32];
    	
    	lcd.clear();
    
    	sprintf(buf,"nDiv:%.3d       ?",Cnf.nDiv);
    	print(buf); 
    
    	lcd.cursorTo(1,0); 
    	print("\4Sel\5 \2Edit\3 \6Ac");  
    
    	lcd.cursorTo(0,7); 
    	lcd.cursor(1);
    
    	Stt = 21;
    	Cur = 0;
    }
    
    
    void f21(int key)                            // Division Edit Key
    {
    	char buf[16];
    	
    	switch(key)
    	{
    		case KUP:
    			switch(Cur)
    			{
    				case 0:Cnf.nDiv += 1;  break;
    				case 1:Cnf.nDiv += 10; break;
    				case 2:Cnf.nDiv += 100;break;
    			}
    			if(Cnf.nDiv >= 1000)
    				Cnf.nDiv -= 1000;
    			Cnf.nDiv = max(1,Cnf.nDiv);             
    			sprintf(buf,"%.3d",Cnf.nDiv);
    			lcd.cursorTo(0,5); 
    			print(buf);              
    			lcd.cursorTo(0,7-Cur);
    			break; 
    		case KDW:
    			switch(Cur)
    			{
    				case 0:Cnf.nDiv -= 1;  break;
    				case 1:Cnf.nDiv -= 10; break;
    				case 2:Cnf.nDiv -= 100;break;
    			}
    			if(Cnf.nDiv <= 0)
    				Cnf.nDiv += 1000;
    			Cnf.nDiv = min(Cnf.nDiv,999);
    			sprintf(buf,"%.3d",Cnf.nDiv);
    			lcd.cursorTo(0,5); 
    			print(buf);              
    			lcd.cursorTo(0,7-Cur);
    			break; 
    		case KLF:
    			Cur++;
    			if(Cur>2)
    				Cur = 0;
    			lcd.cursorTo(0,7-Cur);
    			break;  
    		case KRT:
    			Cur--;
    			if(Cur<0)
    				Cur = 2;
    			lcd.cursorTo(0,7-Cur);
    			break;  
    		case KSL:
    			SaveCnf();
    			f22();
    			break; 
    	}
    }
    
    
    void f22(void)                               // Division Exec Screen
    {
    	char buf[32];
    
    	Div = 0;
    	pStp = 0;
    	pDeg = 0;
    	cDeg = 0;
    
    	lcd.clear();
    
    	lcd.cursor(0);
    	sprintf(buf,"Div:%d/%d",Div,Cnf.nDiv);
    	print(buf); 
    
    	lcd.cursorTo(0,13); 
    	print("\6Bk");  
    
    	lcd.cursorTo(1,0);
    	print("\4Index\5");
    
    	lcd.cursorTo(1,8);
    	PrintDeg();
    
    	Stt = 23;
    }
    
    
    void f23(int key)                            // Division Exec Key
    {
    	int f;
    	char buf[16];
    
    	f = -1;
    	switch(key)
    	{
    		case KUP:
    		case KRT:
    			Div++;
    			if(Div >= Cnf.nDiv)
    				Div = 0;
    			f = CW;
    			break;
    		case KDW:
    		case KLF:
    			Div--;
    			if(Div<0)
    				Div = Cnf.nDiv-1;
    			f = CCW;
    			break;
    		case KSL:
    			f10();
    			break;
    	}
    	if(f >= 0)
    	{
    		lcd.cursorTo(0,4);
    		print(".......");
    
    		lcd.cursorTo(1,8);
    		print("........");
    
    		Index(Cnf.Mod,f,Div,Cnf.nDiv,Cnf.dDeg,Cnf.dJog);
    
    		lcd.cursorTo(0,4);
    		print("       ");
    
    		lcd.cursorTo(0,4);
    		sprintf(buf,"%d/%d",Div,Cnf.nDiv);
    		print(buf);
    
    		lcd.cursorTo(1,8);
    		PrintDeg();
    	}
    }
    
    
    void f30(void)                               // Degree Edit Screen
    {
    	char buf[32];
    
    	lcd.clear();
    
    	sprintf(buf,"dDeg:%.3ld.%.3ld\1   ?",Cnf.dDeg/1000,Cnf.dDeg%1000);
    	print(buf);
    
    	lcd.cursorTo(1,0);
    	print("\4Sel\5 \2Edit\3 \6Ac");
    
    	lcd.cursorTo(0,7);
    	lcd.cursor(1);
    
    	Stt = 31;
    	Cur = 4;
    }
    
    
    void f31(int key)                            // Degree Edit Key
    {
    	char buf[16];
    
    	switch(key)
    	{
    		case KUP:
    			switch(Cur)
    			{
    				case 0:
    					Cnf.dDeg += 1;
    					break;
    				case 1:
    					Cnf.dDeg += 10;
    					break;
    				case 2:
    					Cnf.dDeg += 100;
    					break;
    				case 4:
    					Cnf.dDeg += 1000;
    					break;
    				case 5:
    					Cnf.dDeg += 10000;
    					break;
    				case 6:
    					Cnf.dDeg += 100000;
    					break;
    			}
    			if(Cnf.dDeg >= 360000)
    				Cnf.dDeg -= 360000;
    			Cnf.dDeg = max(1,Cnf.dDeg);
    			sprintf(buf,"%.3ld.%.3ld\1",Cnf.dDeg/1000,Cnf.dDeg%1000);
    			lcd.cursorTo(0,5);
    			print(buf);
    			lcd.cursorTo(0,11-Cur);
    			break;
    		case KDW:
    			switch(Cur)
    			{
    				case 0:Cnf.dDeg -= 1;     break;
    				case 1:Cnf.dDeg -= 10;    break;
    				case 2:Cnf.dDeg -= 100;   break;
    				case 4:Cnf.dDeg -= 1000;  break;
    				case 5:Cnf.dDeg -= 10000; break;
    				case 6:Cnf.dDeg -= 100000;break;
    			}
    			if(Cnf.dDeg <= 0)
    				Cnf.dDeg += 360000;
    			Cnf.dDeg = min(Cnf.dDeg,359999);
    			sprintf(buf,"%.3ld.%.3ld\1",Cnf.dDeg/1000,Cnf.dDeg%1000);
    			lcd.cursorTo(0,5); 
    			print(buf);
    			lcd.cursorTo(0,11-Cur);
    			break; 
    		case KLF:
    			Cur++;
    			if(Cur  == 3)
    				Cur++;
    			if(Cur>6)
    				Cur = 0;
    			lcd.cursorTo(0,11-Cur);
    			break;  
    		case KRT:
    			Cur--;
    			if(Cur  == 3)
    				Cur--;
    			if(Cur<0)
    				Cur = 6;
    			lcd.cursorTo(0,11-Cur);
    			break;  
    		case KSL:
    			SaveCnf();
    			f32();
    			break; 
    	}
    }
    
    
    void f32(void)                               // Degree Exec Screen
    {
    	char buf[32];
    
    	Div = 0;
    	pStp = 0;
    	pDeg = 0;
    	cDeg = 0;
    
    	lcd.clear();
    
    	lcd.cursor(0);
    	sprintf(buf,"P:%dx%ld.%.3ld\1",Div,Cnf.dDeg/1000,Cnf.dDeg%1000);
    	print(buf);
    
    	lcd.cursorTo(0,13); 
    	print("\6Bk");  
    
    	lcd.cursorTo(1,0); 
    	print("\4Index\5"); 
    
    	lcd.cursorTo(1,8);
    	PrintDeg();
    
    	Stt = 33;
    }
    
    
    void f33(int key)                            // Degree Exec Key
    {
    	int f;
    	char buf[16];
    
    	f = -1;
    	switch(key)
    	{
    		case KUP:
    		case KRT:
    			Div++;
    			f = CW;
    			break;
    		case KDW:
    		case KLF:
    			Div--;
    			f = CCW;
    			break;
    		case KSL:
    			f10();
    			break;
    	}
    	if(f >= 0)
    	{
    		lcd.cursorTo(0,2);
    		print("...........");
    
    		lcd.cursorTo(1,8);
    		print("........");
    
    		Index(Cnf.Mod,f,Div,Cnf.nDiv,Cnf.dDeg,Cnf.dJog);
    
    		lcd.cursorTo(0,2);
    		print("           ");
    
    		lcd.cursorTo(0,2);
    		sprintf(buf,"%dx%ld.%.3ld\1",Div,Cnf.dDeg/1000,Cnf.dDeg%1000);
    		print(buf);
    
    		lcd.cursorTo(1,8);
    		PrintDeg();
    	}
    }
    
    
    void f40(void)                               // Jog Exec Screen
    {
    	char buf[32];
    
    	Div = 0;
    	pStp = 0;
    	pDeg = 0;
    	cDeg = 0;
    	lcd.clear();
    
    	lcd.cursor(0);
    	sprintf(buf,"J\2\3:%.3ld.%.3ld\1",Cnf.dJog/1000,Cnf.dJog%1000);
    	print(buf);
    
    	lcd.cursorTo(0,13);
    	print("\6Bk");
    
    	lcd.cursorTo(1,0);
    	print("\4Index\5");
    
    	lcd.cursorTo(1,8);
    	PrintDeg();
    
    	Stt = 41;
    }
    
    
    void f41(int key)                            // Jog Exec Key
    {
    	int f = -1;
    	char buf[16];
    
    	switch(key)
    	{
    		case KUP:
    			Cnf.dJog *= 10;
    			if(Cnf.dJog>100000)
    				Cnf.dJog = 1;
    			sprintf(buf,"%.3ld.%.3ld\1",Cnf.dJog/1000,Cnf.dJog%1000);
    			lcd.cursorTo(0,4);
    			print(buf);
    			break;
    		case KRT:
    			Div++;
    			f = CW;
    			break;
    		case KDW:
    			Cnf.dJog /= 10;
    			if(Cnf.dJog <= 0)
    				Cnf.dJog = 100000;
    			sprintf(buf,"%.3ld.%.3ld\1",Cnf.dJog/1000,Cnf.dJog%1000);
    			lcd.cursorTo(0,4);
    			print(buf);
    			break;
    		case KLF:
    			Div--;
    			f = CCW;
    			break;
    		case KSL:
    			SaveCnf();
    			f10();
    			break;
    	}
    	if(f >= 0)
    	{
    		lcd.cursorTo(1,8);
    		print("........");
    
    		Index(Cnf.Mod,f,Div,Cnf.nDiv,Cnf.dDeg,Cnf.dJog);
    
    		lcd.cursorTo(1,8);
    		PrintDeg();
    	}
    }
    
    
    void f50(void)                               // Continuous Exec Screen
    {
    	Div = 0;
    	pStp = 0;
    	pDeg = 0;
    	cDeg = 0;
    	lcd.clear();
    
    	lcd.cursor(0);
    	print("Continuous");
    
    	lcd.cursorTo(0,13);
    	print("\6Bk");
    
    	lcd.cursorTo(1,0);
    	print("\4Index\5");
    
    	lcd.cursorTo(1,8);
    	PrintDeg();
    
    	Stt = 51;
    }
    
    
    void f51(int key)                            // Continuous Exec Key
    {
    	int f;
    // char buf[16];
    
    	f = -1;
    	switch(key)
    	{
    		case KUP:
    		case KRT:
    			f = CW;
    			break;
    		case KDW:
    		case KLF:
    			f = CCW;
    			break;
    		case KSL:
    			f10();
    			break;
    	}
    	if(f >= 0)
    	{
    		lcd.cursorTo(1,8);
    		print("........");
    
    		Index(Cnf.Mod,f,Div,Cnf.nDiv,Cnf.dDeg,Cnf.dJog);
    
    		lcd.cursorTo(1,8);
    		PrintDeg();
    	}
    }
    
    
    void f60(void)                               // Config Steps/Rev Screen
    {
    	char buf[32];
    
    	lcd.clear();
    
    	sprintf(buf,"Steps/Rev:%.3d  ?", Cnf. Stp);
    	print(buf);
    
    	lcd.cursorTo(1,0);
    	print("\4Sel\5 \2Edit\3 \6Ac");
    
    	lcd.cursorTo(0,12);
    	lcd.cursor(1);
    
    	Stt = 61;
    	Cur = 0;
    }
    
    
    void f61(int key)                            // Config Steps/Rev Edit Key
    {
    	char buf[16];
    	
    	switch(key)
    	{
    		case KUP:
    			switch(Cur)
    			{
    				case 0:Cnf.Stp += 1;  break;
    				case 1:Cnf.Stp += 10; break;
    				case 2:Cnf.Stp += 100;break;
    			}
    			if(Cnf.Stp >= 1000)
    				Cnf.Stp -= 1000;
    			Cnf.Stp = max(1,Cnf.Stp);             
    			sprintf(buf,"%.3d",Cnf.Stp);
    			lcd.cursorTo(0,10); 
    			print(buf);              
    			lcd.cursorTo(0,12-Cur);
    			break; 
    		case KDW:
    			switch(Cur)
    			{
    				case 0:Cnf.Stp -= 1;  break;
    				case 1:Cnf.Stp -= 10; break;
    				case 2:Cnf.Stp -= 100;break;
    			}
    			if(Cnf.Stp <= 0)
    				Cnf.Stp += 1000;
    			Cnf.Stp = min(Cnf.Stp,999);
    			sprintf(buf,"%.3d",Cnf.Stp);
    			lcd.cursorTo(0,10); 
    			print(buf);              
    			lcd.cursorTo(0,12-Cur);
    			break; 
    		case KLF:
    			Cur++;
    			if(Cur>2)
    				Cur = 0;
    			lcd.cursorTo(0,12-Cur);
    			break;  
    		case KRT:
    			Cur--;
    			if(Cur<0)
    				Cur = 2;
    			lcd.cursorTo(0,12-Cur);
    			break;  
    		case KSL:
    			f62();
    			break; 
    	}
    }
    
    
    void f62(void)                               // Config MicroStep Screen
    {
    	char buf[32];
    
    	lcd.clear();
    
    	sprintf(buf,"MicroStep:%.3d  ?",Cnf.Mst);
    	print(buf);
    
    	lcd.cursorTo(1,0);
    	print("\4Sel\5 \2Edit\3 \6Ac");
    
    	lcd.cursorTo(0,12);
    	lcd.cursor(1);
    
    	Stt = 63;
    	Cur = 0;
    }
    
    
    void f63(int key)                            // Config MicroStep Edit Key
    {
    	char buf[16];
    	
    	switch(key)
    	{
    		case KUP:
    			switch(Cur)
    			{
    				case 0:Cnf.Mst += 1;  break;
    				case 1:Cnf.Mst += 10; break;
    				case 2:Cnf.Mst += 100;break;
    			}
    			if(Cnf.Mst >= 1000)
    				Cnf.Mst -= 1000;
    			Cnf.Mst = max(1,Cnf.Mst);
    			sprintf(buf,"%.3d",Cnf.Mst);
    			lcd.cursorTo(0,10);
    			print(buf);              
    			lcd.cursorTo(0,12-Cur);
    			break; 
    		case KDW:
    			switch(Cur)
    			{
    				case 0:Cnf.Mst -= 1;  break;
    				case 1:Cnf.Mst -= 10; break;
    				case 2:Cnf.Mst -= 100;break;
    			}
    			if(Cnf.Mst <= 0)
    				Cnf.Mst += 1000;
    			Cnf.Mst = min(Cnf.Mst,999);
    			sprintf(buf,"%.3d",Cnf.Mst);
    			lcd.cursorTo(0,10); 
    			print(buf);              
    			lcd.cursorTo(0,12-Cur);
    			break; 
    		case KLF:
    			Cur++;
    			if(Cur>2)
    				Cur = 0;
    			lcd.cursorTo(0,12-Cur);
    			break;
    		case KRT:
    			Cur--;
    			if(Cur<0)
    				Cur = 2;
    			lcd.cursorTo(0,12-Cur);
    			break;  
    		case KSL:
    			f64();
    			break; 
    	}
    }
    
    
    void f64(void)                               // Config Reduction Screen
    {
    	char buf[32];
    
    	lcd.clear();
    
    	sprintf(buf,"Reductn 1:%.3d  ?",Cnf.Red);
    	print(buf);
    	lcd.cursorTo(1,0);
    	print("\4Sel\5 \2Edit\3 \6Ac");
    	lcd.cursorTo(0,12);
    	lcd.cursor(1);
    	Stt = 65;
    	Cur = 0;
    }
    
    
    void f65(int key)                            // Config Reduction Edit Key
    {
    	char buf[16];
    	
    	switch(key)
    	{
    		case KUP:
    			switch(Cur)
    			{
    				case 0:Cnf.Red += 1;  break;
    				case 1:Cnf.Red += 10; break;
    				case 2:Cnf.Red += 100;break;
    			}
    			if(Cnf.Red >= 1000)
    				Cnf.Red -= 1000;
    			Cnf.Red = max(1,Cnf.Red);
    			sprintf(buf,"%.3d",Cnf.Red);
    			lcd.cursorTo(0,10); 
    			print(buf);              
    			lcd.cursorTo(0,12-Cur);
    			break; 
    		case KDW:
    			switch(Cur)
    			{
    				case 0:Cnf.Red -= 1;  break;
    				case 1:Cnf.Red -= 10; break;
    				case 2:Cnf.Red -= 100;break;
    			}
    			if(Cnf.Red <= 0)
    				Cnf.Red += 1000;
    			Cnf.Red = min(Cnf.Red,999);
    			sprintf(buf,"%.3d",Cnf.Red);
    			lcd.cursorTo(0,10); 
    			print(buf);              
    			lcd.cursorTo(0,12-Cur);
    			break; 
    		case KLF:
    			Cur++;
    			if(Cur>2)
    				Cur = 0;
    			lcd.cursorTo(0,12-Cur);
    			break;  
    		case KRT:
    			Cur--;
    			if(Cur<0)
    				Cur = 2;
    			lcd.cursorTo(0,12-Cur);
    			break;  
    		case KSL:
    			f66();
    			break; 
    	}
    }
    
    
    void f66(void)                               // Config MaxVel Screen
    {
    	char buf[32];
    
    	lcd.clear();
    
    	sprintf(buf,"MxVl(\1/M):%.4d ?",Cnf.Mvl);
    	print(buf);
    
    	lcd.cursorTo(1,0);
    	print("\4Sel\5 \2Edit\3 \6Ac");
    
    	lcd.cursorTo(0,13);
    	lcd.cursor(1);
    
    	Stt = 67;
    	Cur = 0;
    }
    
    
    void f67(int key)                            // Config MaxVel Edit Key
    {
    	char buf[16];
    	
    	switch(key)
    	{
    		case KUP:
    				switch(Cur)
    					{
    				case 0:Cnf.Mvl += 1;   break;
    				case 1:Cnf.Mvl += 10;  break;
    				case 2:Cnf.Mvl += 100; break;
    				case 3:Cnf.Mvl += 1000;break;
    					}
    				if(Cnf.Mvl >= 10000)
    					Cnf.Mvl -= 10000;
    				Cnf.Mvl = max(1,Cnf.Mvl);
    				sprintf(buf,"%.4d",Cnf.Mvl);
    				lcd.cursorTo(0,10); 
    				print(buf);              
    				lcd.cursorTo(0,13-Cur);
    				break; 
    		case KDW:
    				switch(Cur)
    					{
    				case 0:Cnf.Mvl -= 1;   break;
    				case 1:Cnf.Mvl -= 10;  break;
    				case 2:Cnf.Mvl -= 100; break;
    				case 3:Cnf.Mvl -= 1000;break;
    					}
    				if(Cnf.Mvl <= 0)
    					Cnf.Mvl += 10000;
    				Cnf.Mvl = min(Cnf.Mvl,9999);
    				sprintf(buf,"%.4d",Cnf.Mvl);
    				lcd.cursorTo(0,10); 
    				print(buf);
    				lcd.cursorTo(0,13-Cur);
    				break; 
    		case KLF:
    				Cur++;
    				if(Cur>3)
    					Cur = 0;
    				lcd.cursorTo(0,13-Cur);
    				break;  
    		case KRT:
    				Cur--;
    				if(Cur<0)
    					Cur = 3;
    				lcd.cursorTo(0,13-Cur);
    				break;  
    		case KSL:
    				f68();
    				break; 
    	}
    }
    
    
    void f68(void)                               // Config Acceleration Screen
    {
    	char buf[32];
    
    	lcd.clear();
    
    	sprintf(buf,"Acc(\1/s\7):%.3d  ?",Cnf.Acc);
    	print(buf);
    	lcd.cursorTo(1,0);
    	print("\4Sel\5 \2Edit\3 \6Ac");
    	lcd.cursorTo(0,12);
    	lcd.cursor(1);
    	Stt = 69;
    	Cur = 0;
    }
    
    
    void f69(int key)                            // Config Acceleration Edit Key
    {
    	char buf[16];
    	
    	switch(key)
    	{
    		case KUP:
    			switch(Cur)
    			{
    				case 0:Cnf.Acc += 1;   break;
    				case 1:Cnf.Acc += 10;  break;
    				case 2:Cnf.Acc += 100; break;
    			}
    			if(Cnf.Acc >= 1000)
    				Cnf.Acc -= 1000;
    			Cnf.Acc = max(1,Cnf.Acc);
    			sprintf(buf,"%.3d",Cnf.Acc);
    			lcd.cursorTo(0,10); 
    			print(buf);              
    			lcd.cursorTo(0,12-Cur);
    			break; 
    		case KDW:
    			switch(Cur)
    			{
    				case 0:Cnf.Acc -= 1;   break;
    				case 1:Cnf.Acc -= 10;  break;
    				case 2:Cnf.Acc -= 100; break;
    			}
    			if(Cnf.Acc <= 0)
    				Cnf.Acc += 1000;
    			Cnf.Acc = min(Cnf.Acc,999);
    			sprintf(buf,"%.3d",Cnf.Acc);
    			lcd.cursorTo(0,10); 
    			print(buf);              
    			lcd.cursorTo(0,12-Cur);
    			break; 
    		case KLF:
    			Cur++;
    			if(Cur>2)
    				Cur = 0;
    			lcd.cursorTo(0,12-Cur);
    			break;  
    		case KRT:
    			Cur--;
    			if(Cur<0)
    				Cur = 2;
    			lcd.cursorTo(0,12-Cur);
    			break;
    		case KSL:
    			f70();
    			break;
    	}
    }
    
    
    void f70(void)                               // Config Backlash Screen
    {
    	char buf[32];
    
    	lcd.clear();
    
    	sprintf(buf,"Bcklsh(\1):%.1d.%.3d?",Cnf.Bkl/1000,Cnf.Bkl%1000);
    	print(buf);
    
    	lcd.cursorTo(1,0);
    	print("\4Sel\5 \2Edit\3 \6Ac");
    
    	lcd.cursorTo(0,14);
    	lcd.cursor(1);
    
    	Stt = 71;
    	Cur = 0;
    }
    
    
    void f71(int key)                            // Config Backlash Edit Key
    {
    	char buf[8];
    	
    	switch(key)
    	{
    		case KUP:
    			switch(Cur)
    			{
    				case 0:
    					Cnf.Bkl += 1;
    					break;
    				case 1:
    					Cnf.Bkl += 10;
    					break;
    				case 2:
    					Cnf.Bkl += 100;
    					break;
    				case 4:
    					Cnf.Bkl += 1000;
    					break;
    			}
    			if(Cnf.Bkl >= 10000)
    				Cnf.Bkl -= 10000;
    			Cnf.Bkl = max(0,Cnf.Bkl);
    			sprintf(buf,"%.1d.%.3d?",Cnf.Bkl/1000,Cnf.Bkl%1000);
    			lcd.cursorTo(0,10);
    			print(buf);
    			lcd.cursorTo(0,14-Cur);
    			break;
    		case KDW:
    			switch(Cur)
    			{
    				case 0:
    					Cnf.Bkl -= 1;
    					break;
    				case 1:
    					Cnf.Bkl -= 10;
    					break;
    				case 2:
    					Cnf.Bkl -= 100;
    					break;
    				case 4:
    					Cnf.Bkl -= 1000;
    					break;
    			}
    				if(Cnf.Bkl<0)
    					Cnf.Bkl += 10000;
    				Cnf.Bkl = min(Cnf.Bkl,9999);
    				sprintf(buf,"%.1d.%.3d?",Cnf.Bkl/1000,Cnf.Bkl%1000);
    				lcd.cursorTo(0,10);
    				print(buf);
    				lcd.cursorTo(0,14-Cur);
    				break;
    		case KLF:
    				Cur++;
    				if(Cur  == 3)
    					Cur++;
    				if(Cur>4)
    					Cur = 0;
    				lcd.cursorTo(0,14-Cur);
    				break;  
    		case KRT:
    			Cur--;
    			if(Cur  == 3)
    				Cur--;
    			if(Cur<0)
    				Cur = 4;
    			lcd.cursorTo(0,14-Cur);
    			break;
    		case KSL:
    			SaveCnf();
    			sRot = (long)Cnf.Stp*(long)Cnf.Mst*(long)Cnf.Red;
    			sBkl = (lround)((float)Cnf.Bkl/360000.0*float(sRot));  
    			sVel = (float)Cnf.Mvl/360.0*float(sRot)/60.0;                                  
    			sAcc = (float)Cnf.Acc/360.0*float(sRot);                                    
    			stp.Init(sVel,sAcc);
    			f10();
    			break;
    	}
    }
    
    
    /*****************************************************************************/
    
    
    int GetKey(void)
    {
    	int k;
    	
    	k = lcd.getkey();
    	if(k != Key)
    	{
    		delay(50);									
    		k = lcd.getkey();                                  
    		if(k != Key)
    		return(Key = k);
    	}
    	return(0);
    }
    
    
    void IniUsrChar(void)
    {
    	int i;
    	
    	for(i = 0;i<7;i++)
    	lcd.customChr(i+1,uChr[i]);
    }
    
    
    void PrintDeg(void)
    {
    	char buf[16];
    	
    	sprintf(buf,"%3ld.%.3ld\1",pDeg/1000,pDeg%1000);
    	print(buf);
    }
    
    
    void ReadCnf(void)
    {
    	int i,n;
    	unsigned char *p;
    	
    	n = sizeof(struct Cnf);
    	p = (unsigned char *)&Cnf;
    	for(i = 0;i2)||(newpos != curpos))
    	{
    		if(mod<3)
    		{
    			if(dir)
    				stptgo = curpos-newpos;
    			else
    				stptgo = newpos-curpos;
    			if(stptgo<0)
    				stptgo += stprot;
    			if(stptgo >= stprot)
    				stptgo -= stprot;
    			if(dir)
    				stptgo += sBkl;
    		}
    		else
    			stptgo = 1E9;
    
    		stp.Set(dir,stptgo);
    		if(mod<3)
    			while(stp.Run());
    		else
    		{
    			while(lcd.digkey())
    			stp.Run();
    			stp.Stop();
    			while(stp.Run());
    		}
    		stpgon = stp.Gone();
    		if(dir)
    			if(sBkl>0)
    			{
    				stptgo = min(stpgon,sBkl);
    				if(stptgo)
    				{
    					stp.Set(0,stptgo);
    					while(stp.Run());
    					stpgon -= stp.Gone();
    				}
    			}
    		if(dir)
    			newpos = curpos-stpgon;
    		else
    		newpos = curpos+stpgon;
    		if(newpos<0)
    			newpos += stprot;
    		if(newpos >= stprot)
    			newpos -= stprot;
    		pDeg = lround((float)newpos/(float)stprot*360000.0);
    		pStp = newpos;
    	}
    	cDeg = newdeg;
    }
    Wlcd.cpp
    Code:
    /*
    
    Modified by Wagner May 25, 2013
    
    LCD4Bit v0.1 16/Oct/2006 neillzero http://abstractplain.net
    
    What is this?
    An arduino library for comms with HD44780-compatible LCD, in 4-bit mode (saves pins)
    
    Sources:
    - The original "LiquidCrystal" 8-bit library and tutorial
    		 http://www.arduino.cc/en/uploads/Tutorial/LiquidCrystal.zip
    		 http://www.arduino.cc/en/Tutorial/LCDLibrary
    - DEM 16216 datasheet http://www.maplin.co.uk/Media/PDFs/N27AZ.pdf
    - Massimo's suggested 4-bit code (I took initialization from here) http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1144924220/8
    See also:
    - glasspusher's code (probably more correct): http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1160586800/0#0
    
    Tested only with a DEM 16216 (maplin "N27AZ" - http://www.maplin.co.uk/Search.aspx?criteria=N27AZ)
    If you use this successfully, consider feeding back to the arduino wiki with a note of which LCD it worked on.
    
    Usage:
    see the examples folder of this library distribution.
    
    */
    
    #include "Wlcd.h"
    
    #include "Wprint.h"
    
    int KA=0;
    int KD0=11;
    int KD1=12;
    
    int EN=9;
    int RS=8;
    int DB[]={4,5,6,7};
    int KB[]={30,150,360,535,760};
    
    //--------------------------------------------------------
    
    //how many lines has the LCD? (don't change here - specify on calling constructor)
    int GnLines=2;
    
    
    //constructor.  num_lines must be 1 or 2, currently.
    
    Wlcd::Wlcd(int nLines)
    {
    	GnLines=max(1,min(nLines,2));
    }
    
    
    // initiatize lcd after a short pause
    //while there are hard-coded details here of lines, cursor and blink settings, you can override these original settings after calling .init()
    
    void Wlcd::init()
    {
    	pinMode(EN,OUTPUT);
    	pinMode(RS,OUTPUT);
    	pinMode(DB[0],OUTPUT);
    	pinMode(DB[1],OUTPUT);
    	pinMode(DB[2],OUTPUT);
    	pinMode(DB[3],OUTPUT);
    	digitalWrite(EN,LOW);
    	delay(50);
    
    	//The first 4 nibbles and timings are not in my DEM16217 SYH datasheet, but apparently are HD44780 standard...
    	commandWriteNibble(0x03);
    	delay(5);
    
    	commandWriteNibble(0x03);
    	delayMicroseconds(100);
    	commandWriteNibble(0x03);
    	delay(5);
    
    	// needed by the LCDs controller
    	//this being 2 sets up 4-bit mode.
    	commandWriteNibble(0x02);
    	commandWriteNibble(0x02);
    
    	//todo: make configurable by the user of this library.
    	//NFXX where
    	//N = num lines (0=1 line or 1=2 lines).
    	//F= format (number of dots (0=5x7 or 1=5x10)).
    	//X=don't care
    	int num_lines_ptn = GnLines - 1 << 3;
    	int dot_format_ptn = 0x00;      //5x7 dots.  0x04 is 5x10
    
    	commandWriteNibble(num_lines_ptn | dot_format_ptn);
    	delayMicroseconds(60);
    
    	//The rest of the init is not specific to 4-bit mode.
    	//NOTE: we're writing full bytes now, not nibbles.
    
    	// display control: display on, cursor off, no blinking
    	commandWrite(CMD_CTRL);
    	delayMicroseconds(60);
    	//clear display
    	commandWrite(0x01);
    	delay(3);
    
    	// entry mode set: 06
    	// increment automatically, display shift, entire shift off
    	commandWrite(0x06);
    
    	delay(1);//TODO: remove unnecessary delays
    }
    
    
    //send the clear screen command to the LCD
    
    void Wlcd::clear()
    {
    	commandWrite(CMD_CLAR);
    }
    
    
    //write the given character at the current cursor position. overwrites, doesn't insert.
    
    void Wlcd::write(char value)
    {
    	digitalWrite(RS,HIGH);                 //set the RS pin to show we're writing data
    	pushByte(value);
    }
    
    
    //turns cursor blinking on/off
    void Wlcd::cursor(int atv)
    {
    	commandWrite(CMD_CTRL|atv);
    }
    
    
    //move the cursor to the given absolute position.  line numbers start at 1.
    //if this is not a 2-line LCD4Bit_mod instance, will always position on first line.
    
    void Wlcd::cursorTo(int y,int x)
    {
    	int i;
    
    	commandWrite(CMD_HOME);          //first, put cursor home
    	y=min(y,GnLines-1);              //if we are on a 1-line display, set line_num to 1st line, regardless of given
    	if(y)
    		x+=40;                          //offset 40 chars in if second line requested
    	for(i=0;i>4;
    	lower=byte&0x0F;
    	pushNibble(upper);
    	pushNibble(lower);
    }
    
    
    //push a nibble of data through the the LCD's DB4~7 pins, clocking with the Enable pin.
    
    void Wlcd::pushNibble(char byte)
    {
    	int i;
    	char nibble;
    
    	nibble=byte&0x0F;
    	for(i=0;i<4;i++)
    		{
    		digitalWrite(DB[i],nibble&01);
    		nibble>>=1;
    		}
    	pulseEnablePin();
    }
    
    
    //pulse the Enable pin high (for a microsecond).
    //This clocks whatever command or data is in DB4~7 into the LCD controller.
    
    void Wlcd::pulseEnablePin()
    {
    	digitalWrite(EN,HIGH);
    	delayMicroseconds(1);
    	digitalWrite(EN,LOW);
    	delay(1);                    // pause 1 ms.  TODO: what delay, if any, is necessary here?
    }
    Wlcd.h
    Code:
    class Wlcd
    {
    	public:
    		Wlcd(int);
    		void init();
    		void clear();
    		void write(char);
    		void print(char *);
    		void cursor(int);
    		void cursorTo(int, int);
    		void customChr(char, char *);
    		void commandWrite(int);
    		void commandWriteNibble(char);
    		int getkey(void);
    		int digkey(void);
    	private:
    		void pulseEnablePin();
    		void pushNibble(char);
    		void pushByte(char);
    };
    
    extern "C" void print(const char *,...);
    Wprint.c
    Code:
    #include "Wprint.h"
    
    //push a nibble of data through the the LCD's DB4~7 pins, clocking with the Enable pin.
    static void pushNibble(char byte)
    {
    	int i;
    	char nibble;
    
    	nibble = byte & 0x0F;
    
    	for(i=0;i<4;i++)
    	{
    		digitalWrite(DB[i],nibble&01);
    		nibble>>=1;
    	}
    
    	digitalWrite(EN,HIGH);
    	delayMicroseconds(1);
    	digitalWrite(EN,LOW);
    	delay(1);                    // pause 1 ms.  TODO: what delay, if any, is necessary here?
    }
    
    static void charwrite(char byte)
    {
    	digitalWrite(RS,HIGH);                 //set the RS pin to show we're writing data
    	char lower;
    	char upper;
    
    	upper=byte>>4;
    	lower=byte&0x0F;
    	pushNibble(upper);
    	pushNibble(lower);
    }
    
    void print(const char * fmt, ...) /* this should really be printf(const char * fmt,...) */
    {
    	va_list ap;
    	va_start(ap, fmt);
    	prf(fmt, ap, charwrite); /* you can export Wlcd::write(int) and skip the two previous functions */
    	va_end(ap);
    }
    
    void printn(n, b, flag, minwidth, putfn_p)
    	unsigned long n;
    	int b, flag, minwidth;
    	void (*putfn_p)();
    {
    	char prbuf[11];
    	register char *cp;
    	int width = 0, neg = 0;
    
    	if (b == 10 && (int)n < 0) {
    		neg = 1;
    		n = (unsigned)(-(int)n);
    	}
    	cp = prbuf;
    	do {
    		             *cp++ = "0123456789abcdef0123456789ABCDEF"[(flag & 16) + n%b];
    		n /= b;
    		width++;
    	} while (n);
    	
    	if (neg) {
    		(*putfn_p)('-');
    		width++;
    	}
    	while (width++ < minwidth)
    		(*putfn_p)( (flag & 2) ? '0' : ' ');
    		
    	do
    		(*putfn_p)(*--cp);
    	while (cp > prbuf);
    }
    
    void prf(char *fmt, unsigned int *adx, void (*putfn_p)())
    {
    	int b, c;
    	char *s;
    	int flag = 0, width = 0;
    	int minwidth;
    
    loop:
    	while ((c = *fmt++) != '%')
    	{
    		if(c == '\0')
    			return;
    		(*putfn_p)(c);
    	}
    		     minwidth = 0;
    again:
    	c = *fmt++;
    	switch (c) {
    		case 'l':
    			goto again;
    		case ' ':
    			flag |= 1;
    			goto again;
    		case '0':
    			if (minwidth == 0)
    			{
    				   /* this is a flag */
    				   flag |= 2;
    				   goto again;
    			} /* fall through */
    		case '1':
    		case '2':
    		case '3':
    		case '4':
    		case '5':
    		case '6':
    		case '7':
    		case '8':
    		case '9':
    			minwidth *= 10;
    			minwidth += c - '0';
    			goto again;
    		case 'X':
    		         flag |= 16;
    		         /* fall through */
    		case 'x':
    			b = 16;
    			goto number;
    		case 'd':
    			b = 10;
    			goto number;
    		case 'o': case 'O':
    			b = 8;
    number:
    			printn((unsigned long)*adx, b, flag, minwidth, putfn_p);
    			break;
    		case 's':
    			s = (char *)*adx;
    			while (c = *s++) {
    				(*putfn_p)(c);
    				width++;
    			}
    			while (width++ < minwidth)
    				   (*putfn_p)(' ');
    			break;
    		case 'c':
    			(*putfn_p)((char)*adx);
    			break;
    	}
    	adx++;
    	goto loop;
    }
    Wprint.h
    Code:
    #ifndef WPRINTF_H
    #define WPRINTF_H
    
    #include "Arduino.h"  //all things wiring / arduino
    
    #include  //needed for strlen()
    #include  //needed for strlen()
    #include 
    
    void print(const char *,...);
    
    extern int KA;
    extern int KD0;
    extern int KD1;
    
    extern int EN;
    extern int RS;
    extern int DB[];
    extern int KB[];
    
    //command bytes for LCD
    #define CMD_CLAR 0x01
    #define CMD_RGHT 0x1C
    #define CMD_LEFT 0x18
    #define CMD_HOME 0x02
    #define CMD_BLNK 0x09
    #define CMD_CTRL 0x0C
    
    #endif /* WPRINTF_H */

    DELETE "EEPROM.cpp"

    EEPROM.h
    Code:
    /*
      EEPROM.h - EEPROM library
      Original Copyright (c) 2006 David A. Mellis.  All right reserved.
      New version by Christopher Andrews 2015.
    
      This library is free software; you can redistribute it and/or
      modify it under the terms of the GNU Lesser General Public
      License as published by the Free Software Foundation; either
      version 2.1 of the License, or (at your option) any later version.
    
      This library is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      Lesser General Public License for more details.
    
      You should have received a copy of the GNU Lesser General Public
      License along with this library; if not, write to the Free Software
      Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    */
    
    #ifndef EEPROM_H
    #define EEPROM_H
    
    #include 
    #include 
    #include 
    
    /***
        EERef class.
        
        This object references an EEPROM cell.
        Its purpose is to mimic a typical byte of RAM, however its storage is the EEPROM.
        This class has an overhead of two bytes, similar to storing a pointer to an EEPROM cell.
    ***/
    
    struct EERef{
    
        EERef( const int index )
            : index( index )                 {}
        
        //Access/read members.
        uint8_t operator*() const            { return eeprom_read_byte( (uint8_t*) index ); }
        operator const uint8_t() const       { return **this; }
        
        //Assignment/write members.
        EERef &operator=( const EERef &ref ) { return *this = *ref; }
        EERef &operator=( uint8_t in )       { return eeprom_write_byte( (uint8_t*) index, in ), *this;  }
        EERef &operator +=( uint8_t in )     { return *this = **this + in; }
        EERef &operator -=( uint8_t in )     { return *this = **this - in; }
        EERef &operator *=( uint8_t in )     { return *this = **this * in; }
        EERef &operator /=( uint8_t in )     { return *this = **this / in; }
        EERef &operator ^=( uint8_t in )     { return *this = **this ^ in; }
        EERef &operator %=( uint8_t in )     { return *this = **this % in; }
        EERef &operator &=( uint8_t in )     { return *this = **this & in; }
        EERef &operator |=( uint8_t in )     { return *this = **this | in; }
        EERef &operator <<=( uint8_t in )    { return *this = **this << in; }
        EERef &operator >>=( uint8_t in )    { return *this = **this >> in; }
        
        EERef &update( uint8_t in )          { return  in != *this ? *this = in : *this; }
        
        /** Prefix increment/decrement **/
        EERef& operator++()                  { return *this += 1; }
        EERef& operator--()                  { return *this -= 1; }
        
        /** Postfix increment/decrement **/
        uint8_t operator++ (int){ 
            uint8_t ret = **this;
            return ++(*this), ret;
        }
    
        uint8_t operator-- (int){ 
            uint8_t ret = **this;
            return --(*this), ret;
        }
        
        int index; //Index of current EEPROM cell.
    };
    
    /***
        EEPtr class.
        
        This object is a bidirectional pointer to EEPROM cells represented by EERef objects.
        Just like a normal pointer type, this can be dereferenced and repositioned using 
        increment/decrement operators.
    ***/
    
    struct EEPtr{
    
        EEPtr( const int index )
            : index( index )                {}
            
        operator const int() const          { return index; }
        EEPtr &operator=( int in )          { return index = in, *this; }
        
        //Iterator functionality.
        bool operator!=( const EEPtr &ptr ) { return index != ptr.index; }
        EERef operator*()                   { return index; }
        
        /** Prefix & Postfix increment/decrement **/
        EEPtr& operator++()                 { return ++index, *this; }
        EEPtr& operator--()                 { return --index, *this; }
        EEPtr operator++ (int)              { return index++; }
        EEPtr operator-- (int)              { return index--; }
    
        int index; //Index of current EEPROM cell.
    };
    
    /***
        EEPROMClass class.
        
        This object represents the entire EEPROM space.
        It wraps the functionality of EEPtr and EERef into a basic interface.
        This class is also 100% backwards compatible with earlier Arduino core releases.
    ***/
    
    typedef union _atad {
    	uint8_t  b[4];
    	float f;
    } t2f;
    
    struct EEPROMClass{
    
    	//Basic user access methods.
    	EERef operator[]( const int idx )		{ return idx; }
    
    	uint8_t read( int idx )					{ return EERef( idx ); }
    
    	uint8_t checksum8(void)					{
    												uint8_t csum = 0;
    												for ( uint16_t index = 0; index < length(); index++)
    													csum += read(index);
    												return csum;
    											}
    	void update_checksum8(void)				{
    												uint8_t csum = checksum8();
    												if (csum )
    												{
    													csum -= read(length()-1);
    													uint8_t correct = (0 - csum);
    													write(length() - 1, correct);
    													csum += correct;
    												}
    											}
    	uint16_t read16( int idx )				{ return (((uint16_t)(EERef( idx ) << 8) & 0xFF00) + ((uint16_t)EERef( idx+1 ))); }
    
    	uint32_t read32( int idx )				{ return (((uint32_t)EERef( idx ) << 24) + ((uint32_t)EERef( idx + 1 ) << 16) + ((uint32_t)EERef( idx + 2 ) << 8) + ((uint32_t)EERef( idx + 3 )) ); }
    
    	float readFloat( int idx )				{
    												t2f r;
    												r.b[0] = EERef( idx );
    												r.b[1] = EERef( idx + 1 );
    												r.b[2] = EERef( idx + 2 );
    												r.b[3] = EERef( idx+3 );
    												return r.f;
    											}
    
    	void write( int idx, uint8_t val )		{ (EERef( idx )) = val; }
    
    	void write16( int idx, uint16_t val )	{
    												(EERef( idx )) = ((uint8_t)(val >> 8) & 0xff);
    												(EERef( idx+1 )) = ((uint8_t)val & 0xff);
    											}
    
    	void write32( int idx, uint32_t val )	{
    												(EERef( idx )) = ((uint8_t)(val >> 24) & 0xff);
    												(EERef( idx+1 )) = ((uint8_t)(val >> 16) & 0xff);
    												(EERef( idx+2 )) = ((uint8_t)(val >> 8) & 0xff);
    												(EERef( idx+3 )) = ((uint8_t)val & 0xff);
    											}
    
    	void writeFloat( int idx, float val )	{
    												t2f r;
    												r.f = val;
    												(EERef( idx )) = r.b[0];
    												(EERef( idx + 1 )) = r.b[1];
    												(EERef( idx + 2 )) = r.b[2];
    												(EERef( idx + 3 )) = r.b[3];
    											}
    
    	void update( int idx, uint8_t val )		{ EERef( idx ).update( val ); }
    
    	static struct EEPROMClass EPC;
    
    	uint32_t crc32( void )					{
    												const unsigned long crc_table[16] = { 0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c, 0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c, 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c };
    												unsigned long crc = ~0L;
    												for (uint16_t index = 0; index < EPC.length(); ++index)
    												{
    													crc = crc_table[(crc ^ EPC[index]) & 0x0f] ^ (crc >> 4);
    													crc = crc_table[(crc ^ (EPC[index] >> 4)) & 0x0f] ^ (crc >> 4);
    													crc = ~crc;
    												}
    												return crc;
    											}
    
    	//STL and C++11 iteration capability.
    	EEPtr begin()							{ return 0x00; }
    	EEPtr end()								{ return length(); } //Standards requires this to be the item after the last valid entry. The returned pointer is invalid.
    	uint16_t length()						{ return E2END + 1; }
        
    	//Functionality to 'get' and 'put' objects to and from EEPROM.
    	template< typename T > T &get( int idx, T &t )
    	{
    		EEPtr e = idx;
    		uint8_t *ptr = (uint8_t*) &t;
    		for( int count = sizeof(T) ; count ; --count, ++e )  *ptr++ = *e;
    		return t;
    	}
     	
    	template< typename T > const T &put( int idx, const T &t )
    	{
    		EEPtr e = idx;
    		const uint8_t *ptr = (const uint8_t*) &t;
    		for( int count = sizeof(T) ; count ; --count, ++e )  (*e).update( *ptr++ );
    		return t;
    	}
    };
    
    static EEPROMClass EEPROM;
    
    #endif /* EEPROM_H */

  10. #50
    Join Date
    Sep 2009
    Posts
    1856

    Re: CNC Indexer (Arduino based)

    the way you are going about it, is not that nice

    WOW, this is what I call well written code!!! it worked when it was done, if it don't work now do what you have done and fix it, the code used is out off date for a start so yes it will and does have problems.
    http://danielscnc.webs.com/

    being disabled is not a hindrance it gives you attitude
    [SIGPIC][/SIGPIC]

  11. #51
    Join Date
    Jul 2012
    Posts
    106

    Re: CNC Indexer (Arduino based)

    Why does everyone have the need to send me PM's when they have a question, statement or request???

    Don't PM me telling me it doesn't compile, it compiles just fine, if it's not compiling for you then you obviously copied and pasted it incorrectly.

    I copied and pasted it fresh, compiled it, fixed the three remaining warnings in Wprint.c moved printf() to the end of the file, removed the unneeded routines in Wlcd.cpp/Wlcd.h including Wlcd:rint() and associated functions, compiled it again and I had no errors or warnings, it's smaller and faster executing code.
    Code:
    /Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -Wextra -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106 -I/Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino -I/Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/arduino/variants/standard -I/Volumes/Storage/Arduino.app/Contents/Resources/Java/libraries/Wlcd -I/Volumes/Storage/Arduino.app/Contents/Resources/Java/libraries/Wstepper -I/Volumes/Storage/Arduino.app/Contents/Resources/Java/libraries/EEPROM /tmp/build2212631359320952590.tmp/Indexer.cpp -o /tmp/build2212631359320952590.tmp/Indexer.cpp.o 
    /Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-gcc -c -g -Os -Wall -Wextra -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106 -I/Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino -I/Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/arduino/variants/standard -I/Volumes/Storage/Arduino.app/Contents/Resources/Java/libraries/Wlcd -I/Volumes/Storage/Arduino.app/Contents/Resources/Java/libraries/Wstepper -I/Volumes/Storage/Arduino.app/Contents/Resources/Java/libraries/EEPROM -I/Volumes/Storage/Arduino.app/Contents/Resources/Java/libraries/Wlcd/utility /Volumes/Storage/Arduino.app/Contents/Resources/Java/libraries/Wlcd/Wprint.c -o /tmp/build2212631359320952590.tmp/Wlcd/Wprint.c.o 
    /Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -Wextra -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106 -I/Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino -I/Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/arduino/variants/standard -I/Volumes/Storage/Arduino.app/Contents/Resources/Java/libraries/Wlcd -I/Volumes/Storage/Arduino.app/Contents/Resources/Java/libraries/Wstepper -I/Volumes/Storage/Arduino.app/Contents/Resources/Java/libraries/EEPROM -I/Volumes/Storage/Arduino.app/Contents/Resources/Java/libraries/Wlcd/utility /Volumes/Storage/Arduino.app/Contents/Resources/Java/libraries/Wlcd/Wlcd.cpp -o /tmp/build2212631359320952590.tmp/Wlcd/Wlcd.cpp.o 
    /Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -Wextra -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106 -I/Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino -I/Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/arduino/variants/standard -I/Volumes/Storage/Arduino.app/Contents/Resources/Java/libraries/Wlcd -I/Volumes/Storage/Arduino.app/Contents/Resources/Java/libraries/Wstepper -I/Volumes/Storage/Arduino.app/Contents/Resources/Java/libraries/EEPROM -I/Volumes/Storage/Arduino.app/Contents/Resources/Java/libraries/Wstepper/utility /Volumes/Storage/Arduino.app/Contents/Resources/Java/libraries/Wstepper/Wstepper.cpp -o /tmp/build2212631359320952590.tmp/Wstepper/Wstepper.cpp.o 
      Using previously compiled: /tmp/build2212631359320952590.tmp/WInterrupts.c.o
      Using previously compiled: /tmp/build2212631359320952590.tmp/malloc.c.o
      Using previously compiled: /tmp/build2212631359320952590.tmp/realloc.c.o
      Using previously compiled: /tmp/build2212631359320952590.tmp/wiring.c.o
      Using previously compiled: /tmp/build2212631359320952590.tmp/wiring_analog.c.o
      Using previously compiled: /tmp/build2212631359320952590.tmp/wiring_digital.c.o
      Using previously compiled: /tmp/build2212631359320952590.tmp/wiring_pulse.c.o
      Using previously compiled: /tmp/build2212631359320952590.tmp/wiring_shift.c.o
      Using previously compiled: /tmp/build2212631359320952590.tmp/CDC.cpp.o
      Using previously compiled: /tmp/build2212631359320952590.tmp/HID.cpp.o
      Using previously compiled: /tmp/build2212631359320952590.tmp/HardwareSerial.cpp.o
      Using previously compiled: /tmp/build2212631359320952590.tmp/Print.cpp.o
      Using previously compiled: /tmp/build2212631359320952590.tmp/Stream.cpp.o
      Using previously compiled: /tmp/build2212631359320952590.tmp/USBCore.cpp.o
      Using previously compiled: /tmp/build2212631359320952590.tmp/WMath.cpp.o
      Using previously compiled: /tmp/build2212631359320952590.tmp/WString.cpp.o
      Using previously compiled: /tmp/build2212631359320952590.tmp/main.cpp.o
    /Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /tmp/build2212631359320952590.tmp/core.a /tmp/build2212631359320952590.tmp/WInterrupts.c.o 
    /Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /tmp/build2212631359320952590.tmp/core.a /tmp/build2212631359320952590.tmp/malloc.c.o 
    /Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /tmp/build2212631359320952590.tmp/core.a /tmp/build2212631359320952590.tmp/realloc.c.o 
    /Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /tmp/build2212631359320952590.tmp/core.a /tmp/build2212631359320952590.tmp/wiring.c.o 
    /Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /tmp/build2212631359320952590.tmp/core.a /tmp/build2212631359320952590.tmp/wiring_analog.c.o 
    /Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /tmp/build2212631359320952590.tmp/core.a /tmp/build2212631359320952590.tmp/wiring_digital.c.o 
    /Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /tmp/build2212631359320952590.tmp/core.a /tmp/build2212631359320952590.tmp/wiring_pulse.c.o 
    /Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /tmp/build2212631359320952590.tmp/core.a /tmp/build2212631359320952590.tmp/wiring_shift.c.o 
    /Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /tmp/build2212631359320952590.tmp/core.a /tmp/build2212631359320952590.tmp/CDC.cpp.o 
    /Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /tmp/build2212631359320952590.tmp/core.a /tmp/build2212631359320952590.tmp/HID.cpp.o 
    /Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /tmp/build2212631359320952590.tmp/core.a /tmp/build2212631359320952590.tmp/HardwareSerial.cpp.o 
    /Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /tmp/build2212631359320952590.tmp/core.a /tmp/build2212631359320952590.tmp/Print.cpp.o 
    /Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /tmp/build2212631359320952590.tmp/core.a /tmp/build2212631359320952590.tmp/Stream.cpp.o 
    /Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /tmp/build2212631359320952590.tmp/core.a /tmp/build2212631359320952590.tmp/USBCore.cpp.o 
    /Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /tmp/build2212631359320952590.tmp/core.a /tmp/build2212631359320952590.tmp/WMath.cpp.o 
    /Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /tmp/build2212631359320952590.tmp/core.a /tmp/build2212631359320952590.tmp/WString.cpp.o 
    /Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /tmp/build2212631359320952590.tmp/core.a /tmp/build2212631359320952590.tmp/main.cpp.o 
    /Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-gcc -Os -Wl,--gc-sections -mmcu=atmega328p -o /tmp/build2212631359320952590.tmp/Indexer.cpp.elf /tmp/build2212631359320952590.tmp/Indexer.cpp.o /tmp/build2212631359320952590.tmp/Wlcd/Wprint.c.o /tmp/build2212631359320952590.tmp/Wlcd/Wlcd.cpp.o /tmp/build2212631359320952590.tmp/Wstepper/Wstepper.cpp.o /tmp/build2212631359320952590.tmp/core.a -L/tmp/build2212631359320952590.tmp -lm 
    /Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 /tmp/build2212631359320952590.tmp/Indexer.cpp.elf /tmp/build2212631359320952590.tmp/Indexer.cpp.eep 
    /Volumes/Storage/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-objcopy -O ihex -R .eeprom /tmp/build2212631359320952590.tmp/Indexer.cpp.elf /tmp/build2212631359320952590.tmp/Indexer.cpp.hex 
    Binary sketch size: 17,986 bytes (of a 32,256 byte maximum)
    The -Wextra flag has been added to my Arduino IDE compile options and a checkbox in preferences to enable/disable it so when it's enabled it warns about even more stuff so I know I have no issues when it compiles and it shows no warnings, my Arduino IDE works properly.


    Please refrain from PM'ing me to request a hex file, the code for the 12864 or the posted snippets in zip file format, if you wish to use this code then copy and paste it or, ask someone involved in the project to do it for you if it's beyond your skill level, if you want to use the 12864 LCD, the changes are minimal and all the information to make the transition is in the datasheet and a junior programmer can recode it in less than 15 seconds, it's only eight line changes.


    I've moved far beyond the boundaries, scope and limits of the original code for this project in a short period of time and what I have no longer resembles the original or posted code snippets.

    The issue Markovic Slavol experiences where it exceeds the target degrees has been corrected, it's now all TouchScreen driven using a 3.95in TFT LCD and sadly, it's not anything I'm interested in sharing as a non member of this project so please don't ask me, I've already contributed more than my share of code and, I'm sure there's a confident programmer involved in the project who can write or fix the code as needed, you just need to ask him/her.

  12. #52
    Join Date
    Jul 2012
    Posts
    106

    Re: CNC Indexer (Arduino based)

    What is wrong with people that they think I am here to be their personal problem solver?

    Please, stop PM'ing me for help, if you encounter a problem make a public post requesting help or ask someone directly involved with this project to assist you.


    John you have compiler errors because you didn't follow the simple child-like instructions, as I said in the post, "DELETE EEPROM.cpp", the new EEPROM.h file is masquerading as a C++ class but it's a really a self-supporting (all inclusive) struct and the error is because you can't define a class and a struct with the same name and having duplicate functions in a class and a struct is nothing more than a waste of space so renaming one would be just dumb.

    The only warning that could ever occur would be "EEPROM defined but not used" because it's static and will appear in every file that includes the header but does not use it.


    I think posting updated files was a mistake, those playing with it should just use the original versions, it's more than adequate for your needs and as long as it works it's good enough for your use.

  13. #53
    Join Date
    Jul 2012
    Posts
    2

    Re: CNC Indexer (Arduino based)

    Hello,

    Is it possible to post a new ZIP file containing all the latest files of this project.
    I have problems with the individual files which I found here in the articles and the initial Zip file is not the latest version.
    My compiler gives me errors with the new files.
    Yes, that is my problem, I am not an experienced programmer so please help me, I hate software, therefore software allways drives me to thing I don't want to menthion here.

  14. #54
    Join Date
    Jul 2012
    Posts
    2

    Re: CNC Indexer (Arduino based)

    Hello, is it possible to receive Wstepper and Wlcd, i cant find them anymore.

Page 3 of 3 123

Similar Threads

  1. Arduino Modbus?
    By wbrandsmeier in forum Mach Software (ArtSoft software)
    Replies: 1
    Last Post: 02-01-2014, 07:47 PM
  2. Arduino + tb6560 + cd rom cnc machine help
    By joetemus in forum Community Club House
    Replies: 5
    Last Post: 11-28-2013, 04:56 AM
  3. EMC with Arduino for USB I/O?
    By sansbury in forum LinuxCNC (formerly EMC2)
    Replies: 23
    Last Post: 05-05-2012, 09:27 PM
  4. Interfacing an Arduino-based pendant
    By sansbury in forum Mach Software (ArtSoft software)
    Replies: 4
    Last Post: 12-07-2011, 04:40 PM
  5. Arduino
    By LTP in forum CNC Machine Related Electronics
    Replies: 0
    Last Post: 02-11-2011, 10:26 AM

Posting Permissions

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