Jump to content

Code Example for 2-step Encoder Speed


Recommended Posts

Hi there,

does anyone has a code example for the following behaviour of an encoder:

When tweaking slow, he should react precise. When tweaking fast, it should be possible to rise from 0 zo 127 with one 300° Turn. I thougt of combining a timer that measures the turning-speed and then to arrange the several speed procedures.

Best regards,

digital23

Link to comment
Share on other sites

Oh, are there any apps-examples that I do not konw  :o ?

In what apps, please? Do you have code example for this? Thank you  :)

Regs,

digital23

http://www.ucapps.de/mios_fun.html#MIOS_ENC_SpeedSet

Greets, Roger

MIOS_ENC_SPEED_FAST

  ~~~~~~~~~~~~~~~~~~~

        ;; in this speed mode the increment value depends on the

        ;; rotational speed based on the following formula:

        ;;    speed_ctr: decremented with every update cycle

        ;;    (-> MIOS_SRIO_UpdateFrqSet)

        ;;               (normaly 1 ms) to measure the time between

        ;;               two encoder steps

        ;;               Init value: 0x7f

        ;;               reaches 0x00 after 127 update cycles

        ;;              (normaly after 127 ms)

        ;;    MIOS_PARAMETER2: specified with the MIOS_ENC_SpeedSet

        ;;

        ;;                     function, allowed values:

        ;;                        0 (fast)     -> divider = 2^(7-0) = 128

        ;;                        1 (faster)   -> divider = 2^(7-1) =  64

        ;;                        ...

        ;;                        7 (fastest)  -> divider = 2^(7-7) =   1

        ;; ->

        ;;    incrementer = speed_ctr / (2^(7-MIOS_PARAMETER2))

        ;; set speed for encoder #0 to "fast", speed exponent value is 2

        movlw        0x02                        ; speed exponent

        movwf        MIOS_PARAMETER2

        movlw        MIOS_ENC_SPEED_FAST        ; fast speed mode

        movwf        MIOS_PARAMETER1

        movlw        0x00                        ; rotary encoder #0

        call        MIOS_ENC_SpeedSet

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...