Open Hardware creator

Spruce

Spruce Used to Control LinkSprite Robot Platform

Hits:  UpdateTime:2012-03-10 14:53:00  【Printing】  【Close

On LinkSprite Spruce,  STM32 MCU is used. STM32 has ARM Cortex-M3 core. It can be used on Keil development environment and Arduino IDE. 

 

LinkSprite Arduino Robotics Kit is an Arduino based Robotics kit.

 

 

The hardware included:

  • Robotics platform
  • Two-Channel DC Motor Driver Breakout (L298 Chipset)
  • Path sensor board
  • three infrared obstacle sensors
  •  
  • Arduino board is NOT included
  • Battery holder
  • Jumper wires

 

The platform comes with the metal base, two rubber tires, one ball caster metal, and two gearmotors.

 

Connection instructions:

 

 

Two-Channel DC Motor Driver Breakout  to Arduino Uno:

I1 -> pin 2 of spruce

I2 -> pin 1 of spruce

I3 -> pin 5 of spruce

I4 -> pin 6 of spruce

EA -> pin 11 of spruce

EB-> pin 12 of spruce

 

P3 on the motor driver board is connected to the four wires of two motors. VMS is connected to the Vin of Arduino, and GND is connected to the ground of Arduino.

 

 

 

Path Sensor Breakout Board connected to Arduino:

 

+5V is connected to 5V on Arduino.

GND is connected to ground on Arduino.

 

Pin 15 connected to Q1

Pin 16 connected to Q2

Pin 17 connected to Q3

Pin 18 connected to Q4

Pin 19 connected to Q5

 

Obstacle sensors connected to Arduino:

 

Front obstacle sensor connected to Pin 16.

Right obstacle sensor connected to Pin 17.

Left obstacle sensor connected to Pin 15.

 

 

Path following example:

 

After switch on,the car will run along the black line on floor , this car is equipped with five path sensors, when the middle sensor detectes black line, car will go forward; when the centreright sensor detectes black line, that indicate car will slightly turn to the right side, so the car should be turned slightly to the left; when the most right sensor detects black line, that indicate car turn too much to the right side, so the car should turn left by a wide margin. Concretely, use PWM control L298N end EA, EB can be enabled to control car's speed, by controlling delay () to control car's rotation angle. By analogy, the black line wich detected by left side sensor will be just opposite.

 

Arduino pde example:

 

 

unsigned char road=0;
void setup()
{
pinMode(1,OUTPUT);
pinMode(2,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(11,PWM);
pinMode(12,PWM);
pinMode(15, INPUT);
pinMode(16, INPUT);
pinMode(17, INPUT);
pinMode(18, INPUT);
pinMode(19, INPUT);
Serial1.begin(9600);
}
void loop()
{
Serial1.write("Arduino!\r\n");
////////////////////////////////////////////
road = digitalRead(15)+digitalRead(16)*2+digitalRead(17)*4+
digitalRead(18)*8+digitalRead(19)*16;
switch (road)
{
case 0b00011011:
forward();
delay(100);
break;
///////////////////////////////////////////
case 0b00011101:
turn_left();
pwmWrite(11,17000);
delay(50);
break;
case 0b00010111:
turn_right();
pwmWrite(12,17000);
delay(50);
break;
////////////////////////////////////////
case 0b00001111:
turn_right();
delay(50);
break;
case 0b00011110:
turn_left();
delay(50);
break;
///////////////////////////////////
default:
forward();
delay(10);
}
}
void turn_left(void)
{
digitalWrite(1,LOW);
digitalWrite(2,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,LOW);
pwmWrite(11,35000);
pwmWrite(12,35000);
}
void turn_right(void)
{
digitalWrite(1,HIGH);
digitalWrite(2,LOW);
digitalWrite(4,LOW);
digitalWrite(5,HIGH);
pwmWrite(11,35000);
pwmWrite(12,35000);
}
void forward(void)
{
digitalWrite(1,HIGH);
digitalWrite(2,LOW);
digitalWrite(4,HIGH);
digitalWrite(5,LOW);
pwmWrite(11,35000);
pwmWrite(12,35000);
}
void back(void)
{
digitalWrite(1,LOW);
digitalWrite(2,HIGH);
digitalWrite(4,LOW);
digitalWrite(5,HIGH);
pwmWrite(11,17000);
pwmWrite(12,17000);
}
 
 

Get out of Maze example:

 

 

Equipped with three infrared sensors at the front of the car to avoid obstacles, when an obstacle is detected, the corresponding sensor will output low level. When obstacle is detected at current side, the car will backward a little then turn left again by default; when right side of the obstacle is detected, the car will turn to left; when left obstacle is detected, the car will turn to right. Attention that each rotation rate shouldn't be too much, you can use the program for several minor adjustments, so that car can move ahead closely to the edge of obstacle, Concretely,use the PWM control L298N Enable EA, EB to control car's speed, by controlling delay ()to control car's rotation angle. You can adjust the potentiometer on the back of sensor to adjust the detection range, detection distance shouldn't too far, the appropriate distance is 20CM, thus the car can achieve Maze features, if encountered a dead end, car can come out closely to the wall.

 

 

Arduino pde:

 
 
unsigned char status=0;
void setup()
{
pinMode(1,OUTPUT);
pinMode(2,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
 
pinMode(15,INPUT);
pinMode(16,INPUT);
pinMode(17,INPUT);
pinMode(11, PWM);
pinMode(12, PWM);
}
void loop()
{
status = digitalRead(15)+digitalRead(16)*2+digitalRead(17)*4;
switch (status)
{
case 0b00000000:
case 0b00000101:
back();
delay(100);
turn_right();
pwmWrite(12,15000);
delay(100);
break;
///////////////////////////////////////////
case 0b00000001:
case 0b00000011:
case 0b00000010:
turn_right();
pwmWrite(12,15000);
delay(10);
break;
////////////////////////////////////////
case 0b00000100:
case 0b00000110:
turn_left();
pwmWrite(11,15000);
delay(10);
break;
///////////////////////////////////
/* case 0b00000111:
forward();
delay(30);
break;*/
///////////////////////////////////
default:
forward();
delay(20);
}
}
void turn_left(void)
{
digitalWrite(1,LOW);
digitalWrite(2,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,LOW);
pwmWrite(11,30000);
pwmWrite(12,30000);
}
void turn_right(void)
{
digitalWrite(1,HIGH);
digitalWrite(2,LOW);
digitalWrite(5,LOW);
digitalWrite(6,HIGH);
pwmWrite(11,30000);
pwmWrite(12,30000);
}
void forward(void)
{
digitalWrite(1,HIGH);
digitalWrite(2,LOW);
digitalWrite(5,HIGH);
digitalWrite(6,LOW);
pwmWrite(11,28000);
pwmWrite(12,30000);
}
void back(void)
{
digitalWrite(1,LOW);
digitalWrite(2,HIGH);
digitalWrite(5,LOW);
digitalWrite(6,HIGH);
pwmWrite(11,30000);
pwmWrite(12,30000);
}
 
 

 

 

Article

Contact

Live Help

LinkSprite Technologies, Inc.
Add:1067 S Hover St, Unit E-186,Longmont, CO 80501

Tel: 

720-204-8599 (MST: 9:00am-5:00pm)

 720-279-0774 (MST: 6:00pm- 3:00am)


Email:sales@linksprite.com

 

Technical questions:

Web

 

Online
About us|Enterprise News|Learning Cent|Download|Guestbook|Feedback|Article|Member|Contact|Search|Sitemap|Open Hardware|Admin
Powered by MetInfo 4.0 ©2008-2014 www.MetInfo.cn