Menu

Rotary Encoder Count

Help
Keith
2023-02-04
2023-02-07
  • Keith

    Keith - 2023-02-04

    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.

     
  • Anobium

    Anobium - 2023-02-04

    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.

     
  • Keith

    Keith - 2023-02-04

    I'll put this on the back burner for the time being Evan.

     
  • Keith

    Keith - 2023-02-06

    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>(

     
  • Anobium

    Anobium - 2023-02-06

    If 'value' is a number type.

    'value MOD 10'. See mod() in the Help.

     
  • Keith

    Keith - 2023-02-06

    It is saying "Your search returned no results." for either MOD 10 or mod() ??

     
  • Anobium

    Anobium - 2023-02-07

    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

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.