Saturday, November 16, 2013

Arduino Robot Review

Arduino Team 今年五月推出 Arduino Robot。這個Robot由 Control 板塊及 Motor 板塊所組成。 每個板塊由 ATmega32u4 所控制。 所用的主控制器和 Arduino Leonardo 一樣。 與 Arduino Leonardo 比較, Control 板塊另加有512 Kbit EEPROM,5 鍵 Keypad,轉動把手(Knob),  全彩 LCD,SD 讀卡器, 一個揚聲器, 一個數字指南針。 Motor 板塊就主要控制馬達,可使 Robot 四處走動。 另外有感光感應器用作 Line Following 應用。 電池用4粒1.2V NiMH 充電池共 4.8V。可以用附帶的充電器直接充電。 為何要用兩塊板? 我認為是模塊化設計,它有助將控制和運動分離。除此外就是增加 Control 板塊的連接針數目。如果只用一塊板又要連接馬達又要連接感應器( Senors),可用的連接針數目就會很少了。



有關Arduino Robot詳情資料,請訪問官方網站:
http://arduino.cc/en/Main/Robot
http://arduino.cc/en/Guide/Robot
http://arduino.cc/en/Reference/RobotLibrary

另外RS和Arduino的團隊製作了5部影片, 可使你更明白 Robot 可以做什麼.
http://uk.rs-online.com/web/generalDisplay.html?id=arduino

收到這個Robot第一時間當然是連接電腦。在 Arduino IDE下測試示例代碼 (Sample Code)。 過程非常容易及順利。 上戴了示例代碼後, LCD 就顯示出數值。 示例代碼差唔多包含所有控制的使用 (例如馬達控制, 指南針, 揚聲器, LCD, IR Remote Control 等 )。 我就非常有興趣測試 Line Follower 程式。 我預備了從前LEGO Mindstrom 留下的Line Follower 工作紙做測試。 Arduino 官方網站就建議劃一條大於 3cm 的黑色線在白紙上。但我已經有了,就快快的試一試。 LEGO 的 Line Follower 工作紙上的路軌比較簡單,遲些有時間就自己製作難度高的路軌,看看Robot 有什麼反應。上戴了Line Follower 示例代碼,然後將Robot放在路軌上。 它起動了, 但走了大約一圈就停了。 其實程式可以改變 PID 控制的參數KP, KD 及 RobotSpeed的數值. 但每次更改 PID 的數都要重新上戴程式。 過程十分不方便。於是我就寫了一個程式可以隨時更改PID參數的數值。可以實時見到效果。上下Keypad按鍵改變KP。左右 Keypad按鍵改變KD,轉動把手(Knob) 將會改變RobotSpeed。 中間Keypad按鍵是暫停及重新啓動, 這樣我就可以不斷改變PID的數而希望得到最快最好的效果。這個程式是公開的,有趣趣的朋友請到以下網站下戴。


https://drive.google.com/file/d/0Bzl3RqbE2zm3dVAwXzQxWVgzd2c/edit?usp=sharing






玩了Ardunio Robot 大約兩個星期時間,我覺得它的設計很適合教育用途。雖然市面上都有其他類似的產品。但係因為 Arduino Robot 係一個全開放的設計你可以更改 Control 及 Motor 板塊任何程式。這個給與你很大的自由度。另外 Arduino 有很大的用戶群,你可以很容易找到適合的 Libraries 或程式。

玩 Robot的朋友當然不會安於現有限制的局限。會不斷思考怎樣鄺充現有的硬件及軟件。硬件方面,Arduino Robot 本身機體大小適中,應該可以加入不同的傳感器。 另外有四個Prototype Area,可加上麵包版做測試。例如在麵包版上加入超聲感應器。



軟件方面,它本身帶有 I2C 及SPI通訊協定介面,不過UART serial由於要連接Control 及 Motor 板塊,不能有其他用途了。例如不能連接藍牙串行端口( Bluetooth Serial Port)。  如果可以連接藍牙串行端口就可以再連接 iphone 及 Android 手機 或者電腦。 雖然如此, 開放的設計特別之處係可以運用你的創新及想像去解決現有的限制。 我就計劃測試以下的功能。

- 通過SPI 連接 PS2 Game Controller (http://www.billporter.info/2010/06/05/playstation-2-controller-arduino-library-v1-0/ )。
- 通過 Software Serial  Port 去連接藍牙串行端口( Bluetooth Serial Port)。
- 通過I2C 連接 Raspberry Pi ( http://blog.oscarliang.net/raspberry-pi-arduino-connected-i2c/ )。
- 改變Control 板塊和Motor 板塊的通訊的方式由 UART serial 轉用 I2C 通訊協定 這樣就可以將UART serial用作其他用途了。

下回再與大家分享以上鄺充心得。

Mike

Thursday, November 17, 2011

Using Cellphones as Robotic Control Platforms - Cellbots.com

http://hk.myblog.yahoo.com/robot-builder/article?mid=210
網誌日期:2010-04-08 00:06
http://www.cellbots.com/about/

I agree that it is possible to control the low level devices such as Arduino or PIC from cell phone by just using serial port or bluetooth connection. you just design the serial protocols and it can control the devices on the fly.

I designed M-proxy which will do the similar job by using Nokia N82. But it is not limit to use Iphone and Android phone.

m_proxy version 0.1

http://hk.myblog.yahoo.com/robot-builder/article?mid=183
網誌日期:2010-03-01 00:49
Today, most smart phones ( such as Nokia, iphone, Google Android ) have high resolution camera, Wifi, 3G, HSDPA, 3D tile sensors, GPS and compass functions). Did you think you can turn the smart phone into robot brain? The answer is Yes. I designed m_proxy which will make use of these functions and will let you to control your robot from any place of the earth. You and the robot just need to have Internet access. To implement the m_proxy, I use a cheap 27Mhz RC tank, Arduino, Nokia N82 to build the prototype and test the performance. The target is to make a semi-auto surveillance mobile robot and perform some tasks.

Please refer to the following url for the construction of the robot.
http://picasaweb.google.com/103004795864513293020/M_proxy#slideshow/5443335185983998850

m_proxy

Motor Module

http://hk.myblog.yahoo.com/robot-builder/article?mid=79
網誌日期:2008-05-29 00:29
In this part, I would like to describe the structure of the M-Blocks, both hardware and software, via the Motor Module.

1. Hardware side

Motor module consists of  following common interfaces and it's specific interfaces:


see large picture

a. Common interfaces ( yellow blocks )
1. ISP Programming port
2. ON/OFF Switch
3. UART Serial port
4. M-Blocks Bus which have the following standard.

------------------------------------------
Vin - Input Voltage from battery
Vcc - Regulated 5V
3.3V - Regulated 3.3V
SCL  - I2C  Clock  Bus
SDA - I2C Data Bus
S3, S2, S1 - Slave select for SPI bus
MOSI, MISO, SCK - for SPI bus only
( SPI bus is left for further use, I have not develop any sensors or devices through SPI communication )
TX - Transmitter for UART - connected to PC for debug only
RX - Receiver for UART - connected to PC for debug only
-------------------------------------------

b. Specific interfaces for Motor Module
1. SN754410 H-Bridge
2. External Power Input
3. Motor Connectors 1-4



2. Software side
Except the Controller Module which is a master I2C device, all other modules are slave I2C  devices. The design  of  the program  is divided  into three parts: 

   --------------------------
   |  I2C                         |   
   --------------------------
   | UART                    |   
   --------------------------
   | Functional Logic  |
   --------------------------

1) I2C communication among the modules,
2) UART serial communication for debug only ,
3) The functional logic for controlling devices such as motors or servos.

I developed the program in WinAVR and built the hex file using avrdude. If you are interesting in the program, please download here. motor-module.zip

Schematics and board layouts for Eagle


see large picture.

I use atmega8 to make all the communication and controlling. Atmega8 have three timers providing three PWM Channels. It is able to control the width of the PWM to the SN754410 H-Bridge IC by controlling the values of  OCR1A ( motor 1 PWM) ,OCR1B (motor 2 PWM) and OCR2 (motor 3 PWM).

For the detailed information of Atmega8, please refer to the data sheet.


The protocol is very simple.

[ch][dir][low-power][h-power] , 1 byte each

[ch] set the motor channel , value = 0,1,2
[dir] set the forward direction or backward direction of the motor, value = 0,1
[low-power] and [high-power] set the speed of the motor, value = 0-255

Example: 00FF -> set ch 0 (left motor), dir 0 (forward), power = FF = 256.

The routetime set_power(uint8_t ch , uint8_t dir,uint8_t power) control the motor, direction and speed of the motor.

As I am not a master in programming micocontroller, many of the coding, especially the hardware configuration, or library are "borrowed" from other's projects.

The I2C library is borrowed from http://tuxgraphics.org/electronics/200705/article07051.shtml
and the PWM control is borrowed from another website but I forgot the author's website.

So far, the Motor Module is working. It received commands from Controller Module and run set_power() routine to generate the PWM for the H-Bridge and control the speed of the Motors. My final version is to make the device which provide  feedback parameters to the Controller Module. To make it as a close-loop control. I will borrow the design from the controller board of  the openservo project. The controller board is a I2C slave device and it have feedback parameters to the controller board. All the parameters are saved in the registers ( flash memory ) of the micro-controller ( atmega8 or atmega168 ) and
permanently  in the EEROM as in the following diagram.

   --------------------------
   |  EEROM                 |
   --------------------------
   |  I2C                         |   
   --------------------------
   | UART                    |   
   --------------------------
   | Functional Logic  |
   --------------------------


Reference websites:
1. Dr. Pascal Stang have contributed to the programming and design of the hardware. It is worthly to study his design if  you want to learn avr-gcc programming and hardware design. I have implement the I2C master device from his design.
http://hubbard.engr.scu.edu/embedded/

2. Openservo project, the opensource servo controller is based on atmega8 or atmega168 and avr-gcc. The design is very good.
http://www.openservo.org

3. Paparazzi UAV project
Paparazzi is a free and open-source hardware and software project intended to create an exceptionally powerful and versatile autopilot system by allowing and encouraging input from the community. I implement the PPM decoding for my 6 channels Radio Transmitter by referring to the UAV project.

M-Blocks Application

http://hk.myblog.yahoo.com/robot-builder/article?mid=60

網誌日期:2008-05-09 00:45
This is the robot I built for the M-Blocks Modules. It is a Lego tank with a video camera attached to two servos. I built this robot aim to develop the protocols for communication among the modules. In the first phase, I think the protocol is not very efficiency and need improvement. Anyway. I can now use either radio transmitter, PC terminal, or Nokia N82 to control the robot. It is quite interesting! I think it is possible to add other control interfaces such as PS2 controller and IR Remote.






Construction of the robot with M-Blocks

Control M-Blocks by Radio Control

Control M-Blocks by PC

Control M-Blocks by Nokia N82

Design of M-Block

http://hk.myblog.yahoo.com/robot-builder/article?mid=56

網誌日期:2008-05-07 21:43

1. Why design  M-Blocks?

Having experience in programming with atmega8  ( 8K Bytes flash program memory, two 8-bit timer, one 16 bit timer , 6-8 ADC, 1 UART, 1 I2C, 1 SPI ). I figured out it is quite limit if you need to build a robot with many sensors and accumulators. That  comes to my mind and think  it is  possible to build stack blocks of atemega8 and connect them together. Each block perform it's own function. The challenge is to design the protocol to communicate among the blocks.

The following figure outlines the design. The I2C Master device called Controller Module (CM). CM  perform its task by receiving commands from Radio Control, Bluetooth serial port or PC serial port. Then, it sends I2C commands to the slave devices and receive response from these devices. When the salve devices receive the commands, they will perform its own tasks. It is possible to write a autonomous logic. For example, Motor Module will turn on and turn off the H-bridge, Servo Module will move the servos, Sensor  Module will acquire data and response to CM.  That is it!. It seems all the above functions can be carried out in a single board computer. But if you need to extend the number of sensors (say 20 more) or number of accumulators (say control 4 motors more). Single board computer cannot achieve the goal.

(M)     (S1)    (S2)     (S3)     (S4)   ...... (Sn)
CM    SM1   SM2    MM1   MM2  .....            M-Blocks
  |          |           |           |           |
------------------------------------------------  I2C Bus

Lets see how I2C works.
http://www.esacademy.com/faq/i2c/general/i2cproto.htm
http://www.robot-electronics.co.uk/htm/using_the_i2c_bus.htm

www.robot-electronics.co.uk sells Compass sensors, Servo Controller, Ultrasonic Sensor, Thermal Sensors , Text to Speech Synthesizer. All have interface to I2C.

If it is possible to develop efficiency I2C protocols for communication among the salve modules and the mater module, it is possible  to extend the system by adding new modules.


2. What is the Pro and Cons of M-Block?
Pros:
1. Multitasking, each module perform  its own task, for example, controller in Motor Module only service to control the H-bridge.

Cons:
1. All modules are connected through I2C bus. If the bus hanged, the system will not work.
2. All the control is carried out through Controller Module as a proxy by sending commands to  the Slave Modules. This turn out to be quite inefficiency in control.


3. M-Blocks structure

a. Controller Module - I2C Master module to control slave devices

b. Motor Module - I2C slave device to control two SN754410 H-Bridge Motor Driver 1A

c. Servo Module - I2C slave device having 12 channels for controlling stanard  analog servo .e.g. Futaba S3003.

d. Sensor Module - I2C slave device with  ADC conversion for connecting Ultrasonic Range Finder - Maxbotix LV-EZ0 and Infrared Proximity Sensor - Sharp GP2Y0A21YK

e. Radio Module - 6 channels Radio receiver and transmitter detached from damaged electric helicopter. It connect to Controller Module and ICP to decode PPM signals.

f.  Bluetooth Module - As a bluetooth serial port  Bluetooth Modem - BlueSMiRF Silver connected to Controller Module's UART serial port. The bluetooth serial port will let you control the robot from PC terminal or custom build programe. It is possible to control the robot from bluetooth smartphone such as Nokia N73 or Nokia N82.

Download


http://hk.myblog.yahoo.com/robot-builder/article?mid=45

網誌日期:2008-04-30 00:04

1. M-Blocks schematics and board layouts ( Updated on 30.4.2008 )
M-Blocks.zip consists all the schematics and board layouts for Eagle ( http://www.cadsoft.de/ ). To view the files, you can just install Eagle and unzip the files in the "Projects" folder of Eagle.