Beispiel #1
0
main()
{
	float speed = *(float *)&persist.UserData[97];  // value stored is actually a float 
	float LastSpeed = *(float *)&persist.UserData[99];  // get last speed setting 
	float LastState = persist.UserData[98];  // get last state 
	
	if (LastState==1)  
	{
		// if spindle was CW now we want CCW 
		// spin down
		
		ClearBit(154);
		ClearBit(155);
		LastSpeed = 0.0;
		Jog(SPINDLEAXIS,0);
		while (!CheckDone(SPINDLEAXIS)) ;
	}
	
	// turn spindle on CCW and ramp to new speed
	
	SetBit(155);
	
	// spindle is already on, so ramp to new speed
	
	if (LastSpeed != speed)
	{
		LastSpeed = speed;
		Jog(SPINDLEAXIS,LastSpeed * FACTOR);
	}
	
	*(float *)&persist.UserData[99] = LastSpeed;  // save the last speed
	persist.UserData[98] = -1;  // remember we are CCW
}
Beispiel #2
0
void SimpleHome(int axis,float speed,int dir,int bit,int polarity, float offset)
{
	int SaveLimits;  //place to save limit switch settings

	DisableAxis(axis);
	
	// disable the limits (first save how they were set) 
	SaveLimits = chan[axis]->LimitSwitchOptions;
	chan[axis]->LimitSwitchOptions = 0;
	
	EnableAxis(axis);	// enable axis and begin servoing where we are 

 	// Home - jog until it sees the limit

	Jog(axis,speed*dir);      	// jog slowly 
	while (!ReadBit(bit)) ;  	// loop until IO bit goes high
	Jog(axis,0);				// stop
	while (!CheckDone(axis)) 	// loop until motion completes
		if (!chan[axis].Enable) return; 	// abort/exit if diasabled 
	DisableAxis(axis);			// disable the axis
	Zero(axis);					// Zero the position
	EnableAxis(axis);			// re-enable
	Move(axis,-dir * offset);	// move some amount inside the limits
	while (!CheckDone(axis)) ; 	// loop until motion completes 
	chan[axis]->LimitSwitchOptions = SaveLimits;  // restore limit settings
}
main()
{
	float speed = *(float *)&persist.UserData[SPEEDVAR];  // value stored is actually a float 
	float LastState = persist.UserData[STATEVAR];  // get last state 
	
	if (LastState==1)  
	{
		// if spindle was CW now we want CCW 
		// spin down
		
		ClearBit(SPINDLECW_BIT);
		ClearBit(SPINDLECCW_BIT);
		Jog(SPINDLEAXIS,0);
		while (!CheckDone(SPINDLEAXIS)) ;
	}
	
	// turn spindle on CCW and ramp to new speed
	SetBit(SPINDLECCW_BIT);
	
	// spindle is already on, so ramp to new speed
	Jog(SPINDLEAXIS,-speed * FACTOR);
	printf("Jogging Spindle %f counts/sec\n",speed * FACTOR);
	
	persist.UserData[STATEVAR] = -1;  // remember we are CCW
}
Beispiel #4
0
void DoSpeedAxis(int ch, int Select, double *LastSpeed, double Speed)
{
	if (ReadBit(Select))  //is this axis selected ??
	{
		Jog(ch,Speed);
		*LastSpeed = Speed;
		T0=T1;  // save last time speed was changed
	}
	else if (*LastSpeed != 0.0) //not selected so stop if was moving
	{
		 Jog(ch,0.0);
		*LastSpeed=0.0;
	}
}
Beispiel #5
0
void ServiceCSS(void)
{
	float rpm;
	double T=Time_sec();

	if (*css_mode == 2 && T > css_T) // check if we are in CSS mode and it is time to update
	{
		css_T=T+CSS_UPDATE_DT;  // determine next time to update
		
		// convert axis position to distance from center in inches
		float radius = fast_fabs((chan[CS0_axis_x].Dest - *css_xoff) * *css_xfactor);
		
		if (radius > 0.0f)
			rpm = *css_s / (radius * (TWO_PI_F/60.0f));
		else
			rpm = *css_max_rpm;

		if (rpm > *css_max_rpm) rpm = *css_max_rpm;
				
		if (persist.UserData[STATEVAR]!=0)  // if spindle is already on, ramp to new speed
			Jog(SPINDLEAXIS,rpm * FACTOR);
		
//		printf("xoff=%f radius= %f xfactor=%f s=%f(ips) maxrpm=%f rpm=%f\n",*css_xoff,radius,*css_xfactor,*css_s,*css_max_rpm,rpm);
	}
}
Beispiel #6
0
void MakeSelection(S1){
    
    switch(S1){
        case 1:  TestServo1();
                 debounce(1); 
                 break;
        case 2:  TestServo2();
                 debounce(1);
                 break;
        case 3:  TestServo3();
                 debounce(1);
                  break;   
        case 4:  TestServo4();
                 debounce(1);
                 break;
        case 5:  TestServo5();
                 debounce(1);
                 break;
        case 6:  TestServo6();
                 debounce(1);
                 break;
        case 7:  SetTo90();
                 debounce(1);
                 break;
        case 8:  GrabBlock();
                 break;
        case 9:  Jog();
                 break;
                 
        
    }
}
Beispiel #7
0
main()
{
	ch0->LimitSwitchOptions=0x00000000; // disable limits
	
	Jog(0,-100);          				// start moving
	while (!Readbit(8)) ; 				// wait for switch (input #8) to change
	
	Jog(0,0);		      				// stop
	while (!CheckDone(0))  ;  			// wait till we are stopped

	Zero(0);                            // Set current position to 0

	Move(0,1000);	      				// move off limit
	while (!CheckDone(0))  ;  			// wait till we are stopped
	
	// re-enable limits, bit 8 both ends, active low, disable all axis
	ch0->LimitSwitchOptions=0x808000f;	
}
Beispiel #8
0
main()
{
	// spin down
	
	ClearBit(SPINDLECW_BIT);
	ClearBit(SPINDLECCW_BIT);
	Jog(SPINDLEAXIS,0);
	printf("Jogging Spindle Stop\n");
	persist.UserData[STATEVAR] = 0;  // remember we are Off
	while (!CheckDone(SPINDLEAXIS)) ;
}
Beispiel #9
0
main()
{
    int message = persist.UserData[0];  // Mach3 message ID
    int Direction = persist.UserData[1];  // Mach3 Spindle Direction
    float speed = *(float *)&persist.UserData[2];  // value stored is actually a float
    int DirFactor = 1;

    if (Direction==0) DirFactor=-1; // change Direcion 0 or 1 to DirFactor -1 or +1


    printf("Mach3 Notify Message=%d, Direction=%2d, Spindle Set to %f\n",message,Direction,speed);

    switch (message)
    {
    case EX_SPINSPEED:
        if (Direction != -1)
        {
            printf("Spindle Speed Set to %f\n",speed);
            Jog(SPINDLE_AXIS,speed*FACTOR*DirFactor);
        }
        break;

    case EX_SPINON:
        if (Direction==0)
        {
            printf("Spindle CW ON\n");
        }
        else if (Direction==1)
        {
            printf("Spindle CCW ON\n");
        }
        break;

    case EX_SPINOFF:
        printf("Spindle Stop\n");
        Jog(SPINDLE_AXIS,0.0);
        break;
    }
}
Beispiel #10
0
main()
{
	int i,n_Samples = 0.005 / TIMEBASE;
	
	gather.Inject = FALSE;	// Don't inject any Data anywhere

	gather.list[0].type = GATHER_DOUBLE_TYPE; // Gather Dest
	gather.list[0].addr = &chan[4].Dest;

	gather.list[1].type = GATHER_DOUBLE_TYPE; // Gather Pos
	gather.list[1].addr = &chan[4].Position;

	gather.list[2].type = GATHER_FLOAT_TYPE ; // Gather Output
	gather.list[2].addr = &chan[4].Output;

	gather.list[3].type = GATHER_FLOAT_TYPE ; // Gather Output
	gather.list[3].addr = &chan[4].last_vel;

	gather.list[4].type = GATHER_END_TYPE;  
	
    gather.bufptr = (double *)0xfffffffc;   // force more than endbuf
    gather.endptr = gather_buffer + 4 * n_Samples;

	Jog(4,250000);
	Delay_sec(1);
	TriggerGather();  // start capturing data
	Delay_sec(0.002);
	Jog(4,-250000);
	while (!CheckDoneGather()) ; // what till all captured
	Jog(4,0);
	
	// print all captured data (every 50th sample)
	
	for (i=0; i<n_Samples; i+=1)
		printf("%d,%f,%f,%f,%f\n", i,gather_buffer[i*4],gather_buffer[i*4+1],
			gather_buffer[i*4+2],gather_buffer[i*4+3]); 

}
Beispiel #11
0
main()
{
	float speed = *(float *)&persist.UserData[KMVAR];  // value stored is actually a float 
	float LastState = persist.UserData[STATEVAR];  // get last state 
	
	persist.UserData[SPEEDVAR] = persist.UserData[KMVAR];  // Always save the last desired speed 
	
	if (LastState==0)  
	{
		// if spindle is off and User Changes the speed 
		// just save the desired speed
		
		return 0;
	}
	
	// spindle is already on, so ramp to new speed
	Jog(SPINDLEAXIS,LastState * speed * FACTOR);
	printf("Jogging Spindle %f counts/sec\n",speed * FACTOR);
}
Beispiel #12
0
void CTenkeyOpr::Seq(void)
{
	Tenkey();
	Jog();
}
Beispiel #13
0
main()
{
	Jog(0,10);
	Delay_sec(1);
	Jog(0,0);
}