Friday, January 22, 2016

HOW TO COMPILE OPENCV FOR RASPBERRY PI2 (Windows 10 IoT)

It is manual about OpenCV compilation for Raspberry Pi2  with Windows10 IoT


for thous who tried to follow this manual but for some reason still do not have compiled OpenCV.

For the building process you will need to:
  1. Install Windows 10 on your PC;
  2. Install Visual Studio Community 2015 with Update 1;
  3. Install Windows 10 IoT for RPI2. 
If you will have problems with installation RPI WIN10 IoT (HOW TO).When you install everything go to the next step.

Fast and simple building of the OpenCV Libraries for ARM in details.

You have to follow this steps for it:
  1. Download  MS Open Tech GitHub repo and extra.
  2. Copy this files to the root directory (I mean C:\)
  3.  Extract them
     
  4. Rename received folders:
    • opencv-vs2015-samples ->  opencv
    • opencv_extra-master -> opencv_extra
  5.  Create folder opencv_validation
  6. Result should be like this:
  7. Create three system variables (OCV2015_ROOT, OPENCV_TEST_DATA_PATH, OPENCV_PERF_VALIDATION_DIR) as described below:





     
  8.  Open OpenCV Visual Studio project:
  9.  Compile debug and release versions:

  10.  Lets it! Now you can start developing with OpenC:
  11.  For checking you can open this example:
  12.  Do not forget to set ip adress:
  13.  Just run the application and enjoy:

Thank you for attention!
Sincerely your,
Ing. Dmitry Kochubey.

Friday, January 15, 2016

RPI2 UART to PC communication via PL2303 adapter

AS5140 as incremental encoder

Wiring for incremental mode is shown below:


Arduino code:

/*
This sketch was developed buy Ing. Dmitry Kochubey
in Technical university of Liberec
Czech Republic
year 2013
*/

#define ENCODER_A_PIN 2
#define ENCODER_B_PIN 3

long pos = 0;

void setup()
{
   pinMode(ENCODER_A_PIN, INPUT);
   pinMode(ENCODER_B_PIN, INPUT);

   attachInterrupt(0, read_quadrature, CHANGE);
  
   Serial.begin(9600);
}

void loop()
{
   Serial.print("Position: ");
   Serial.println(pos, DEC);
   delay(1000);
}

void read_quadrature()

  // found a low-to-high on channel A
  if (digitalRead(ENCODER_A_PIN) == HIGH)
  {  
    // check channel B to see which way
    if (digitalRead(ENCODER_B_PIN) == LOW)
        pos++;
    else
        pos--;
  }
  // found a high-to-low on channel A
  else                                       
  {
    // check channel B to see which way
    if (digitalRead(ENCODER_B_PIN) == LOW)
        pos--;
    else
        pos++;
  }
}

Enjoy!

Encoder becomes alive (AS5140)

Today's morning started from AS5140 commissioning.
 You can see wiring connection on the pictures below:




 Here is simple arduino sketch:
/*
This scetch was developed buy Ing. Dmitry Kochubey
in Technical university of Liberec
Czech Republic
year 2013
*/


#define cs 2
#define clk 3
#define din 4
#define prog 5

unsigned short data = 0;
unsigned short stat = 0;
unsigned short pos = 0;
boolean OCF = false;
boolean COF = false;
boolean LIN = false;
boolean MagINCn = false;
boolean MagDECn = false;
boolean EvenParity = false;

void AS5140_Init(void)
{
  pinMode(cs, OUTPUT);
  pinMode(clk, OUTPUT);
  pinMode(prog, OUTPUT);
  pinMode(din, INPUT);
  digitalWrite(din, LOW);
 
  digitalWrite(cs, LOW);
  digitalWrite(clk, HIGH);
  digitalWrite(prog, LOW); //or you can connect prog to the ground
  delayMicroseconds(50);
}

unsigned short AS5140_Ssi(void)
{
    unsigned short i, data;
    digitalWrite(cs, LOW);
    digitalWrite(clk, LOW);
    data          = 0;

    for (i = 0; i < 16; i++)
    {
        digitalWrite(clk, HIGH);
        delayMicroseconds(1);
        digitalWrite(clk, LOW);

        data = data << 1;                // shift bits in target variable one to the left
        if ( digitalRead(din) )        // read port bit
        {
            data |=0x01;                 // set new bit in 16 bit variable
        }
        delayMicroseconds(1);
    }
        digitalWrite(cs, HIGH);

    return data;
}

void setup() {
  AS5140_Init();
  Serial.begin(9600);
}


void loop() {
 data = AS5140_Ssi();
 stat = (data & 0b0000000000111111);
 OCF = data & 32;
 COF = data & 16;
 LIN = data & 8;
 MagINCn = data & 4;
 MagDECn = data & 2;
 EvenParity = data & 1;
 Serial.print("Status=");
 Serial.println(stat,BIN);
 if ((stat>>1)==0b10000) //data validation check
 {
  pos = (data & 0b11111111111000000) >> 6;
  Serial.print("Position=");
  Serial.println(pos,DEC);
 }
 delay(100);
}

Enjoy!