Hurco BMC20 Dynomotion Retrofit - Page 31


Page 31 of 34 FirstFirst ... 2128293031323334 LastLast
Results 361 to 372 of 397

Thread: Hurco BMC20 Dynomotion Retrofit

  1. #361
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    3183
    Downloads
    0
    Uploads
    0

    Default Re: Hurco BMC20 Dynomotion Retrofit

    Hi Troy,

    The code still needs cleaned up and some adjustments made, like a way to wait for spindle to come to a complete stop before starting Tool Change sequence, other than a delay. Example: If spindle was running at 3800RPM the delay needs to be about 8seconds for spindle to come to a complete stop. But if RPM was at 500RPM the delay needs to be much less.
    I believe your Spindle has an encoder so you might wait until the measured speed is close enough to zero (or your desired speed). Note exactly zero speed might not occur in some cases if there is something like the slightest dither in the spindle position. So you might do something like:

    while (fast_fabs(Spindle.TrueSpeedRPS)*60.0 > 5.0) ; // wait until less than 5RPM

    Waiting for video

    Regards
    TK http://dynomotion.com


  2. #362
    Member Need TECH Help!'s Avatar
    Join Date
    Dec 2007
    Location
    United States
    Posts
    471
    Downloads
    0
    Uploads
    0

    Default Re: Hurco BMC20 Dynomotion Retrofit

    Hi Tom,
    That did the trick I also added it to my M5 code. Will get a video soon. Would like to fix an air cushion issue for cylinder that extends and retracts the tool changer, before i post a video. Currently is slamming when it retracts.Using some rubber stops to absorb shock now, but it still hits hard. The cushion screw is having very little effect. Thinking will need to disassemble the cylinder.
    But still never thought a working tool changer would make me this happy.
    Thanks,
    Troy

    http://www.homecncstuff.elementfx.com/


  3. #363
    Member Need TECH Help!'s Avatar
    Join Date
    Dec 2007
    Location
    United States
    Posts
    471
    Downloads
    0
    Uploads
    0

    Default Re: Hurco BMC20 Dynomotion Retrofit

    Quote Originally Posted by mmurray70 View Post
    .......

    And here is the code to read file from disk. Put this in your init file, before forever loop. You may need to create that file first, make sure paths match up. Mine is just a txt file with the tool number in it. Mine has 6 decimal places, not sure if it makes a difference. Currently says 16.000000

    Code:
    FILE *f;
        	char s[256];
    	double CTool=0;
    	int result;
    
        	f=fopen("c:\\KMotion Files\\KFlopData.txt","rt");
        	if (!f)
        	{
           	 printf("Unable to open file\n");
            	return;
        	}
        	result=fscanf(f,"%lf",&CTool);
        	fclose(f);    
    	persist.UserData[157] = CTool;
    	printf("Current tool=%f\n",CTool);
    
    	// Send MDI code to kmotion to display proper tool
    	char s[80];
       	sprintf(s,"T%d",persist.UserData[157]);
    	MDI(s);  //send the T word
    Hi mmurray,
    Iam getting an error when compiling. States that 'f' is undeclared. How and where should it be defined? In the main init code or ?

    Thanks,
    Troy

    http://www.homecncstuff.elementfx.com/


  4. #364
    Member
    Join Date
    May 2012
    Location
    canada
    Posts
    430
    Downloads
    0
    Uploads
    0

    Default Re: Hurco BMC20 Dynomotion Retrofit

    Troy,

    I had a look through my init file and dont see anything else about that f being declared. Pretty sure that is everything. The first line is not indented in my init like it shows here on the forum, all lines are even with each other, but I doubt that will change anything. Maybe Tom can help with this.

    I think your air cylinder is probably fine. In order to retract smoothly, the backside of the cylinder needs to be pressurized up until the point of when you want to reverse it. Their needs to be air on the backside in order for the motion to be dampened. Looking at your code, you set a bit to extend the cylinder and then clear it. Leave that bit on until the new tool is loaded and when your ready to retract, turn that bit off, and switch the other one on. It will retract much smoother that way, and the cusion screw should do its job. Does it extend smoothly? The extending part would probably be smoother as well if there was pressure on the other end before extending. Id probably have your init file pressurize the cylinder to retract on start up, and always leave one side pressurized. Just get your toolchange program to switch back and forth. Make it operate the same as a 2 position solenoid valve. Always extending or retracting, never in neutral.

    I learned this from an ameria seiki VMC at my last shop. It had a side mount tool changer, and the arm that tilted tool 90 degrees had a 3 position solenoid valve from the factory, with neutral (held pressure in cyl) in the middle. If the machine was sitting for an hour or more the cylinder would have lost its pressue and then when you did a toolchange it would slam down hard sometimes dropping the tool, first toolchange of the day was also the same. I changed it to a 2 positon valve with no neutral and problem solved. Smooth as silk every time.

    Mark



  5. #365
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    3183
    Downloads
    0
    Uploads
    0

    Default Re: Hurco BMC20 Dynomotion Retrofit

    Hi Troy,

    Hi mmurray,
    Iam getting an error when compiling. States that 'f' is undeclared. How and where should it be defined? In the main init code or ?

    I had a look through my init file and dont see anything else about that f being declared. Pretty sure that is everything. The first line is not indented in my init like it shows here on the forum, all lines are even with each other, but I doubt that will change anything. Maybe Tom can help with this.
    The code FILE *f; should define 'f' and it shouldn't matter if it is indented or not. The compiler ignores 'white space'. Indenting properly just makes it easier for a human to read and understand. Other minor things are that Result is declared but never used and s is defined twice. But the code you posted compiles ok for me. Here is it cleaned up and indented properly:

    Code:
        FILE *f;
        double CTool = 0;
    
        f = fopen("c:\\KMotion Files\\KFlopData.txt", "rt");
        if (!f)
        {
            printf("Unable to open file\n");
            return;
        }
        fscanf(f, "%lf", &CTool);
        fclose(f);
        persist.UserData[157] = CTool;
        printf("Current tool=%f\n", CTool);
    
        // Send MDI code to kmotion to display proper tool
        char s[80];
        sprintf(s, "T%d", persist.UserData[157]);
        MDI(s);                        //send the T word


    Regards
    TK http://dynomotion.com


  6. #366
    Member Need TECH Help!'s Avatar
    Join Date
    Dec 2007
    Location
    United States
    Posts
    471
    Downloads
    0
    Uploads
    0

    Default Re: Hurco BMC20 Dynomotion Retrofit

    Quote Originally Posted by mmurray70 View Post
    Troy,

    ......
    I think your air cylinder is probably fine. In order to retract smoothly, the backside of the cylinder needs to be pressurized up until the point of when you want to reverse it. Their needs to be air on the backside in order for the motion to be dampened. Looking at your code, you set a bit to extend the cylinder and then clear it. Leave that bit on until the new tool is loaded and when your ready to retract, turn that bit off, and switch the other one on. It will retract much smoother that way, and the cusion screw should do its job. Does it extend smoothly? The extending part would probably be smoother as well if there was pressure on the other end before extending. Id probably have your init file pressurize the cylinder to retract on start up, and always leave one side pressurized. Just get your toolchange program to switch back and forth. Make it operate the same as a 2 position solenoid valve. Always extending or retracting, never in neutral.

    ....
    Mark
    Hi Mark,
    I tried this before but has no effect leaving one opposite solenoid on. The air valve will stay maintained keeping air pressure on cylinder no matter what direction. The extension of cylinder is a little softer than retract. The manifold i have all the valves and solenoids attached to has 2 exhaust ports on both sides. Originally i had all for open with mufflers. Then i plugged off 2 and that helped but still not soft like it should be. Once all the C code is working i will work on this some more. As old as the cylinder is, it wont hurt to dissemble and inspect it any how.

    Troy

    http://www.homecncstuff.elementfx.com/


  7. #367
    Member Need TECH Help!'s Avatar
    Join Date
    Dec 2007
    Location
    United States
    Posts
    471
    Downloads
    0
    Uploads
    0

    Default Re: Hurco BMC20 Dynomotion Retrofit

    I dont know how or where exactly to add code to my main INIT code. I tried to where i thought it should be but when executing the init code, the code just hangs. Now i know what the apprentice iam training at work on the CNCs is feeling like,.... except Gcode is much simpler than Ccode
    Wish there was some sort of a GUI for this sort of thing.

    Troy

    http://www.homecncstuff.elementfx.com/


  8. #368
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    3183
    Downloads
    0
    Uploads
    0

    Default Re: Hurco BMC20 Dynomotion Retrofit

    Hi Troy,

    I tried this before but has no effect leaving one opposite solenoid on. The air valve will stay maintained keeping air pressure on cylinder no matter what direction. The extension of cylinder is a little softer than retract. The manifold i have all the valves and solenoids attached to has 2 exhaust ports on both sides. Originally i had all for open with mufflers. Then i plugged off 2 and that helped but still not soft like it should be. Once all the C code is working i will work on this some more. As old as the cylinder is, it wont hurt to dissemble and inspect it any how.
    I don't really follow what you guys are saying, but years ago some equipment I worked on had very smooth pneumatic motion. I believe we used Festo cylinders that had like a double throw double pole solenoid valve right at the cylinder. It switched both sides of the cylinder from pressure to vent and vice versa and the vent had a needle valve to control the rate of motion independently each direction.



    I dont know how or where exactly to add code to my main INIT code. I tried to where i thought it should be but when executing the init code, the code just hangs.
    You might have told us where you put it. A good place might be just before any forever loop you may have. Not inside the forever loop.

    Regards
    TK http://dynomotion.com


  9. #369
    Member Need TECH Help!'s Avatar
    Join Date
    Dec 2007
    Location
    United States
    Posts
    471
    Downloads
    0
    Uploads
    0

    Default Re: Hurco BMC20 Dynomotion Retrofit

    I tried before and after forever loop, at least i think i did. Here it is before??

    Code:
    //V3- Added LowPass Filter to output.
    //V3.1- Removed waylube bit timer
    //V3.2-Added Auto Tool Changer Code
    #include "KMotionDef.h"
    #define TMP 10					// which spare persist to use to transfer data
    #include "KflopToKMotionCNCFunctions.c"
    #include "AdjustSoftLimits.c"
    
    //#define CYCLESTARTBIT 16
    //#define FEEDHOLDBIT 17
    #define ESTOP 137
    #define MISTCOOLANTBIT 158
    #define FLOODCOOLANTBIT 157
    //#define SPINDLESTOPBIT 21
    //#define SPINDLECWBIT 19
    //#define SPINDLECCWBIT 20
    #define VFDERRORLINEBIT 138
    #define XSDERRORLINEBIT 139
    #define YSDERRORLINEBIT 140
    #define ZSDERRORLINEBIT 141
    
    #define XMINUSLIMITBIT 1025
    #define XPLUSLIMITBIT 1024
    #define YMINUSLIMITBIT 1027
    #define YPLUSLIMITBIT 1026
    #define ZMINUSLIMITBIT 1029
    #define ZPLUSLIMITBIT 1028
    
    
    #define X 0
    #define Y 1
    #define Z 2
    
    #define QA 1042					// define to which IO bits the AB signals are connected
    #define QB 1041
    
    #define TAU 0.08				// smoothness factor (Low Pass Time constant seconds)
    #define FINAL_TIME 1.0			// Set final dest after this amount of time with no change
    
    #define MAX_JOG_SPEED_X 510.0	// ipm
    #define MAX_JOG_SPEED_Y 510.0	// ipm
    #define MAX_JOG_SPEED_Z 510.0	// ipm
    
    
    void UpdateJogSpeeds(void);
    void DoLimitJog(double rate, int cmd);
    
    void ServiceTimerSequence(void);
    void ServiceEStop(void);
    
    
    // function prototypes for compiler
    int DoPC(int cmd);
    int DoPCFloat(int cmd, float f);
    int Debounce(int n, int *cnt, int *last, int *lastsolid);
    
    // state variables for switch debouncing
    int flast = 0, flastsolid = -1, fcount = 0;
    int ccwlast = 0, ccwlastsolid = -1, ccwcount = 0;
    int cwlast = 0, cwlastsolid = -1, cwcount = 0;
    int colast = 0, colastsolid = -1, cocount = 0;
    int solast = 0, solastsolid = -1, socount = 0;
    int xsdelast = 0, xsdelastsolid = -1, xsdecount = 0;
    int ysdelast = 0, ysdelastsolid = -1, ysdecount = 0;
    int zsdelast = 0, zsdelastsolid = -1, zsdecount = 0;
    int vfdelast = 0, vfdelastsolid = -1, vfdecount = 0;
    int zmlast = 0, zmlastsolid = -1, zmcount = 0;
    int zplast = 0, zplastsolid = -1, zpcount = 0;
    int ymlast = 0, ymlastsolid = -1, ymcount = 0;
    int yplast = 0, yplastsolid = -1, ypcount = 0;
    int xmlast = 0, xmlastsolid = -1, xmcount = 0;
    int xplast = 0, xplastsolid = -1, xpcount = 0;
    int clast = 0, clastsolid = -1, ccount = 0;
    int elast = 0, elastsolid = -1, ecount = 0;
    int hlast = 0, hlastsolid = -1, hcount = 0;
    int rlast = 0, rlastsolid = -1, rcount = 0;
    int zlast = 0, zlastsolid = -1, zcount = 0;
    
    int xpjblast = 0, xpjblastsolid = -1, xpjbcount = 0;
    
    
    
    //int Debounce(int n, int *cnt, int *last, int *lastsolid);
    
    main()
    {
    
    	InitAux();
    	AddKonnect(0, &VirtualBits, VirtualBitsEx);
    	int BitA, Change1 = 0, Change2 = 0, DiffX2;
    	int PosNoWrap, NewPos, Pos = 0, wraps;
    	int InMotion = FALSE, Axis, LastAxis = -1;
    	double LastChangeTime = 0, Target, Factor = 0;
    
    
    #define DROIN 40
    	double *pin = (double *)&persist.UserData[(DROIN - 1) * 2];
    
    	int result;
    	int Answer;
    
    	ch0->InputMode = ENCODER_MODE;
    	ch0->OutputMode = CL_STEP_DIR_MODE;
    	ch0->Vel = 270700;
    	ch0->Accel = 9.7e+05;
    	ch0->Jerk = 10e+06;
    	ch0->P = 0;
    	ch0->I = 0.003;
    	ch0->D = 0;
    	ch0->FFAccel = 0;
    	ch0->FFVel = 0;
    	ch0->MaxI = 400;
    	ch0->MaxErr = 200;
    	ch0->MaxOutput = 200;
    	ch0->DeadBandGain = 0;
    	ch0->DeadBandRange = 1;
    	ch0->InputChan0 = 0;
    	ch0->InputChan1 = 0;
    	ch0->OutputChan0 = 12;
    	ch0->OutputChan1 = 0;
    	ch0->MasterAxis = -1;
    	ch0->LimitSwitchOptions = 0x113;
    	ch0->LimitSwitchNegBit = 1025;
    	ch0->LimitSwitchPosBit = 1024;
    	ch0->SoftLimitPos = 1e+09;
    	ch0->SoftLimitNeg = -1e+09;
    	ch0->InputGain0 = -1;
    	ch0->InputGain1 = 1;
    	ch0->InputOffset0 = 0;
    	ch0->InputOffset1 = 0;
    	ch0->OutputGain = -1;
    	ch0->OutputOffset = 0;
    	ch0->SlaveGain = 1;
    	ch0->BacklashMode = BACKLASH_OFF;
    	ch0->BacklashAmount = 0;
    	ch0->BacklashRate = 0;
    	ch0->invDistPerCycle = 1;
    	ch0->Lead = 0;
    	ch0->MaxFollowingError = 100;
    	ch0->StepperAmplitude = 20;
    
    	ch0->iir[0].B0 = 1;
    	ch0->iir[0].B1 = 0;
    	ch0->iir[0].B2 = 0;
    	ch0->iir[0].A1 = 0;
    	ch0->iir[0].A2 = 0;
    
    	ch0->iir[1].B0 = 1;
    	ch0->iir[1].B1 = 0;
    	ch0->iir[1].B2 = 0;
    	ch0->iir[1].A1 = 0;
    	ch0->iir[1].A2 = 0;
    
    	ch0->iir[2].B0 = 0.000768809;
    	ch0->iir[2].B1 = 0.00153762;
    	ch0->iir[2].B2 = 0.000768809;
    	ch0->iir[2].A1 = 1.92081;
    	ch0->iir[2].A2 = -0.923885;
    
    
    	ch1->InputMode = ENCODER_MODE;
    	ch1->OutputMode = CL_STEP_DIR_MODE;
    	ch1->Vel = 270700;
    	ch1->Accel = 9.7e+05;
    	ch1->Jerk = 10e+06;
    	ch1->P = 0;
    	ch1->I = 0.003;
    	ch1->D = 0;
    	ch1->FFAccel = 0;
    	ch1->FFVel = 0;
    	ch1->MaxI = 200;
    	ch1->MaxErr = 200;
    	ch1->MaxOutput = 200;
    	ch1->DeadBandGain = 0;
    	ch1->DeadBandRange = 0;
    	ch1->InputChan0 = 1;
    	ch1->InputChan1 = 0;
    	ch1->OutputChan0 = 13;
    	ch1->OutputChan1 = 0;
    	ch1->MasterAxis = -1;
    	ch1->LimitSwitchOptions = 0x112;
    	ch1->LimitSwitchNegBit = 1026;
    	ch1->LimitSwitchPosBit = 1026;
    	ch1->SoftLimitPos = 1e+09;
    	ch1->SoftLimitNeg = -286500;
    	ch1->InputGain0 = 1;
    	ch1->InputGain1 = 1;
    	ch1->InputOffset0 = 0;
    	ch1->InputOffset1 = 0;
    	ch1->OutputGain = 1;
    	ch1->OutputOffset = 0;
    	ch1->SlaveGain = 1;
    	ch1->BacklashMode = BACKLASH_OFF;
    	ch1->BacklashAmount = 0;
    	ch1->BacklashRate = 0;
    	ch1->invDistPerCycle = 1;
    	ch1->Lead = 0;
    	ch1->MaxFollowingError = 500;
    	ch1->StepperAmplitude = 20;
    
    	ch1->iir[0].B0 = 1;
    	ch1->iir[0].B1 = 0;
    	ch1->iir[0].B2 = 0;
    	ch1->iir[0].A1 = 0;
    	ch1->iir[0].A2 = 0;
    
    	ch1->iir[1].B0 = 1;
    	ch1->iir[1].B1 = 0;
    	ch1->iir[1].B2 = 0;
    	ch1->iir[1].A1 = 0;
    	ch1->iir[1].A2 = 0;
    
    	ch1->iir[2].B0 = 0.000768809;
    	ch1->iir[2].B1 = 0.00153762;
    	ch1->iir[2].B2 = 0.000768809;
    	ch1->iir[2].A1 = 1.92081;
    	ch1->iir[2].A2 = -0.923885;
    
    	ch2->InputMode = ENCODER_MODE;
    	ch2->OutputMode = CL_STEP_DIR_MODE;
    	ch2->Vel = 270700;
    	ch2->Accel = 7.7e+05;
    	ch2->Jerk = 3.9e+06;
    	ch2->P = 0;
    	ch2->I = 0.003;
    	ch2->D = 0;
    	ch2->FFAccel = 0;
    	ch2->FFVel = 0;
    	ch2->MaxI = 400;
    	ch2->MaxErr = 155;
    	ch2->MaxOutput = 200;
    	ch2->DeadBandGain = 0;
    	ch2->DeadBandRange = 0;
    	ch2->InputChan0 = 2;
    	ch2->InputChan1 = 0;
    	ch2->OutputChan0 = 14;
    	ch2->OutputChan1 = 0;
    	ch2->MasterAxis = -1;
    	ch2->LimitSwitchOptions = 0x113;
    	ch2->LimitSwitchNegBit = 1029;
    	ch2->LimitSwitchPosBit = 1028;
    	ch2->SoftLimitPos = 1e+09;
    	ch2->SoftLimitNeg = -1e+09;
    	ch2->InputGain0 = 1;
    	ch2->InputGain1 = 1;
    	ch2->InputOffset0 = 0;
    	ch2->InputOffset1 = 0;
    	ch2->OutputGain = 1;
    	ch2->OutputOffset = 0;
    	ch2->SlaveGain = 1;
    	ch2->BacklashMode = BACKLASH_LINEAR;
    	ch2->BacklashAmount = 5;
    	ch2->BacklashRate = 90;
    	ch2->invDistPerCycle = 1;
    	ch2->Lead = 0;
    	ch2->MaxFollowingError = 500;
    	ch2->StepperAmplitude = 20;
    
    	ch2->iir[0].B0 = 1.000000;
    	ch2->iir[0].B1 = 0.000000;
    	ch2->iir[0].B2 = 0.000000;
    	ch2->iir[0].A1 = 0.000000;
    	ch2->iir[0].A2 = 0.000000;
    
    	ch2->iir[1].B0 = 1.000000;
    	ch2->iir[1].B1 = 0.000000;
    	ch2->iir[1].B2 = 0.000000;
    	ch2->iir[1].A1 = 0.000000;
    	ch2->iir[1].A2 = 0.000000;
    
    	ch2->iir[2].B0 = 0.000769;
    	ch2->iir[2].B1 = 0.001538;
    	ch2->iir[2].B2 = 0.000769;
    	ch2->iir[2].A1 = 1.920810;
    	ch2->iir[2].A2 = -0.923885;
    
    
    
    
    
    
    
    	EnableAxisDest(0, ch0->Position);
    	//EnableAxisDest(0,ch0->Dest);
    	EnableAxisDest(1, ch1->Position);
    	//EnableAxisDest(1,ch1->Dest);
    	EnableAxisDest(2, ch2->Position);
    	//EnableAxisDest(2,ch2->Dest);
    
    	FILE *f;
    	double CTool = 0;
    
    	f = fopen("c:\\KMotionFiles\\KFlopData.txt", "rt");
    	if (!f)
    	{
    		printf("Unable to open file\n");
    		return;
    	}
    	fscanf(f, "%lf", &CTool);
    	fclose(f);
    	persist.UserData[157] = CTool;
    	printf("Current tool=%f\n", CTool);
    
    	// Send MDI code to kmotion to display proper tool
    	char s[80];
    	sprintf(s, "T%d", persist.UserData[157]);
    	MDI(s);						//send the T word
    
    
    	SetBit(144);				//Enables Main Contactor Relay1 for servo drives with SWE kanalog output.
    	// once the RESET button is clicked.
    	SetBit(145);				//Enables Relay2 for enable/disable of servo drives and VFDwith SWE 
    	// kanalog output. And controled by Estop switch.
    	SetBit(159);				// WayLubePump          
    	DefineCoordSystem(0, 1, 2, -1);	//DefineXYZ(A not used)
    
    
    
    	{
    		double Tau = 0.002;		//seconds for low pass filtertime constant
    		KLP = exp(-TIMEBASE / Tau);
    		printf("Tau=%f KLP=%f\n", Tau, KLP);
    	}
    
    	for (;;)					// loop forever
    
    
    
    
    	{
    
    
    		// convert quadrature to 2 bit binary
    		BitA = ReadBit(QA);
    		PosNoWrap = (ReadBit(QB) ^ BitA) | (BitA << 1);
    
    		// Diff between expected position based on average of two prev deltas
    		// and position with no wraps.  (Keep as X2 to avoid division by 2)
    
    		DiffX2 = 2 * (Pos - PosNoWrap);	// + (Change2+Change1);
    
    		// Calc quadrature wraparounds to bring Diff nearest zero
    		// offset by 128 wraps to avoid requiring floor()
    		wraps = ((DiffX2 + 1028) >> 3) - 128;
    
    		// factor in the quadrature wraparounds
    		NewPos = PosNoWrap + (wraps << 2);
    
    		Change2 = Change1;
    		Change1 = NewPos - Pos;
    		Pos = NewPos;
    
    		if (ReadBit(1048))		// is X1 selected?
    			Factor = .5;
    		else if (ReadBit(1046))	// is X10 selected?
    			Factor = 5;
    		else if (ReadBit(1045))	// is X100 selected?
    			Factor = 50.;
    
    
    		if (ReadBit(1052))		// is x selected?
    			Axis = 0;
    		else if (ReadBit(1055))	// is y selected?
    			Axis = 1;
    		else if (ReadBit(1053))	// is z selected?
    			Axis = 2;
    		else					// ignore encoder
    			Change1 = 0;
    
    
    		// check if the Axis just changed or we have been 
    		// converging to the target for a long time
    		if (Axis != LastAxis || (InMotion && Time_sec() > LastChangeTime + FINAL_TIME))
    		{
    			if (InMotion)
    				Move(LastAxis, Target);	//finalize any motion
    
    			LastAxis = Axis;
    			InMotion = FALSE;
    		}
    
    		if (Change1)			// did we move?
    		{
    			if (!InMotion)
    				Target = chan[Axis].Dest;
    			Target += Change1 * Factor;
    			MoveExp(Axis, Target, TAU);	// note: contains a WaitNextTimeSlice
    			LastChangeTime = Time_sec();
    			InMotion = TRUE;
    		}
    		else
    		{
    
    			WaitNextTimeSlice();	// execute loop once every time slice
    			// check if all axes are enabled
    			if (ch0->Enable && ch1->Enable && ch2->Enable)
    			{
    				SetBit(145);	// yes they are, enable the amplifier
    			}
    			else
    			{
    				ClearBit(145);	// no at least one is disabled, disable the amplifier
    			}
    			ServiceTimerSequence();	// service the timer sequencing
    			UpdateJogSpeeds();
    
    
    		}						// end of forever loop
    
    	}
    }
    
     //set Rate within Limits
    void DoLimitJog(double rate, int cmd)
    {
    	if (rate < 0.0)
    		rate = 0.0;
    	if (rate > 1.0)
    		rate = 1.0;
    
    	DoPCFloat(cmd, rate);
    }
    
    void UpdateJogSpeeds(void)
    {
    	static LastChangeCount = -1;
    	int Units, TWORD, HWORD, DWORD;
    	double rate;
    
    	// don't bother if nothing changed
    	if (EditChangeCount == LastChangeCount)
    		return;
    
    	// remember count before updating
    	LastChangeCount = EditChangeCount;
    
    	// Read double from a KMotionCNC Edit Control
    	// Persist Var identifies the Control and contents specifies 
    	// where the string data should be placed in the 
    	// Gather Buffer as an offset in words
    	if (GetEditControlDouble(&rate, 170, 1000))
    		return;					// exit if value is invalid
    
    	GetMiscSettings(&Units, &TWORD, &HWORD, &DWORD);	// check Units
    	if (Units == CANON_UNITS_MM)
    		rate = rate / 25.4;		// convert screen value to ipm   
    	DoLimitJog(rate / MAX_JOG_SPEED_X, PC_COMM_SET_JOG_OVERRIDE_X);
    	DoLimitJog(rate / MAX_JOG_SPEED_Y, PC_COMM_SET_JOG_OVERRIDE_Y);
    	DoLimitJog(rate / MAX_JOG_SPEED_Z, PC_COMM_SET_JOG_OVERRIDE_Z);
    
    
    }
    
    
    // sequence an IO Bit Based on Time in a non-blocking manner WAY LUBE PUMP
    
    //#define TIME_ON 1800.0//seconds
    //#define CYCLE_TIME 700.0 //seconds
    //#define OUTPUT_BIT 159 // which IO bit to drive
    void ServiceTimerSequence(void)
    {
    	//  static double T0=0.0;  // remember the last time we turned on
    	//double T=Time_sec(); // get current Time_sec
    
    	//if (T0==0.0 || T > T0 + CYCLE_TIME) T0=T;  // set start time of cycle
    
    	//if (T < T0 + TIME_ON)  // are we within the TIME_ON section of the cycle?
    	//  SetBit(OUTPUT_BIT);  //yes
    	//else
    	//  ClearBit(OUTPUT_BIT);  //no
    
    
    
    
    
    	int result;
    
    
    
    /// Handle FeedHold/Resume
    //      result = Debounce(ReadBit(FEEDHOLDBIT),&fcount,&flast,&flastsolid);
    	//  if  (result == 1)
    	//{
    	//if (CS0_StoppingState == 0)
    	//StopCoordinatedMotion();
    	//else
    	//ResumeCoordinatedMotion();
    	//}
    
    	/// Handle Cycle Start
    	//result = Debounce(ReadBit(CYCLESTARTBIT),&ccount,&clast,&clastsolid);
    	//if  (result == 1)
    	//{
    	//DoPC(PC_COMM_EXECUTE);
    	//}
    	/// Handle Coolant Pump
    	//result = Debounce(ReadBit(COOLANTBIT),&cocount,&colast,&colastsolid);
    	//if  (result == 1)
    	//{
    	//if (ReadBit(154) == 1)
    	//ClearBit(154);
    	//else
    	//SetBit(154);
    	//}
    
    
    	//}
    
    	/// Handle ESTOP
    	result = Debounce(ReadBit(ESTOP), &ecount, &elast, &elastsolid);
    	if (result == 0)
    	{
    		DoPC(PC_COMM_ESTOP);
    		ClearBit(145);			//Disable Servo Drives & vfd
    		ClearBit(157);			//Turn off FloodCoolant
    		ClearBit(158);			//Turn off Mist Coolant
    		ClearBit(159);			//WayLubePump
    		ClearBit(63);			//TC_OUT Solenoid
    		ClearBit(62);			//TC_IN Solenoid
    		ClearBit(61);			//TC_DOWN Solenoid
    		ClearBit(60);			//TC_UP Solenoid
    		ClearBit(59);			//Tool Release Solenoid
    		ClearBit(48);			//ZeroServoCommand to VFD
    		ClearBit(49);			//TC_CW
    		ClearBit(50);			//TC_CCW
    		ClearBit(156);			//SpindleOrientateProx minusVolt 
    		SetBit(147);			// turn off spindle clockwise
    		SetBit(148);			// turn off spindle counterclockwise
    		MsgBox("E-STOP Condition", MB_OK | MB_ICONEXCLAMATION);
    	}
    
    
    	// Handle X Axis Servo Drives Error Line
    	result = Debounce(ReadBit(XSDERRORLINEBIT), &xsdecount, &xsdelast, &xsdelastsolid);
    	if (result == 1)
    	{
    		DoPC(PC_COMM_ESTOP);
    		ClearBit(145);			//Disable Servo Drives & vfd
    		SetBit(147);			// turn off spindle clockwise
    		SetBit(148);			// turn off spindle counterclockwise
    		ClearBit(157);			//Turn off FloodCoolant
    		ClearBit(158);			//Turn off Mist Coolant
    
    		MsgBox("X ServoDrive Fault", MB_OK | MB_ICONEXCLAMATION);
    		ClearBit(144);			//Enable/Disable MainContactorRelay for servo drive main & logic power.
    	}
    
    	// Handle Y Axis Servo Drives Error Line
    	result = Debounce(ReadBit(YSDERRORLINEBIT), &ysdecount, &ysdelast, &ysdelastsolid);
    	if (result == 1)
    	{
    		DoPC(PC_COMM_ESTOP);
    		ClearBit(145);			//Disable Servo Drives & vfd
    		SetBit(147);			// turn off spindle clockwise
    		SetBit(148);			// turn off spindle counterclockwise
    		ClearBit(157);			//Turn off FloodCoolant
    		ClearBit(158);			//Turn off Mist Coolant
    
    		MsgBox("Y ServoDrive Fault", MB_OK | MB_ICONEXCLAMATION);
    		ClearBit(144);			//Enable/Disable MainContactorRelay for servo drive main & logic power.
    	}
    
    	// Handle Z Axis Servo Drives Error Line
    	result = Debounce(ReadBit(ZSDERRORLINEBIT), &zsdecount, &zsdelast, &zsdelastsolid);
    	if (result == 1)
    	{
    		DoPC(PC_COMM_ESTOP);
    		ClearBit(145);			//Disable Servo Drives & vfd
    		SetBit(147);			// turn off spindle clockwise
    		SetBit(148);			// turn off spindle counterclockwise
    		ClearBit(157);			//Turn off FloodCoolant
    		ClearBit(158);			//Turn off Mist Coolant
    
    		MsgBox("Z ServoDrive Fault", MB_OK | MB_ICONEXCLAMATION);
    		ClearBit(144);			//Enable/Disable MainContactorRelay for servo drive main & logic power.
    	}
    	// Handle VFD Error Output
    	result = Debounce(ReadBit(VFDERRORLINEBIT), &vfdecount, &vfdelast, &vfdelastsolid);
    	if (result == 1)
    	{
    		DoPC(PC_COMM_ESTOP);
    		ClearBit(145);			//Disable Servo Drives & vfd
    		SetBit(147);			// turn off spindle clockwise
    		SetBit(148);			// turn off spindle counterclockwise
    		ClearBit(157);			//Turn off FloodCoolant
    		ClearBit(158);			//Turn off Mist Coolant
    
    		MsgBox("VFD Fault", MB_OK | MB_ICONEXCLAMATION);
    	}
    	// Handle axis X minus limit switch
    	result = Debounce(ReadBit(XMINUSLIMITBIT), &xmcount, &xmlast, &xmlastsolid);
    	if (result == 1)
    	{
    		ClearBit(152);
    
    		MsgBox("X - Limit. Jog opposite direction.", MB_OK | MB_ICONEXCLAMATION);
    	}
    	// Handle axis X plus limit switch
    	result = Debounce(ReadBit(XPLUSLIMITBIT), &xpcount, &xplast, &xplastsolid);
    	if (result == 1)
    	{
    		ClearBit(152);
    
    		MsgBox("X + Limit. Jog opposite direction.", MB_OK | MB_ICONEXCLAMATION);
    	}
    
    	// Handle axis Y minus limit switch
    	result = Debounce(ReadBit(YMINUSLIMITBIT), &ymcount, &ymlast, &ymlastsolid);
    	if (result == 1)
    	{
    		ClearBit(152);
    
    		MsgBox("Y - Limit. Jog opposite direction.", MB_OK | MB_ICONEXCLAMATION);
    	}
    	// Handle axis Y plus limit switch
    	result = Debounce(ReadBit(YPLUSLIMITBIT), &ypcount, &yplast, &yplastsolid);
    	if (result == 1)
    	{
    		ClearBit(152);
    
    		MsgBox("Y + Limit. Jog opposite direction.", MB_OK | MB_ICONEXCLAMATION);
    	}
    
    
    	// Handle axis Z minus limit switch
    	result = Debounce(ReadBit(ZMINUSLIMITBIT), &zmcount, &zmlast, &zmlastsolid);
    	if (result == 1)
    	{
    		ClearBit(152);
    
    		MsgBox("Z - Limit. Jog opposite direction.", MB_OK | MB_ICONEXCLAMATION);
    	}
    	// Handle axis Z plus limit switch
    	result = Debounce(ReadBit(ZPLUSLIMITBIT), &zpcount, &zplast, &zplastsolid);
    	if (result == 1)
    	{
    		ClearBit(152);
    
    		MsgBox("Z + Limit. Jog opposite direction.", MB_OK | MB_ICONEXCLAMATION);
    	}
    	// Handle HALT
    	//result = Debounce(ReadBit(HALTBIT),&hcount,&hlast,&hlastsolid);
    	//if  (result == 1)
    	//{
    
    }
    
    
    		// Put a Float as a parameter and pass the command to the App
    int DoPCFloat(int cmd, float f)
    {
    	int result;
    	persist.UserData[PC_COMM_PERSIST + 1] = *(int *)&f;
    	return DoPC(cmd);
    }
    
    		// Pass a command to the PC and wait for it to handshake
    		// that it was received by either clearing the command
    		// or changing it to a negative error code
    int DoPC(int cmd)
    {
    	int result;
    
    	persist.UserData[PC_COMM_PERSIST] = cmd;
    
    	do
    	{
    		WaitNextTimeSlice();
    	}
    	while (result = persist.UserData[PC_COMM_PERSIST] > 0);
    
    	printf("Result = %d\n", result);
    
    	return result;
    }
    
    // Debounce a bit
    //
    // return 1 one time when first debounced high 
    // return 0 one time when first debounced low 
    // return -1 otherwise 
    #define DBTIME 300
    
    int Debounce(int n, int *cnt, int *last, int *lastsolid)
    {
    	int v = -1;
    
    	if (n == *last)				// same as last time?
    	{
    		if (*cnt == DBTIME - 1)
    		{
    			if (n != *lastsolid)
    			{
    				v = *lastsolid = n;	// return debounced value
    			}
    		}
    		if (*cnt < DBTIME)
    			(*cnt)++;
    	}
    	else
    	{
    		*cnt = 0;				// reset count
    	}
    	*last = n;
    	return v;
    
    
    }


    http://www.homecncstuff.elementfx.com/


  10. #370
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    3183
    Downloads
    0
    Uploads
    0

    Default Re: Hurco BMC20 Dynomotion Retrofit

    Hi Troy,

    Looks reasonable to me. Does the file exist in that directory? What prints on the Console?

    Regards
    TK http://dynomotion.com


  11. #371
    Member
    Join Date
    May 2012
    Location
    canada
    Posts
    430
    Downloads
    0
    Uploads
    0

    Default Re: Hurco BMC20 Dynomotion Retrofit

    Quote Originally Posted by Need TECH Help! View Post
    Hi Mark,
    I tried this before but has no effect leaving one opposite solenoid on. The air valve will stay maintained keeping air pressure on cylinder no matter what direction.
    Do you know the make/model of your solenoid valve? It looks like you have 2 coils based on your program using 2 different bit numbers. Most valves with 2 coils are 3 position, with the center position just blocking all ports. This leaks down after a period of time and causes the problem I had with the amera seiki. It is possible that yours it a 2 position valve (extend/reverse only) toggled back and forth by 2 coils, but its not common. Usually there is just one coil and spring return for 2 position valves.

    Quote Originally Posted by Need TECH Help! View Post
    Originally i had all for open with mufflers. Then i plugged off 2 and that helped but still not soft like it should be.
    This sounds odd. Kinda makes me wonder if something is connected wrong, replacing mufflers with plugs would normally be a major problem.

    Have a read over this: https://www.omega.co.uk/auto/pdf/SimpValvesGuide.pdf

    Another option that will work for you is to add flow control valves in the lines or right at the ports in the cylinder. Note that these valves only adjust flow in one direction, and the direction is important. Theres a bunch of info on these in that pdf too. Have a look at all your lines for flow control valves you may not have noticed. I still think your cylinder is most likely fine assuming its not leaking. They tend to last a very long time. Im always fearful of damaging something while fixing an item that wasn't even broke in the first place. Been there and done that lol.

    Mark



  12. #372
    Member Need TECH Help!'s Avatar
    Join Date
    Dec 2007
    Location
    United States
    Posts
    471
    Downloads
    0
    Uploads
    0

    Default Re: Hurco BMC20 Dynomotion Retrofit

    Hi Mark,
    They are 2 position.
    AutomationDirect
    The manifold has 4 exhaust ports, 2 at each end, gives you the option to direct the exhaust. I have worked on Hardinge VMCs that use a similar manifold and they dont use any mufflers, just a long pc of hose.

    I have control valves also but mettering it down to the point where it does not actuate as hard makes movement slow. A couple post back is a picture of the solenoid manifold assembly.

    Troy

    http://www.homecncstuff.elementfx.com/


Page 31 of 34 FirstFirst ... 2128293031323334 LastLast

Tags for this Thread

Posting Permissions

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


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

Hurco BMC20 Dynomotion Retrofit

Hurco BMC20 Dynomotion Retrofit

Hurco BMC20 Dynomotion Retrofit