I finally got the I2C communication working with my controller box and it works!
It is really fun to mess with and I can't wait to use it a bit more, but I still have to work out some bugs. Here is a clip of it controlled from the RA and my phone. I made a little box with the Arduino, the BigEasy Driver and a little board to receive the I2C signal input, and some LEDs to tell me if it is working even if the motor isn't.
https://www.youtube.com/watch?v=KJ7EDLtV59Q
1. If someone is a robotics guru, I think the driver heats up a bit in the box and therefore is a bit choppy when it moves a long distance. Maybe a fan or a bigger driver is needed? It runs smoothly when it's first started and acts up a bit when warm. I tried to use the enable setting to keep it off while not moving, but it stays hot.
2. The power isolator doesn't seem to work when I test it and the RA blinks the red led when it is inline between the add-on and the RA. I have it with the IN from the RA to the OUT add-on. Maybe that's backwards? I set it up that way as the power comes into the add-on Arduino from the I2C lines. It works fine, just makes me a bit nervous that the 12V 2A power to the motor could cause a problem.
3. I haven't figured out an elegant solution for the camera wire. It just looks ugly hanging below the track.
Any suggestions are welcome.

Here's the Arduino code if anyone is interested (the // out code is debugging with the Serial feed)
Code: Select all
// stepper motor receive code from the RA
// designed to input a position from the serial integer input then go to it on the dolly
#include <Wire.h>
int stp = 13; //connect pin 13 to step
int dir = 12; // connect pin 12 to dir
int enb = 11; //enable pin for motor sheild
int ledred = 10; //led poweron
int ledgreen = 9; //led moving forward
int ledyellow = 8; //led moving backward
int pos = 0; // gen counter
int newpos = 0; // last request for a position
long dis = 0; // calculated distance
long dist =0;
String readString;
int endx = 9500; //end of the line
char rx_byte = 0;
String rx_str = "";
boolean not_number = false;
void setup()
{
Wire.begin(11); // I2C address 1q
Wire.onReceive(receiveEvent);
Serial.begin(9600);
pinMode(stp, OUTPUT);
pinMode(dir, OUTPUT);
pinMode(enb, OUTPUT);
pinMode(ledred, OUTPUT);
pinMode(ledgreen, OUTPUT);
pinMode(ledyellow, OUTPUT);
digitalWrite(ledred, HIGH);
digitalWrite(ledyellow, LOW);
digitalWrite(ledgreen, LOW);
}
void loop()
{
// Readint();
MoveCam();
}
void MoveCam()
{
digitalWrite(enb,HIGH);
if (newpos != pos)
{
digitalWrite(enb,LOW);
if (newpos > pos)
{
dis = newpos-pos;
if (newpos>endx)
{
digitalWrite(ledgreen, HIGH);
digitalWrite(ledyellow, HIGH);
newpos = 9500;
}
else
{
// Serial.print("Distance forward: ");
// Serial.println(dis);
// Serial.print ("current position ");
// Serial.println (pos);
// Serial.print ("new position ");
// Serial.println (newpos);
digitalWrite (dir, HIGH);
dist = dis*10;
for (int i=0; i < dist; i++)
{
digitalWrite(ledgreen, HIGH);
digitalWrite(stp, HIGH);
delayMicroseconds(100);
digitalWrite(stp, LOW);
delayMicroseconds(100);
}
digitalWrite(ledgreen, LOW);
// Serial.print("Current Position from: ");
// Serial.print(pos);
pos=newpos; //set the current position for comparison next time
// Serial.print(" to ");
// Serial.println(pos);
digitalWrite(enb, HIGH);
}
}
else if (newpos < pos)
{
dis = pos-newpos;
// Serial.print("Distance backward: ");
// Serial.println(dis);
dist = dis*10;
digitalWrite (dir, LOW);
for (int i=0; i < dist; i++)
{
digitalWrite(ledyellow, HIGH);
digitalWrite(stp, HIGH);
delayMicroseconds(100);
digitalWrite(stp, LOW);
delayMicroseconds(100);
}
digitalWrite(ledyellow, LOW);
// Serial.print("Current Position from: ");
// Serial.print(pos);
pos =newpos; //set the current position for comparison next time
// Serial.print(" to ");
// Serial.println(pos);
digitalWrite(enb, HIGH);
}
}
}
void Readint()
{
if (Serial.available() > 0) { // is a character available?
rx_byte = Serial.read(); // get the character
if (rx_byte == 'p') {
Serial.print ("current position ");
Serial.println (pos);
Serial.print ("new position ");
Serial.println (newpos);
Serial.print ("distance ");
Serial.println (dis);
not_number = true; // flag a non-number
}
else if (rx_byte == '\n') {
rx_str = ""; // clear the string for reuse
}
}
}
void receiveEvent(int howMany)
{
if (howMany==5) // Our custom protocol is 13 bytes
{
byte cmd1,cmd2,cmd3,cmd4,cmd5;
cmd1=Wire.read();
cmd2=Wire.read();
cmd3=Wire.read();
cmd4=Wire.read();
cmd5=Wire.read();
if (cmd1=='%' && cmd2=='%' && cmd3=='%') // the first 3 bytes of the custom protocol are $$$ to ensure it's coming from RA
{
newpos=(cmd4<<8)+cmd5;
}
}
else
for (int a=0;a<howMany;a++)
Wire.read(); // if the number of bytes is not 32, discard everything
}
-Jon