Scaling 0-1024 to 0-102
- slowpoke
- Offline
- Elite Member
- 
				  
		Less
		More
		
			
	
		- Posts: 206
- Thank you received: 28
			
	
						20 Aug 2024 00:22		 -  20 Aug 2024 00:24		#308179
		by slowpoke
	
	
		
			
	
	
		
	
			 		
													
	
				Scaling 0-1024 to 0-102 was created by slowpoke			
			
				I have an exposed analog from pot value in HAL "arduino.ain.0"  (range is 0-1024), and I want to drive "halui.axis.jog-speed" with that value divided by 10
1) Am I best to use mult2, scale or something else?
2) How to implement whatever you suggest?
Much appreciated.
This entire HAL concept and the implementation with HALShow is simply fantastic!
I cobbled together a really rough around the edges (proof of concept) gadget to test messaging before going to an actual PCB and so far so good, All the buttons are working, Pot's next and then a few messages to the display and proof of concept will be complete.
  
			
					1) Am I best to use mult2, scale or something else?
2) How to implement whatever you suggest?
Much appreciated.
This entire HAL concept and the implementation with HALShow is simply fantastic!
I cobbled together a really rough around the edges (proof of concept) gadget to test messaging before going to an actual PCB and so far so good, All the buttons are working, Pot's next and then a few messages to the display and proof of concept will be complete.
Attachments:
		Last edit: 20 Aug 2024 00:24  by slowpoke.			
			Please Log in or Create an account to join the conversation.
- Benb
- 
				  
- Offline
- Elite Member
- 
				  
		Less
		More
		
			
	
		- Posts: 183
- Thank you received: 60
			
	
						20 Aug 2024 01:54				#308183
		by Benb
	
	
		
			
	
	
		
	
			 		
													
	
				Replied by Benb on topic Scaling 0-1024 to 0-102			
			
					Attachments:
		The following user(s) said Thank You: slowpoke 	
			Please Log in or Create an account to join the conversation.
- slowpoke
- Offline
- Elite Member
- 
				  
		Less
		More
		
			
	
		- Posts: 206
- Thank you received: 28
			
	
						20 Aug 2024 09:22		 -  20 Aug 2024 09:24		#308203
		by slowpoke
	
	
		
			
				
Thanks for that.
The visual (block diagram) explanation works much better for me than the plain text explanation that I initially found.
excerpt from my postgui for anyone trying to figure this out in the future.... this works for me:
# Analog Inputs - Jog Speed
loadrt scale count=1
addf scale.0 servo-thread
setp scale.0.offset 0.0
setp scale.0.gain 0.12
net jog-pot-in scale.0.in <= arduino.ain.0
net jog-speed halui.axis.jog-speed <= scale.0.out
					
	
	
			 		
													
	
				Replied by slowpoke on topic Scaling 0-1024 to 0-102			
			Thanks for that.
The visual (block diagram) explanation works much better for me than the plain text explanation that I initially found.
excerpt from my postgui for anyone trying to figure this out in the future.... this works for me:
# Analog Inputs - Jog Speed
loadrt scale count=1
addf scale.0 servo-thread
setp scale.0.offset 0.0
setp scale.0.gain 0.12
net jog-pot-in scale.0.in <= arduino.ain.0
net jog-speed halui.axis.jog-speed <= scale.0.out
		Last edit: 20 Aug 2024 09:24  by slowpoke.			
			Please Log in or Create an account to join the conversation.
		Time to create page: 0.201 seconds	
 
													