ebox.comp for gearbox 2speed
- SOLD
- Offline
- Premium Member
- 
				  
		Less
		More
		
			
	
		- Posts: 116
- Thank you received: 12
			
	
						26 Oct 2023 11:39				#283857
		by SOLD
	
	
		
			
				
					
	
			
			 		
													
	
				Replied by SOLD on topic ebox.comp for gearbox 2speed			
			Thanks, I'm testing. and will inform youI see the problem, the component does a check for a change in the spindle speed:
[/code]// Only do anything if the spindle speed has changed if ( fabs(spindle_speed - last_speed) < 50) return; But it never updates the "last_speed" so this comparison always returns "false" so the code continues and the timer is set back to 2000. Try this version. [code]component ebox "electronic gearbox component"; license "GPL"; pin in bit spindle-on-in; pin out bit spindle-on-out; pin in float spindle-speed; pin out bit relay1; pin out bit relay2; pin out bit relay3; function _; include "rtapi_math.h"; ;; FUNCTION(_){ static int timer; static double last_speed = -100; if (timer > 0){ timer -= 1; spindle_on_out = 0; } else { spindle_on_out = spindle_on_in; } // Only do anything if the spindle speed has changed if ( fabs(spindle_speed - last_speed) < 50) return; last_speed = spindle_speed; if (spindle_speed >= 1500 ){ relay1 = 0; relay2 = 0; relay3 = 0; spindle_on_out = 0; timer = 2000; } else { relay1 = 1; relay2 = 0; relay3 = 0; spindle_on_out = 0; timer = 2000; } }
Please Log in or Create an account to join the conversation.
- andypugh
- 
				  
- Offline
- Moderator
- 
				  
		Less
		More
		
			
	
		- Posts: 19677
- Thank you received: 4554
			
	
						26 Oct 2023 11:50				#283858
		by andypugh
	
	
		
			
				
Does the component need to calculate the desired motor speed for a given spindle input speed?
					
	
	
			 		
													
	
				Replied by andypugh on topic ebox.comp for gearbox 2speed			
			It's probably better to wait for the sensors to change state, and time-out with an error message after 4 seconds than to always wait 4 seconds.1. Connect spindle.0.on to the spindle-on-in pin.
2. Check RPM from spindle encoder. whether it is 0 or not. If not, wait until it is 0 and then continue.
3. Read speed from spindle-speed pin. If less than or equal to 2000, relay 1 output = 1 to open the air cylinder, push the gear down, wait 4 seconds and check the sensor 1 input. Read the value as 1 or not. If not 1 then display a warning message and cancel and if it is 1 then spindle-on-out pin =1.
4.. Read speed from spindle-speed pin. If more than 2000, relay 1 output = 0 to open the air cylinder, push the gear up, wait 4 seconds and check the sensor 2 input. Read the value as 1 or not. If not 1 then display a warning message and cancel and if it is 1 then spindle-on-out pin =1.
Does the component need to calculate the desired motor speed for a given spindle input speed?
		The following user(s) said Thank You: SOLD 	
			Please Log in or Create an account to join the conversation.
- SOLD
- Offline
- Premium Member
- 
				  
		Less
		More
		
			
	
		- Posts: 116
- Thank you received: 12
			
	
						26 Oct 2023 12:09		 -  26 Oct 2023 12:12		#283861
		by SOLD
	
	
		
			
	
	
			 		
													
	
				Replied by SOLD on topic ebox.comp for gearbox 2speed			
			
				No need to calculate speed. I'm thinking of using input. Select gear-a Connect from relay, select pid.s			
					net spindle-pid-out  pid.s.output    => scale.gear.in
net gear-ratio       ratio_select.out-f => scale.gear.gain
setp ratio_select.in00 0.000167
setp ratio_select.in01 0.000500
net gear-select-a         =>  ratio_select.sel0
net spindle-output        <=  scale.gear.out
		Last edit: 26 Oct 2023 12:12  by SOLD.			
			Please Log in or Create an account to join the conversation.
- SOLD
- Offline
- Premium Member
- 
				  
		Less
		More
		
			
	
		- Posts: 116
- Thank you received: 12
			
	
						26 Oct 2023 12:17		 -  26 Oct 2023 12:18		#283863
		by SOLD
	
	
		
			
	
	
			 		
													
	
				Replied by SOLD on topic ebox.comp for gearbox 2speed			
			
					
		Last edit: 26 Oct 2023 12:18  by SOLD.			
			Please Log in or Create an account to join the conversation.
- SOLD
- Offline
- Premium Member
- 
				  
		Less
		More
		
			
	
		- Posts: 116
- Thank you received: 12
			
	
						26 Oct 2023 15:30				#283870
		by SOLD
	
	
		
			
				
This new version It works with every function.
I increased the time from 2000 to 8000 to see how it behaved.
Found that the next Gcode worked without waiting for 8000. This may be caused by incorrect hal linking. I'll check again.
Or must use a spindle-at-speed to check the correct RPM? before the next G-Code will run But it is complicated to use an encoder from a spindle motor. Because it has revolutions that do not match the actual output from the reduction gear.
					
	
			
			 		
													
	
				Replied by SOLD on topic ebox.comp for gearbox 2speed			
			
Try this version.
component ebox "electronic gearbox component"; license "GPL"; pin in bit spindle-on-in; pin out bit spindle-on-out; pin in float spindle-speed; pin out bit relay1; pin out bit relay2; pin out bit relay3; function _; include "rtapi_math.h"; ;; FUNCTION(_){ static int timer; static double last_speed = -100; if (timer > 0){ timer -= 1; spindle_on_out = 0; } else { spindle_on_out = spindle_on_in; } // Only do anything if the spindle speed has changed if ( fabs(spindle_speed - last_speed) < 50) return; last_speed = spindle_speed; if (spindle_speed >= 1500 ){ relay1 = 0; relay2 = 0; relay3 = 0; spindle_on_out = 0; timer = 2000; } else { relay1 = 1; relay2 = 0; relay3 = 0; spindle_on_out = 0; timer = 2000; } }
This new version It works with every function.
I increased the time from 2000 to 8000 to see how it behaved.
Found that the next Gcode worked without waiting for 8000. This may be caused by incorrect hal linking. I'll check again.
Or must use a spindle-at-speed to check the correct RPM? before the next G-Code will run But it is complicated to use an encoder from a spindle motor. Because it has revolutions that do not match the actual output from the reduction gear.
Please Log in or Create an account to join the conversation.
- andypugh
- 
				  
- Offline
- Moderator
- 
				  
		Less
		More
		
			
	
		- Posts: 19677
- Thank you received: 4554
			
	
						27 Oct 2023 11:35				#283905
		by andypugh
	
	
		
			
	
			
			 		
													
	
				Replied by andypugh on topic ebox.comp for gearbox 2speed			
			
				It probably makes sense to combine all of the functions into one component.
gear ratio selection, including waiting for zero speed to change gear
spindle to motor gear ratio calculation.
spindle-at-speed determination, based on the encoder feeback (especially if the encoder is on the motor rather than the spindle)
					gear ratio selection, including waiting for zero speed to change gear
spindle to motor gear ratio calculation.
spindle-at-speed determination, based on the encoder feeback (especially if the encoder is on the motor rather than the spindle)
Please Log in or Create an account to join the conversation.
- SOLD
- Offline
- Premium Member
- 
				  
		Less
		More
		
			
	
		- Posts: 116
- Thank you received: 12
			
	
						28 Oct 2023 03:26		 -  28 Oct 2023 03:28		#283931
		by SOLD
	
	
		
			
				
					
	
	
			 		
													
	
				Replied by SOLD on topic ebox.comp for gearbox 2speed			
			This component is in the correct order of operation. It should be developed. But it's beyond my ability to do it. I hope you will add an ebox function. in future versions of Linux CNCIt probably makes sense to combine all of the functions into one component.
gear ratio selection, including waiting for zero speed to change gear
spindle to motor gear ratio calculation.
spindle-at-speed determination, based on the encoder feeback (especially if the encoder is on the motor rather than the spindle)
		Last edit: 28 Oct 2023 03:28  by SOLD.			
	
		The following user(s) said Thank You: COFHAL 	
			Please Log in or Create an account to join the conversation.
		Time to create page: 0.186 seconds	
