Cube Robot

From Microduino Wiki
Jump to: navigation, search

Outline

  • Project: Open source motor driving Cube Robot car.
  • Objective: Using Microduino-Joypad to control the Cube Robot car.
  • Difficulty: High
  • Time-consuming: 3-hour
  • Maker: Microduino Studio-YLB

Bill of Materials

  • Microduino Equipment
Module Number Function
Microduino-Core 1 Core board (Joypad)
Microduino-Core+ 1 Core board (Robot)
Microduino-USBTTL 1 Program download
Microduino-nRF24 2 Wireless communication
Microduino-Joypad 1 Remote controller
Microduino-TFT 1 Screen display
Microduino-Motor 1 Motor driver
Microduino-Robot 1 Driver connection board
  • Other Equipment
Module Module Function
Frame for the Cube Robot car 1 Body structure
Screw 18 Fixation
Nut 8 Fixation
Micro-USB cable 1 Program download
Wheel 1 Body structure
Motor 1 Wheel driving
Battery 1 Power supply
Boxz物料.jpg

Principle

There are many robot cars such as tracking, obstacle and Bluetooth remote controlling car or computer mouse, which shares the same control mode, namely, moving in four directions. Off course, they are different in structure and function. Here we're talking about two-wheel-driving mode. By controlling the rotation direction of two wheels, it can realize moving forward or backward, spinning and other functions, which combines with a universal wheel to keep balance. This Cube Robot car has a simple structure, including wheels, body frame and control system. 1)The wheels adopt two reducer motors with large torque and PWN speed adjustment, making them easy to control. 2)The body structure adopts wooden board with a size of 8cm*8cm*8cm. 3)The whose control system contains four parts:

  • Power supply system

Since the Cube Robot car is small, here we adopt the lithium battery.

  • CPU

The CPU of the car adopts Microduino-Core.

  • Wireless communication

The car adopts Microduino-nRF24 wireless communication, which owns quick response and about 100m control range in the open area.

  • Motor control

It adopts Microduino-Robot DC motor driving motor--a module that can drive two motor and can connect the CPU and the DC motor modules together.

Document

Debugging

Please stack the Microduino-Core and Microduino-USBTTL together, and upload the program from the Microduino-USBTTL to Microduino-Core with a USB cable. Note: Please upload the program before stacking all modules together.

Open the Arduino IDE.(If you don't have the IDE, you can refer to the appendix to install it by click【Files】→【Open】.)

Cubeopfgen.png

Browse to the program address, click " Robot_Microduino.ino " and open.

Cubeopefgdfn2.png

Click "√" on the top and compile, click Tools, select the Micrdouino-Core (Atmega328P@16M,5V) and the COMX as the port, click "→" and download the program to the developing board.

Cubeselect.png

Cube Robot Installation

  • Step1:Use the bracket and the screws to fixate the motor and the wheels on A1.
Cubestep1.jpg
  • Step2:Insert A2 into the slot of A1, and B1 into the top of A1, A3 into the bottom of A1, and then use A4 to fixate.
Cubestep2.jpg
  • Step3:Connect B2 and C1 to the two sides of B1 respectively.
Cubestep3.jpg
  • Step4:Connect antenna to the bottom of the nRF24 module, stack them with Microduino-Core, then connect them to the battery onto the base board of the Robot; Fixate that structure on B1 with screws.
Cubestep4.jpg
  • Step5:Fixate C2 onto the corresponding position of A2.
Cubestep5.jpg
  • Step6:Connect D1 to the interface of B2 and C1, then connect D2 to the front slot of B2 and C1. Congratulations! You just finished the installation. Tear off the stick of the antenna and affix it to the car.
Cubestep6.jpg

Joypad Buildup

  • Step 1:Put the Microduino-TFT into the panel of Microduino-Joypad and fixate them with nylon screws.
Joypadstep1.jpg
  • Step 2:Plug the sensor cable into the interface of Microduino-TFT.
Joypadstep2.jpg

Note: For different battery connection, please dial the switch in the middle as the picture shows. You need to adjust the switch firstly and then connect batteries.

11Joypadstep1 1.jpg
  • Step 3:Put the two Joypad keys, batteries and four white keys into the right place and then connect the nRF24 module (with antenna)and the Core module on the base board of the Joypad.
Joypadstep3.jpg
  • Step 4:Connect one side of the Microduino-TFT sensor cable to the corresponding position of the base board.
Joypadstep4.jpg
  • Step 5:Fixate the Joypad shell and the panel.
Joypadstep5.jpg
  • Step 6:Tear off the stick of the antenna and affix it to the Joypad panel.
Joypadstep6.jpg

Joypad Buildup & Debugging

  • Key setting

Press Key1 in 4s after opening the Joypad , it'll enter the Config mode.

Step00001进入设置.jpg
  • Enter the setting mode

Key 1- Key 4 from the left to right as the picture shows below.

Step002按键对应.jpg

Note: You have to enter the setting mode before the OS interface. (4s) If not, please restart.

  • Joystick calibration

Press Key3 and Key4 to move the cursor. Be noted of the Key1 points to "Return" and the Key2 refers to "Confirm". Select Joystick Config to enter the setting mode. And choose Joystick Correct to enter the calibration mode. After that, it'll appear the interface shown in the third picture with an initializing state of two crosses. At the this time, you can move the joystick around. Then, you can see circles in four directions and biggest circle means the Joystick has been turned to the limit position. Press Key2 to confirm after the calibration and return to the last page.

Step003摇杆校准.jpg
  • Select the control mode

Press Key1 to return to the main page and select Protocol Config to enter mode selection. Select the first Mode, then choose nRF24(namely, Robot control mode), press Key2 to confirm and return.

Step004设置Robot模式.jpg
  • Set communication channel

Return to the secondary list, select nRF24 Channel and press Key2 to confirm. Select 70, which corresponds to the function setting of the nRF24 in Robot_Microduino.ino.

Step005通信通道设置robot11.jpg

By this step, you have completed the Microduino Cube Robot car and the Joypad installation.

Attention

  • Please make sure you only stack the Core (Core+) and the USBTTL modules when downloading the program. Although the nRF24 will not cause conflict, other communication modules may lead to serial conflict.
  • Make sure the right cathode connection of the lithium battery, or it'll burn the circuit.
  • After the debugging, please don't adopt USB power supply when running the program and use battery instead, or it may cause undervoltage.

Program Description

  • About Joypad

In def.h, it defines:

uint8_t nrf_channal = 70;  //0~125

nrf_channal is the NRF communication channel, which is included in the code of both the Joypad and the Cube Robot car. When the channel is consistent, the Joypad and the Cube Robot car will be connected successfully. In the car code, it'll show program sections as follows:

 //nRF==============================
  SPI.begin();		//Initialize SPI 
  radio.begin();
  network.begin(/*channel*/ 70  , /*node address*/ this_node);

在data.h中

  outBuf[0] = Joy1_x;
  outBuf[1] = Joy1_y;
  outBuf[2] = Joy_x;
  outBuf[3] = Joy_y;
  outBuf[4] = map(AUX[0], 0, 1, Joy_MID - Joy_maximum, Joy_MID + Joy_maximum);
  outBuf[5] = map(AUX[1], 0, 1, Joy_MID - Joy_maximum, Joy_MID + Joy_maximum);
  outBuf[6] = map(AUX[2], 0, 1, Joy_MID - Joy_maximum, Joy_MID + Joy_maximum);
  outBuf[7] = map(AUX[3], 0, 1, Joy_MID - Joy_maximum, Joy_MID + Joy_maximum);

The 8-bit array "outBuf" represents 8 data sent from the Joypad. 0: left and right control of the right rod. 1: up and down control of the right rod. 2: left and right control of the left rod. 3: up and down control of the left rod. Bit 4~7 correspondS to AUX0~4.

In nrf.h

struct send_a	//Send 
{
  uint32_t ms;
  uint16_t rf_CH0;
  uint16_t rf_CH1;
  uint16_t rf_CH2;
  uint16_t rf_CH3;
  uint16_t rf_CH4;
  uint16_t rf_CH5;
  uint16_t rf_CH6;
  uint16_t rf_CH7;
};

Here "send_a" correponds to the data sent from the 0 bit.

  • About the car

Below is the definition about controlling the left and right wheel movement of the reducer motor.

#define motor_pin0A 5  //PWM left
#define motor_pin0B 7
#define motor_pin1A 6  //PWM 
#define motor_pin1B 8

Here "receive_a" corresponds to "send_a" in the Joypad program.

struct receive_a	//Receive
{
  uint32_t ms;
  uint16_t rf_CH0;
  uint16_t rf_CH1;
  uint16_t rf_CH2;
  uint16_t rf_CH3;
  uint16_t rf_CH4;
  uint16_t rf_CH5;
  uint16_t rf_CH6;
  uint16_t rf_CH7;
};

Select CH3 as the left rod to control the Cube Robot fore and aft, and the CH0 as the right rod to control left and right.

 _i[0] = map(rec.rf_CH3, 1000, 2000, -MAX_THROTTLE, MAX_THROTTLE);   
_i = _turn;
_i[0] = map(rec.rf_CH0, 1000, 2000, -MAX_STEERING, MAX_STEERING);

Video