Multi encoder sketch with acceleration

Post your cool example code here.
max_sl
Posts: 4
Joined: Thu Dec 15, 2016 2:35 pm
Location: Russia, Saint-Petersburg

Re: Multi encoder sketch with acceleration

Post by max_sl » Fri Dec 16, 2016 9:12 am

Thanks for the answers.
My "ENCODER RATE" value changed to 1. Because with the value "1000" it loses very many impulses.
I just want to get direct number of impulses by STM32duino, like in this article (http://blablacode.ru/mikrokontrollery/531) It`s not in English but the code is universal. I want to get result like this:

u16 cnt = TIM3->CNT;
Delay(100);

But there are no available descriptions of translation stm32 functions to stm32duino ( in Internet) :(

P.S.
Transition "millis" to "micros" cannot give an effect for my device.

User avatar
Pito
Posts: 1385
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Multi encoder sketch with acceleration

Post by Pito » Fri Dec 16, 2016 9:52 am

While browsing the Rot Enc debouncing this seems to be the most discussed solution:
Rotary Encoder debounce.JPG
Rotary Encoder debounce.JPG (22.62 KiB) Viewed 281 times
The capacitors range from 10nF - 100nF; the R1,2 from 3k3 to 33k; the R3,4 from 180ohm to 2k2.
Mind R1/R3 and R2/R4 create a voltage divider, where the CMOS threshold is Vcc/2.
I just want to get direct number of impulses by STM32duino, like in this article..
That could be done in stm32duino, sure, but it does just counts the pulses on pin A or B via internal counter.

The GPIO and TIMER APIs you may use with stm32duino are here:
http://docs.leaflabs.com/static.leaflab ... /apis.html
Pukao Hats Cleaning Services Ltd.

max_sl
Posts: 4
Joined: Thu Dec 15, 2016 2:35 pm
Location: Russia, Saint-Petersburg

Re: Multi encoder sketch with acceleration

Post by max_sl » Fri Dec 16, 2016 10:27 am

Ok.
I work with Arduino and STM32 for about 3 month so could you explain these strings:

Code: Select all

if ( (gpio_read_bit(PIN_MAP[encoderpinA].gpio_device, PIN_MAP[encoderpinA].gpio_bit) ? HIGH : LOW) != A_set )
  {
    A_set = !A_set;
    if ( A_set && !B_set )
    {
      //if (millis() - encodertimer > 3) 
      encoderpos += 1;
      //else
      //encoderpos += 5;
    }
   encodertimer = micros();
  }
Why +=5? What provides this condition?

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest