Legacy Forum: Preserving Nearly 20 Years of Community History - A Time Capsule of Discussions, Memories, and Shared Experiences.

BIFFERBOARD + VSTONE NANO

Custom built or hacked Electronic boards and sensors
37 postsPage 3 of 31, 2, 3
37 postsPage 3 of 31, 2, 3

Post by Zacohk » Sat Mar 26, 2011 4:03 pm

Post by Zacohk
Sat Mar 26, 2011 4:03 pm

Thanks for these advices Billy and Pedro. I am studying these options and will post my progress.
For the moment I don’t see how to compile the Darwin YUV LUT generator (
camlutgen) or the Opencv library on the Bifferboard, any tips would be welcome.
Thanks for these advices Billy and Pedro. I am studying these options and will post my progress.
For the moment I don’t see how to compile the Darwin YUV LUT generator (
camlutgen) or the Opencv library on the Bifferboard, any tips would be welcome.
Zacohk
Savvy Roboteer
Savvy Roboteer
Posts: 38
Joined: Wed Jul 02, 2008 9:54 am

Post by billyzelsnack » Sat Mar 26, 2011 6:55 pm

Post by billyzelsnack
Sat Mar 26, 2011 6:55 pm

camlutgen is my implementation of a generator of the type of LUT the Darwin team is using for their vision. I don't think the Darwin source contains their LUT generator, though maybe I missed it.

camlutgen is a Qt app. Qt is cross-platform, but Qt does not have cross-platform support for webcams. The code only has an implementation for webcams under Linux.

Also. camlutgen is only a tool to generate a LUT. You would not run it on the bifferboard. You would use it to generate a LUT that would be used by some other code on the bifferboard.
camlutgen is my implementation of a generator of the type of LUT the Darwin team is using for their vision. I don't think the Darwin source contains their LUT generator, though maybe I missed it.

camlutgen is a Qt app. Qt is cross-platform, but Qt does not have cross-platform support for webcams. The code only has an implementation for webcams under Linux.

Also. camlutgen is only a tool to generate a LUT. You would not run it on the bifferboard. You would use it to generate a LUT that would be used by some other code on the bifferboard.
billyzelsnack
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 618
Joined: Sat Dec 30, 2006 1:00 am

Post by Bullit » Mon Mar 28, 2011 4:27 am

Post by Bullit
Mon Mar 28, 2011 4:27 am

The newer Robotis Darwin-OP source includes a mjpeg_streamer interface for look up table (lut) generation to an ini file. The follower class can load specific color entries from the ini file.

here's another link to the Darwin-OP source for reference:
http://darwinop.svn.sourceforge.net/viewvc/darwinop/trunk/darwin/
The newer Robotis Darwin-OP source includes a mjpeg_streamer interface for look up table (lut) generation to an ini file. The follower class can load specific color entries from the ini file.

here's another link to the Darwin-OP source for reference:
http://darwinop.svn.sourceforge.net/viewvc/darwinop/trunk/darwin/
Bullit
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 291
Joined: Wed May 31, 2006 1:00 am
Location: Near robot

Reading I2c Sensors - preparation

Post by Zacohk » Thu Jul 28, 2011 3:32 pm

Post by Zacohk
Thu Jul 28, 2011 3:32 pm

I took some time rewriting my server and other functions from Python to C. I found that Python was not fast enough on this board and I had some difficulties with some protocols.

I wanted to collect a maximum of environment data and display them to the web control page. ( a next step will be to use these data in a autonomous navigation program).

Image

I gathered a batch of small I2c sensors and connected them in serial to the Bifferboard IO (pin 9 &12).

Following posts give details and code samples showing how to configure and read the I2c sensors with a Bifferboard running a Debian Squeeze distro with relevant patches (there is a link on my blog to download it).


Bifferboard preparation:

Compile and install the i2c tools.

Then, add the following command in a startup script:

modprobe rdc321x_gpio
modprobe i2c-algo-bit
modprobe i2c-gpio
modprobe i2c-gpio-custom bus0=0,12,9 // I2c Pin
modprobe i2c-dev

In this configuration Pin 12 = SDA, Pin 9 = SCL

Image

All the following codes are compiled on the Bifferboard with GCC
I took some time rewriting my server and other functions from Python to C. I found that Python was not fast enough on this board and I had some difficulties with some protocols.

I wanted to collect a maximum of environment data and display them to the web control page. ( a next step will be to use these data in a autonomous navigation program).

Image

I gathered a batch of small I2c sensors and connected them in serial to the Bifferboard IO (pin 9 &12).

Following posts give details and code samples showing how to configure and read the I2c sensors with a Bifferboard running a Debian Squeeze distro with relevant patches (there is a link on my blog to download it).


Bifferboard preparation:

Compile and install the i2c tools.

Then, add the following command in a startup script:

modprobe rdc321x_gpio
modprobe i2c-algo-bit
modprobe i2c-gpio
modprobe i2c-gpio-custom bus0=0,12,9 // I2c Pin
modprobe i2c-dev

In this configuration Pin 12 = SDA, Pin 9 = SCL

Image

All the following codes are compiled on the Bifferboard with GCC
Zacohk
Savvy Roboteer
Savvy Roboteer
Posts: 38
Joined: Wed Jul 02, 2008 9:54 am

Distance Sensor SRF10

Post by Zacohk » Thu Jul 28, 2011 3:35 pm

Post by Zacohk
Thu Jul 28, 2011 3:35 pm

It is the smallest i2c distance sensor I found. I connected 5v, Gnd, SDA, SCL
Device id = 0x70
Below code spit out the distance in CM.

Image



Code: Select all

#include <stdio>
#include <fcntl>
#include <stdlib>
#include "/usr/include/linux/i2c-dev.h"

int main(void)
{
   int fd;
   char filename[20];
   char buf[10];
   int res;
   int range=0;

   sprintf(filename, "/dev/i2c-0");
   fd = open(filename, O_RDWR);
   if (fd < 0) {
      printf("Error on open\n");
      exit(1);
   }

   if (ioctl(fd, I2C_SLAVE, 0x70) < 0) {
      printf("Error on slave address\n");
      exit(1);
   }


   buf[0] = 0x00;
   buf[1] = 0x51;
   if ((write(fd,buf,2))!=2) {
      printf("Error send the read command\n");
      exit(1);
   }

   // Wait for the measurement
   usleep(66000);

   buf[0] = 0x02;
   if ((write(fd,buf,1))!=1) {
      printf("Error on select the Range High Byte\n");
      exit(1);
   }

   if ((read(fd,buf,1))!=1) {
      printf("Error on read the Range High Byte\n");
      exit(1);
   }
   range = buf[0]<<8;

   buf[0] = 0x03;
   if ((write(fd,buf,1))!=1) {
      printf("Error on select the Range Low Byte\n");
      exit(1);
   }

   if ((read(fd,buf,1))!=1) {
      printf("Error on read the Range Low Byte\n");
      exit(1);
   }
   range |= buf[0];

   printf("Range=%d cm\n",range);   
   close(fd);

   return 0;   
}

It is the smallest i2c distance sensor I found. I connected 5v, Gnd, SDA, SCL
Device id = 0x70
Below code spit out the distance in CM.

Image



Code: Select all

#include <stdio>
#include <fcntl>
#include <stdlib>
#include "/usr/include/linux/i2c-dev.h"

int main(void)
{
   int fd;
   char filename[20];
   char buf[10];
   int res;
   int range=0;

   sprintf(filename, "/dev/i2c-0");
   fd = open(filename, O_RDWR);
   if (fd < 0) {
      printf("Error on open\n");
      exit(1);
   }

   if (ioctl(fd, I2C_SLAVE, 0x70) < 0) {
      printf("Error on slave address\n");
      exit(1);
   }


   buf[0] = 0x00;
   buf[1] = 0x51;
   if ((write(fd,buf,2))!=2) {
      printf("Error send the read command\n");
      exit(1);
   }

   // Wait for the measurement
   usleep(66000);

   buf[0] = 0x02;
   if ((write(fd,buf,1))!=1) {
      printf("Error on select the Range High Byte\n");
      exit(1);
   }

   if ((read(fd,buf,1))!=1) {
      printf("Error on read the Range High Byte\n");
      exit(1);
   }
   range = buf[0]<<8;

   buf[0] = 0x03;
   if ((write(fd,buf,1))!=1) {
      printf("Error on select the Range Low Byte\n");
      exit(1);
   }

   if ((read(fd,buf,1))!=1) {
      printf("Error on read the Range Low Byte\n");
      exit(1);
   }
   range |= buf[0];

   printf("Range=%d cm\n",range);   
   close(fd);

   return 0;   
}

Zacohk
Savvy Roboteer
Savvy Roboteer
Posts: 38
Joined: Wed Jul 02, 2008 9:54 am

Triple axis accelerometer BMA 180

Post by Zacohk » Thu Jul 28, 2011 3:38 pm

Post by Zacohk
Thu Jul 28, 2011 3:38 pm

Below code simply show x,y,z status.
Just connect 3.3v, GND, SDA, SCL
Device id = 0x40
Image


Code: Select all

#include <stdio>
#include <fcntl>
#include <stdlib>
#include "/usr/include/linux/i2c-dev.h"
#define BMA180_ID       0x00
#define BMA180_ADDR     0x40 //device id
#define BMA180_X_ACC    0x02
#define BMA180_Y_ACC    0x04
#define BMA180_Z_ACC    0x06

int main(void)
{
   int fd;
   char filename[20];
       
        char data[2];
        int16_t x,y,z;

   sprintf(filename, "/dev/i2c-0");
   fd = open(filename, O_RDWR);
   if (fd < 0) {
      printf("Error on open\n");
      exit(1);
   }

   if (ioctl(fd, I2C_SLAVE, 0x40) <0>>= 2;
        x  = *((int16_t*)data);
       
        data[0] = BMA180_Y_ACC;
        write(fd, data, 1);
        read(fd, data, 2);
   data[0] >>= 2;
        y  = *((int16_t*)data);
       
        data[0] = BMA180_Z_ACC;
        write(fd, data, 1);
        read(fd, data, 2);
   data[0] >>= 2;
        z  = *((int16_t*)data);

   
       printf ("X: %d Y: %d Z: %d\n", x/136, y/136, z/136);
       printf("x: %.1f y: %.1f z: %.1f\n", x/16384.0f, y/16384.0f, z/16384.0f); //2^14

       
}
   close(fd);
   return 0;   
}
Below code simply show x,y,z status.
Just connect 3.3v, GND, SDA, SCL
Device id = 0x40
Image


Code: Select all

#include <stdio>
#include <fcntl>
#include <stdlib>
#include "/usr/include/linux/i2c-dev.h"
#define BMA180_ID       0x00
#define BMA180_ADDR     0x40 //device id
#define BMA180_X_ACC    0x02
#define BMA180_Y_ACC    0x04
#define BMA180_Z_ACC    0x06

int main(void)
{
   int fd;
   char filename[20];
       
        char data[2];
        int16_t x,y,z;

   sprintf(filename, "/dev/i2c-0");
   fd = open(filename, O_RDWR);
   if (fd < 0) {
      printf("Error on open\n");
      exit(1);
   }

   if (ioctl(fd, I2C_SLAVE, 0x40) <0>>= 2;
        x  = *((int16_t*)data);
       
        data[0] = BMA180_Y_ACC;
        write(fd, data, 1);
        read(fd, data, 2);
   data[0] >>= 2;
        y  = *((int16_t*)data);
       
        data[0] = BMA180_Z_ACC;
        write(fd, data, 1);
        read(fd, data, 2);
   data[0] >>= 2;
        z  = *((int16_t*)data);

   
       printf ("X: %d Y: %d Z: %d\n", x/136, y/136, z/136);
       printf("x: %.1f y: %.1f z: %.1f\n", x/16384.0f, y/16384.0f, z/16384.0f); //2^14

       
}
   close(fd);
   return 0;   
}
Zacohk
Savvy Roboteer
Savvy Roboteer
Posts: 38
Joined: Wed Jul 02, 2008 9:54 am

I2C – ADC module

Post by Zacohk » Thu Jul 28, 2011 3:40 pm

Post by Zacohk
Thu Jul 28, 2011 3:40 pm

The Bifferboard has a limited qty of IO. I needed some analog inputs for battery measurement and to connect some cheap analog sensors.
The I2C-ADC is a tiny 8-CH Analog-to-Digital Converter, wonderful, from one I2c module I can read 8 analog inputs.
I connected this module to 3.3v, GND, SDA, SCL
Below code sample will display the value from CHO (pin 1).
Device id = 0x48

Image

Code: Select all

#include <stdio>
#include <fcntl>
#include <stdlib>
#include "/usr/include/linux/i2c-dev.h"

int main(void)
{

while (1){
   int fd;
   char filename[20];
   char buf[10];
   int value0=0;

   sprintf(filename, "/dev/i2c-0");
   fd = open(filename, O_RDWR);
   if (fd < 0) {
      printf("Error on open\n");
      exit(1);
   }

   if (ioctl(fd, I2C_SLAVE, 0x48) < 0) {
      printf("Error on slave address\n");
      exit(1);
   }


   buf[0] = 0x8C;
        write(fd,buf,1);

   // Wait for the measurement
   usleep(300000);

   read(fd,buf,2);
   
   value0 = buf[0]<<8;

   value0 |= buf[0];
   

   printf("Value =%d\n",value0);   
   close(fd);
}
   return 0;   
}
The Bifferboard has a limited qty of IO. I needed some analog inputs for battery measurement and to connect some cheap analog sensors.
The I2C-ADC is a tiny 8-CH Analog-to-Digital Converter, wonderful, from one I2c module I can read 8 analog inputs.
I connected this module to 3.3v, GND, SDA, SCL
Below code sample will display the value from CHO (pin 1).
Device id = 0x48

Image

Code: Select all

#include <stdio>
#include <fcntl>
#include <stdlib>
#include "/usr/include/linux/i2c-dev.h"

int main(void)
{

while (1){
   int fd;
   char filename[20];
   char buf[10];
   int value0=0;

   sprintf(filename, "/dev/i2c-0");
   fd = open(filename, O_RDWR);
   if (fd < 0) {
      printf("Error on open\n");
      exit(1);
   }

   if (ioctl(fd, I2C_SLAVE, 0x48) < 0) {
      printf("Error on slave address\n");
      exit(1);
   }


   buf[0] = 0x8C;
        write(fd,buf,1);

   // Wait for the measurement
   usleep(300000);

   read(fd,buf,2);
   
   value0 = buf[0]<<8;

   value0 |= buf[0];
   

   printf("Value =%d\n",value0);   
   close(fd);
}
   return 0;   
}
Zacohk
Savvy Roboteer
Savvy Roboteer
Posts: 38
Joined: Wed Jul 02, 2008 9:54 am

Previous
37 postsPage 3 of 31, 2, 3
37 postsPage 3 of 31, 2, 3