PicoborgRev C/C++ Library

I want to control my stepper motor via the output of a IMU sensor with the IMU sensor interpretter program written in C++ (quite lengthy and complicated, not written by me). Is there C++ code to run the picoborgrev?

piborg's picture

There is not a C or C++ library available for PicoBorg Reverse, but it should be fairly simple for someone to write one.

If you are familiar with C or C++ then you could probably code either the whole library or just the functions you need yourself.

What you want to do is use open to get a file handle to either /dev/i2c-1 or /dev/i2c-0 (depends on which Raspberry Pi you own).

Once you have the file handle use itoctl to set the I2C address you are talking to like this:
ioctl(hI2C, I2C_SLAVE, targetAddress);
where hI2C is the file handle and targetAddress is the I2C address of the board (0x44 by default for PicoBorg Reverse).

You can then use the file handle to talk with the board using write to send I2C data and read to receive I2C data from the board.

We have an example bit of C code for doing this with XLoBorg that shows how the I2C code works in practice:
XLoBorg C library

As for the actual I2C messages themselves I would suggest looking at the Arduino code example:
PicoBorg Reverse Arduino library
This should show you the actual bytes sent over the I2C, it also has all of the constant values required.

ok, thanks for that, David E Grayson's seems to have nailed a nice I2C library on github so I'll use that and hack the arduino picoborgrev code to suit. I only need to use the stepper motor control and I'm still learning C++ so if I get it working soon it won't be super beautiful. thanx man.

Subscribe to Comments for "PicoborgRev C/C++ Library"