2013년 1월 18일 금요일

RQ-HUNO with ARDUINO - Day #1



RQ-HUNO is mainly consist of 16 pcs of  SAM-3 robot module.

SAM is stand for "Smart Actuator Module",  and  3 means 3kg.cm torque power.


Let's see how to control SAM-3 with Arduino Board today!


Prepare below.

- ARDUINO UNO R3 Board   1 pcs

  









- USB Cable                             1 pcs










- SAM-3                                   1 pcs














- 4 pin Cable                             1 pcs







and your PC + Arduino software environment.


For the detailed Arduino software configuration, visit to http://www.arduino.cc/.



For the example source of the SAM-3 control,



















Full source is as below.

/*
Blink & SAM Control
Turns on an LED and changes a SAM position on for one second, then off for one second, repeatedly.

This example code is in the public domain.
*/

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
// for SAM control
int id; // SAM id
int torq; // torque level(0:max, 4:min)
int checksum; // protocol checksum
int tmp1, tmp2; // temporary byte
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
// start serial port at 115200 bps:
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
id = 0;
torq = 2;
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
tmp1 = (torq << 5) | id;
tmp2 = 20; // position1
checksum = (tmp1 ^ tmp2) & 0x7f;
Serial.write(0xff);
Serial.write(tmp1);
Serial.write(tmp2);
Serial.write(checksum);
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
tmp1 = (torq << 5) | id;
tmp2 = 120; // position2
checksum = (tmp1 ^ tmp2) & 0x7f;
Serial.write(0xff);
Serial.write(tmp1);
Serial.write(tmp2);
Serial.write(checksum);
delay(1000); // wait for a second
}



Then, you need to connect "hardware part" properly.

Hardware Connection
















For the detailed hardware part connection,

Make the cable as shown in the right.



SAM-3 pin layout is as below.
 
For the Rx/Tx connection,
 
    -  connect Rx of SAM-3  with Tx of Arduino board.
    -  connect Tx of SAM-3  with Rx of Arduino board.






















After proper connection of all hardware part, then connect USB to PC.

And Compile the source and Upload to Arduino board.


Then, you will see SAM-3 moves from 20 degree to 120 degree continuously





댓글 없음:

댓글 쓰기