Missing impulses, help needed (sorry for being confused)

18 views
Skip to first unread message

Linus Anderberg

unread,
Apr 22, 2015, 7:02:45 AM4/22/15
to ioio-...@googlegroups.com
Starting a new thread since my 2 previous where a bit confusing, Let me instead describe my problem and maybe someone can point me to a possible solution.
please excuse me if this all looks simple but I'm some what new to java and still learning the ropes.

I'm using an IDrive from a BMW. Its a kind of rotary and uses photo resistors to determines what way and how many steps you rotate it. I use this rotary to animate GUI in my app.

The way it works is that the 2 photo resistors are placed slightly offset and are either lit or dark. when rotating the rotary it cut or lit one photo resistors a fragment before the other. this is how I determines what way I rotate. when the rotary is inactive both photo resistors are lit or dark.

Right now I'm just reading the photo resistors periodically with digitalinput.read() and I tend to miss the offset cut from time to time, especially over bluetooth, witch makes things a bit erratic.

Does anyone have a suggestion how i should do this to catch all "pulses"?


//This is called every time in the ioio loop

public void setRotation(boolean DigitalInput1, boolean DigitalInput2){
 oldA = A;
 oldB = B;
 oldRotation = rotation;
 A = DigitalInput1;
 B = DigitalInput2;

// CALCULATE ROTATION
// 1 = CW  
//-1= CCW
  if(A != oldA){
  if(A != B){
  rotation = 1;
  }else{
  rotation = -1;
  }
  }
  if(B != oldB){
  if(B == A){
  rotation = 1;
  }else{
  rotation = -1;
  }
  }
// CALCULATES KNOB steps  
  if(A && B && ifChange ==0){
   if(rotation == 1 && oldRotation == rotation){counter++;}
   if(rotation == -1 && oldRotation == rotation){counter--;}
   ifChange = 2;
  }else if(!A && !B && ifChange == 2){
   if(rotation == 1 && oldRotation == rotation){counter++;}
   if(rotation == -1 && oldRotation == rotation){counter--;}
   ifChange = 0;
  }
  
  
 }

Ytai Ben-Tsvi

unread,
Apr 24, 2015, 12:41:38 AM4/24/15
to ioio-...@googlegroups.com
What you're describing sounds like a quadrature encoder interface. Ideally, there would be support for it in the IOIO firmware, but I haven't gotten around to that. If all you care about is speed, you can use the PulseInput interface. If you want count and/or direction, your options are:
  1. If the pulse rate is slow enough, do it in software. Using USB as opposed to Bluetooth will increase what's considered "slow enough".
  2. Otherwise, if you're feeling adventurous you can try implementing this in firmware. Shouldn't be terribly hard if you've done some embedded programming before.
  3. Alternatively, have an external quadrature decoder chip or a small MCU that acts as such and communicate with it over serial, SPI or I2C.

--
You received this message because you are subscribed to the Google Groups "ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ioio-users+...@googlegroups.com.
To post to this group, send email to ioio-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages