PDA

View Full Version : [Question(s)] Arduino Mega talking to Pincher



kelly.edlyn
11-10-2015, 02:06 PM
Hi Everyone,

So I am trying to have an arduino mega send a serial packet to an arbotix-m that has the ArmLinkSerial sketch uploaded to it.

I am trying to make this as simple as possible for now so I am just wanting to send a premade packet from the examples on the website.

This is what I have so far:


void setup(){
Serial.begin(9600);
Serial1.begin(38400);
}

void loop() {

if (Serial1.available()){
Serial.print("Writing to Robot");


Serial1.write(0xff);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x30);
Serial1.write(0xcf);

delay(10000);
}

}



The Mega is then attached to the arbotix like this:

http://imgur.com/a/Y38DS

I am really new to the arduino and robotics in general, any help would be really really appreciated.

Thanks!
-Kelly

kelly.edlyn
11-10-2015, 03:26 PM
So I tried to simplify it further and my code now looks like this:




void setup(){
Serial.begin(38400);
Serial1.begin(38400);
delay(10000);
Serial.println("Send Data.");
}

void loop() {

Serial.println("Sending Packet...");

Serial1.write(0xff);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x30);
Serial1.write(0xcf);
delay(10000);

}



It says it is sending the packets and the TX light is flashing but there is no response from the robot. I am really at a loss as to how to send these packets...

Any help would be a life saver

kgranat
11-19-2015, 03:02 PM
Hi Kelly,
Sorry for not responding to this sooner.

You're code looks fine (I got it to work on a mega / pincher here)

Before we delve too deep in, I just want to make sure that
1)If you were to number the pins on the ArbotiX FTDI Pinout from 1-6 with green being 1 and black being 6, the ArbotiX's TX pin is 2(yellow) and RX pin is 3(orange). Pin 2 on the arbotix should be connected to the RX1 pin on the mega, and pin 3 to the TX1. So basically make sure that RX on one goes to TX on the other board. If that doesn't work,
2)Were you able to run the test code for the pincher?
3)Were you able to run the arm link software to control the pincher?


The following code should have the arm move between home position and on offset position every second or so.


void setup(){ Serial.begin(38400);
Serial1.begin(38400);
delay(1000);
Serial.println("Send Data.");
}


void loop() {

Serial.println("Sending Packet...");

Serial1.write(0xff);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x0);
Serial1.write(0x30);
Serial1.write(0xcf);
delay(1000);

Serial1.write(0xff);
Serial1.write(0x02);
Serial1.write(0x00);
Serial1.write(0x00);
Serial1.write(0x96);
Serial1.write(0x00);
Serial1.write(0x96);
Serial1.write(0x00);
Serial1.write(0x5A);
Serial1.write(0x02);
Serial1.write(0x0);
Serial1.write(0x00);
Serial1.write(0x00);
Serial1.write(0x80);
Serial1.write(0x00);
Serial1.write(0x00);
Serial1.write(0xf5);

delay(1000);

}

kelly.edlyn
11-20-2015, 01:06 AM
Hi, thank you for the help! I am so excited that I was on the right path but I actually ended up just running all of the code directly on the Arbotix-m. Believe it or not I just got it working earlier today. It uses a pixy to find object location to basically act as a pick and place robot. Video is attached. This was my first time programming an arduino so pretty happy with the turn out :)
https://youtu.be/3IpbwvIWMRI