Showing posts with label M-Blocks. Show all posts
Showing posts with label M-Blocks. Show all posts

Thursday, November 17, 2011

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.

M-Blocks PCBs

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

網誌日期:2008-04-26 01:46
I started the project called "M-Blocks" on April 05 and the first phase was completed on Dec 06. Later  I started another project and did not have time to continue the development of the M-Blocks.

Here I would like to share the design, construction and coding of M-Blocks. But today is 26.4.2008. I have to recall my memory to fill out the content. I hope to make it as accuracy as possible and the content will be revisited if i found it is incorrect. Sorry for that.

What is M-Blocks? Look at the following notebooks. I think only me can understand what it means?

M-Blocks are modules which can be stacked together to perform a system for mobile robot.

For the first phase. I designed:

1. Controller Module (CM)
2. Motor Module (MM)
3. Servo Module (SM)
4. Radio Module (RM)
5. Bluetooth Module (BM)

All the modules are connected via I2C bus and they all can be debugged through serial port individually (UART).
Each module have a atmega8, atmega168 or atmega32 for the mcu.

   | --- BM ( Serial )
   | --- RM ( PPM )
   |       
 CM    MM    SM   
   |          |          |       
-------------------------------------------------  I2C bus

I designed the schematic and boards in Eagle and write C code in gcc-avr.








Schematic and circuit board  for Servo Module.




The printed PCB. I use toner transfer method to make the double sided PCB. I use the following type of paper. It called "Glossy Photo Paper".


The steps are as same as that in the following video.
http://www.youtube.com/watch?v=urv6jArKp6M&feature=related

Each PCB have top and bottom print out from the glossy photo paper. And one bottom layer from transparent. Totally three print out. The transparent print out is used for alignment purpose.


Alignment of the top and bottom layers to make double sided PCB.


PCB Etching. I use Ferric chloride (FeCl). It is very dirty but can be reused.


Then drill holes.


The completed PCB.


Put in components , compete soldering and test the circuit board.
This is the Sensor Module. The mcu is either atmega8 or atmega168.


This is the another Controller Module. I created the first Controller Module with atmega8. But I found out there is not enough space to coding the "Brain" of the robot. Then, I created another Controller Module with atmega32 which provide more space (32 Kbytes) for coding.



M-Blocks Modules completed.


Stacks of M-Blocks



Next. I will show the application of the M-Blocks.