12/30/2015 4WD Mobile Platform SKU:ROB0022 Robot Wiki https://www.dfrobot.com/wiki/index.php?title=4WD_Mobile_Platform_SKU:ROB0022 1/24 4WD Mobile Platform SKU:ROB0022 Contents [hide] 1 Function Introduction 1.1 STEP1: Assemble Robot 1.2 STEP2: Debug Motor 1.3 STEP3:Install Upper Plate 1.4 STEP4: Debug Ultrasonic Sensor and Servo 1.5 STEP5: Debugging Robot Function Introduction This Kit will teach you how to build a automatic obstacle avoidance robot which is achieved on the platform of the Turtle Robot,based on ultrasonic sensor as distance measuring device,and combined with servo. STEP1: Assemble Robot 1.Assemble Your Own Motor Look in your parts bag for eight long screws. These are used to fix and secure the motors in place. Place the motors in the correct alignment, then screw them into place as shown in the picture below. Please note that washers and gaskets are also included in the parts bag. Washers can be used to increase friction, which helps fasten the motors into place. The gaskets help prevent the screw nuts from loosening and falling off due to the Pirate’s movements and collisions.
24
Embed
4WD Mobile Platform SKU:ROB0022 - RobotShop · 2015-12-30 · STEP1: Assemble Robot 1.Assemble Your Own Motor Look in your parts bag for eight long screws. These are used to fix and
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
12/30/2015 4WD Mobile Platform SKU:ROB0022 Robot Wiki
This Kit will teach you how to build a automaticobstacle avoidance robot which is achieved on theplatform of the Turtle Robot,based on ultrasonicsensor as distance measuring device,and combinedwith servo.
STEP1: Assemble Robot1.Assemble Your Own Motor
Look in your parts bag for eight long screws. These areused to fix and secure the motors in place. Place themotors in the correct alignment, then screw them intoplace as shown in the picture below.
Please note that washers and gaskets are alsoincluded in the parts bag. Washers can be used toincrease friction, which helps fasten the motors intoplace. The gaskets help prevent the screw nuts fromloosening and falling off due to the Pirate’smovements and collisions.
Take the black and red wires out of the parts bag.Attach one black and one red cable (15 cm long) toeach motor (4 motors in total). Then use your wirestripper to strip the insulation at both ends of the wires(make sure not to strip too much—refer to the picturesbelow). Next, solder the wires onto the pins affixed tothe motors. Repeat the soldering process for all fourmotors.
Look in your parts bag for three copper supports.Those 1cmlong supports are used to fasten theRomeo controller board. As shown in the picturebelow, there are three holes in the controller board.Place the three copper supports into the holes, thenfasten them into place with the appropriate screws.
Batteries are the essential lifeblood of robots. Tocontrol power usage, we need to use a power switch:the switch turns off power when not in use, thuspreserving electricity and battery life. Refer to thepicture below before assembling and installing thepower switch.
Please pay attention to the sequence of the gasketsand screw nuts when assembling the switch.
After assembling the switch, we want to start solderingits wires. Take some of the remaining wire leftoverfrom before. Strip the wiring off both ends of thecables so that the inside of the wire is exposed (sameprocess as with the motors before). We want to solderthe exposed end of the wires to the pins on the switch.When soldering, it’s very important that we note theposition of the switch’s pins.
Let’s do this step by step. a)Connect the switch to thebattery charger. Pay attention to the exact location ofboth items.
c)Finally, take one red cable and one black cable.Attach one end of one cable to the negative pole ofthe battery charger and one end of the other cable tothe positive pole of the battery charger. Then attachthe other ends of both cables to the Romeo BLEcontroller.
Looking at this enlarged picture should give you abetter idea of how the wires should be connected.After soldering, make sure to check and see if yourwiring between the battery and Romeo controller isconsistent from start to finish and matches with theabove pictures.
6.Assemble the Car Base
Using eight M3x6mm screws, attach the side plates tothe front and back bumper plates as shown by thediagram below.
Note: When tightening the screws during this step,make sure not to fully tighten the screws at first —this way, we can easily detach the top board in latersteps should we need to make adjustments.
Then, reattach the base plate to the body of the caras shown in the picture below.
This is what the car base should like after it’sbeen assembled — remember to install the batterypack!
7.Connect the Motors with the MicrocontrollerBoard
Now we need to the motors with the microcontrollerboard. Carefully follow the following diagram: the leftmotor’s red and black wires should be soldered intoM2; the right motor’s red and black wires should besoldered to M1. Pay special attention to the batterypack: the black wire should be soldered into the wireport reading GND, while the red wire should besoldered in the wire port labeled VND. Use yourscrewdriver to loosen and tighten the wire ports —make sure these ports are fastened well once the wireshave been inserted.
Note: Make sure the wires from one motor (i.e. theleft motor) are soldered into the motor port. (i.e. theM2 port on the diagram below — do not solder onemotor’s wires into two separate ports.)
After soldering the motor wires to the microcontrollerboard, we’re ready to attach the top plate to the baseof the car. Before we attach the top plate, you havethe option of attaching a sensor plate (see diagrambelow) — if you don’t plan to use sensors just yet, youcan skip this extra step.
After attaching the top plate, your Pirate shouldresemble the picture below.
8.Attach an extra level to the Pirate
Find the four holes on the base’s top plate. Screw inthe four M3x60mm Copper Standoffs, then attach theadditional top plate as shown in the diagram below —use M3x6mm screws to affix the plate to the copperstandoffs.
int speedPin_M1 = 5; //M1 Speed Control int speedPin_M2 = 6; //M2 Speed Control int directionPin_M1 = 4; //M1 Direction Control int directionPin_M2 = 7; //M1 Direction Control
void SensorSetup() pinMode(URTRIG,OUTPUT); // A low pull on pin COMP/TRIG digitalWrite(URTRIG,HIGH); // Set to HIGH pinMode(URPWM, INPUT); // Sending Enable PWM mode command for(int i=0;i<4;i++) Serial.write(EnPwmCmd[i]);
int MeasureDistance() // a low pull on pin COMP/TRIG triggering a sensor reading digitalWrite(URTRIG, LOW); digitalWrite(URTRIG, HIGH); // reading Pin PWM will output pulses unsigned long distance=pulseIn(URPWM,LOW); if(distance==50000) // the reading is invalid. Serial.print("Invalid"); else distance=distance/50; // every 50us low level stands for 1cm return distance;
void servoSweep() if(sweepFlag ) if(pos>=60 && pos<=120) pos=pos+1; // in steps of 1 degree myservo.write(pos); // tell servo to go to position in variable 'pos' if(pos>119) sweepFlag = false; // assign the variable again else if(pos>=60 && pos<=120) pos=pos‐1; myservo.write(pos); if(pos<61) sweepFlag = true;
12/30/2015 4WD Mobile Platform SKU:ROB0022 Robot Wiki
Method 1: Reinstall wheelMethod 2: Adapt your code accordingly
STEP5: Debugging Robot1. Fix the expansion board
Uplpad the code
#include <Servo.h> #include <Metro.h> Metro measureDistance = Metro(50); Metro sweepServo = Metro(20);
int speedPin_M1 = 5; //M1 Speed Control int speedPin_M2 = 6; //M2 Speed Control int directionPin_M1 = 4; //M1 Direction Control int directionPin_M2 = 7; //M1 Direction Control unsigned long actualDistance = 0;
Servo myservo; // create servo object to control a servo int pos = 60; int sweepFlag = 1;
int MeasureDistance() // a low pull on pin COMP/TRIG triggering a sensor reading digitalWrite(URTRIG, LOW); digitalWrite(URTRIG, HIGH); // reading Pin PWM will output pulses unsigned long distance=pulseIn(URPWM,LOW);
12/30/2015 4WD Mobile Platform SKU:ROB0022 Robot Wiki
if(distance==50000) // the reading is invalid. Serial.print("Invalid"); else distance=distance/50; // every 50us low level stands for 1cm return distance;
void carStop() // Motor Stop digitalWrite(speedPin_M2,0); digitalWrite(directionPin_M1,LOW); digitalWrite(speedPin_M1,0); digitalWrite(directionPin_M2,LOW);
void carTurnLeft(int leftSpeed,int rightSpeed) //Turn Left analogWrite (speedPin_M2,leftSpeed); //PWM Speed Control digitalWrite(directionPin_M1,HIGH); analogWrite (speedPin_M1,rightSpeed); digitalWrite(directionPin_M2,HIGH);
void servoSweep() if(sweepFlag) if(pos>=60 && pos<=120) pos=pos+1; // in steps of 1 degree myservo.write(pos); // tell servo to go to position in variable 'pos' if(pos>119) sweepFlag = false; // assign the variable again else if(pos>=60 && pos<=120) pos=pos‐1; myservo.write(pos); if(pos<61) sweepFlag = true;
12/30/2015 4WD Mobile Platform SKU:ROB0022 Robot Wiki