Hi, thank you looking.
Im struggling with what should be simple but I cant get my head around it and I am just going around in circles. Its even harder as we cant deal in fractions!
I have an ADC input that ranges from 340 - 1000
Id like to take the input and use it to set the speed of a motor that is controlled using the pwmduty command and the range is 0-1024.
How do I take my 340 -1000 input and turn that into a value for the Pwmduty of 0 - 1024
I have come up with this bit of code but its clunky and the motor speed up has obvious incremental steps and Id like it to be more linear?
Thanks for helping as I have about given up and I am going around in circles.
JPU
Im struggling with what should be simple but I cant get my head around it and I am just going around in circles. Its even harder as we cant deal in fractions!
I have an ADC input that ranges from 340 - 1000
Id like to take the input and use it to set the speed of a motor that is controlled using the pwmduty command and the range is 0-1024.
How do I take my 340 -1000 input and turn that into a value for the Pwmduty of 0 - 1024
I have come up with this bit of code but its clunky and the motor speed up has obvious incremental steps and Id like it to be more linear?
Code:
pwmout b.4,255,0
main:
Readadc10 b.5,adcvalu
adcvalu=adcvalu-340
adcvalu=adcvalu*15/10
PWMDUTY B.4,adcvalu
etc
etc
goto main
JPU