My Spindle Motor Coolant Controller Project is moving on at reasonable pace and on of the next part of the project involves including a Rotary Encoder to increment and decrement a temperature range and a Fan Speed PWM service.
The Rotary Encoder I have is working which increments and decrements a numeric value from 0 to 1000 and is quite stable but what I want it to do is increment/decrement in decimal value like 30.5 , 30.6 etc.
It's basic maths again, but heck I haven't used this stuff in absolute eons, I have fumbled on nearly all day trying to work it out to where my head hurts!
. I know there are some really clever lads out there who do this as a breakfast crossword.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Still on the same tack so to speak but with a different approach. Is it possible in GCB to take the last digit of a numeric value of say 648 to display the last digit '8' using something like
'Print Right(value, 1) or do I have to convert the numeric value into a string?
Running 'Print Right(value, 1)' spews out a boatload of symbols and characters from what looks like the LCD Character Set 8>(
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The Help search is modulo. Where % is the same as MOD.
The following program will display the last digit.
The modulo operation returns the remainder or signed remainder of a division, after one number is divided by another.
#chip 16f886
#option Explicit
#DEFINE USART_BAUD_RATE 19200
#DEFINE USART_TX_BLOCKING
#DEFINE USART_DELAY OFF
Dim myVar as Word
for myVar = 1 to 0xFFFF
HSerPrint myVar % 10
HSerPrint " "
HSerPrint myVar MOD 10
HserPrintCRLF
wait 50 ms
next
end
Enjoy
Edit: Fixed baud rate
Last edit: William Roth 2023-02-07
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have been along this road in the past but through one thing and another (usually health issues) I had to put it aside.
The problem I'm having is with the rotary encode limitation rrange.
This instruction line is responsible (I think)
encoder(value, 100, 460) ;between 100 and 460, inclusive
Whilst the value of 460 stops the upper value from going above 460' I don't seem to be able to work out how to stop it from going below 100.
I stand to be corrected but I think it is handled by the include Encoder.h by Thomas Henry 6/7/2014
I'm not too sure how it works (Once again well above my pay scale) but it handles a rotary encoder really well particularly the RUNCCI-YUN KY-040 Rotary Encoder Module from Amazon.
Yes it is in the include Encoder.h Line 82 refers. Thomas has written up an explanation on line 31 how it works. It states the minimum is '0' and the maximum is 16383.
I need it to start at 100 which works out at 10˚C when divided by 10 and tops out at 46˚C
What happens below 10˚C it starts to display weird and wonderful decimal digits and doesn't store the value to the EEPROM correctly. In layman's terms it goes boobs up!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
A quick look as I do not have the setup you have. And, I am not totally sure how the encoder routines works. But, you know encode() will set 'value' to 0 to 16383, so call the method then scale to the constraints you want of 100, 460.
encoder(value, 100, 460) ;between 100 and 460, inclusive
value = Scale ( Value, 0, 16383, 100, 460)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have eventually managed to resolve the Encoder issues in my project. I apologise in advance to the Author of the encoder.h include file, Thomas Henry but my 'Cack-Handed Fix' involved modifying a few variables in the include file.
I'm still unsure as mathmatical equation but changing two values in a simple IF statement gave me the desired effect of an elevated minimum value preventing a negative overflow which was causing a major headache when storing the value to EPPROM
Now fhe next couple of issues, one of which is a mystery. The instruction "Pulsein" in a loop stall's (freezes) the program. and I don't seem to be able to find anything on it.
My Spindle Motor Coolant Controller Project is moving on at reasonable pace and on of the next part of the project involves including a Rotary Encoder to increment and decrement a temperature range and a Fan Speed PWM service.
The Rotary Encoder I have is working which increments and decrements a numeric value from 0 to 1000 and is quite stable but what I want it to do is increment/decrement in decimal value like 30.5 , 30.6 etc.
It's basic maths again, but heck I haven't used this stuff in absolute eons, I have fumbled on nearly all day trying to work it out to where my head hurts!
. I know there are some really clever lads out there who do this as a breakfast crossword.
What range does it need to be?
And, we can assume 1 decimal point.
What will be happening with the value? display on lcd? send via serial to terminal?
Need to know the range before being able to help.
I'll put this on the back burner for the time being Evan.
Still on the same tack so to speak but with a different approach. Is it possible in GCB to take the last digit of a numeric value of say 648 to display the last digit '8' using something like
'Print Right(value, 1) or do I have to convert the numeric value into a string?
Running 'Print Right(value, 1)' spews out a boatload of symbols and characters from what looks like the LCD Character Set 8>(
If 'value' is a number type.
'value MOD 10'. See mod() in the Help.
It is saying "Your search returned no results." for either MOD 10 or mod() ??
The Help search is modulo. Where
%is the same asMOD.The following program will display the last digit.
The modulo operation returns the remainder or signed remainder of a division, after one number is divided by another.
Enjoy
Edit: Fixed baud rate
Last edit: William Roth 2023-02-07
I have been along this road in the past but through one thing and another (usually health issues) I had to put it aside.
The problem I'm having is with the rotary encode limitation rrange.
This instruction line is responsible (I think)
I have put the entire code in a zip file below
Last edit: Keith 2026-03-21
I will take a look for you.
Many Thanks Evan
I cannot find a sub() or function() called encoder().
Help me.
I stand to be corrected but I think it is handled by the include Encoder.h by Thomas Henry 6/7/2014
I'm not too sure how it works (Once again well above my pay scale) but it handles a rotary encoder really well particularly the RUNCCI-YUN KY-040 Rotary Encoder Module from Amazon.
Once again I have attached the encoder zip below
Yes it is in the include Encoder.h Line 82 refers. Thomas has written up an explanation on line 31 how it works. It states the minimum is '0' and the maximum is 16383.
I need it to start at 100 which works out at 10˚C when divided by 10 and tops out at 46˚C
What happens below 10˚C it starts to display weird and wonderful decimal digits and doesn't store the value to the EEPROM correctly. In layman's terms it goes boobs up!
I cannot get the source ( with the .h instaled ) to compile.
and, this will not compile.
Last edit: Anobium 2026-03-22
I don't have a clue what is causing the problem. DSDATA is the byte which handles the Digital Temperature Sensor (DS1822)
what happens if you Comment it out as it is not needed to resolve the encoder issue (just a thought)
I must a have a different source file to what you are using. If yours compiles then we are not working on the same source file.
A quick look as I do not have the setup you have. And, I am not totally sure how the encoder routines works. But, you know encode() will set 'value' to 0 to 16383, so call the method then scale to the constraints you want of 100, 460.
I have eventually managed to resolve the Encoder issues in my project. I apologise in advance to the Author of the encoder.h include file, Thomas Henry but my 'Cack-Handed Fix' involved modifying a few variables in the include file.
I'm still unsure as mathmatical equation but changing two values in a simple IF statement gave me the desired effect of an elevated minimum value preventing a negative overflow which was causing a major headache when storing the value to EPPROM
Now fhe next couple of issues, one of which is a mystery. The instruction "Pulsein" in a loop stall's (freezes) the program. and I don't seem to be able to find anything on it.
Last edit: Keith 2026-03-24