Thursday, February 26, 2009

Welcome to the english version of our blog!

We are a group of college students from the Electrical major from ITESM Chihuahua.

On this semester, we are working on a project for our robotics class. The project involves designing and building a surveillance robot. This robot will be created with educational purposes.

We had created a spanish version of the blog, the contents are pretty much the same, but you can find the original entries to the blog in the following webpage:

http://robotecnicos.blogspot.com

Take a look at the things we have been working on. Feel free to follow our steps and do your own creations.

WELCOME!

Tuesday, February 24, 2009

First test code for the PIC16F877A

We visited the robotics help webpage:

ROBOT ELECTRONICS - 1st rule of Robotics: Have fun!

In this webpage we could find a variety of examples to control our SRF08. The owners of this code samples allows us to use them for educational purposes, but not commercial ones.

We found the following program, which would be the first in our set of tests with the PIC16F877A.

'****************************************************************
'* Name : UNTITLED.BAS *
'* Author : [Vladimir Kornienko] *
'* Notice : Copyright (c) 2006 [ARMORED DOLPHIN] *
'* : All Rights Reserved *
'* Date : 12/1/2006 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************************************

'PIC16f872

'---------------- Definitions---------------------------------------------

define OSC 20

'------------- Define LCD registers and bits------------------------------

DEFINE I2C_HOLD 1
define I2C_SLOW 1

Define LCD_DREG PORTB 'Set LCD data port
Define LCD_DBIT 0 'Set starting data bit
Define LCD_RSREG PORTB 'Set LCD register select port
Define LCD_RSBIT 4 'Set LCD register select bit
Define LCD_EREG PORTB 'Set LCD enable port
Define LCD_EBIT 5 'Set LCD enable bit
define DEBUG_REG PORTC 'Set DEBUD port
DEFINE DEBUG_BIT 1 'Set DEBUG pin
DEFINE DEBUG_BAUD 2400 'Set DEBUG baud rate
DEFINE DEBUG_MODE 0 'Set DEBUG mode

DPIN var PORTc.4 ' I2C data pin
CPIN var PORTc.3 ' I2C clock pin

bearing var word ' word size bearing value 0 - 359
bearing1 var byte ' byte size bearing value 0 - 254

Main:

i2cread dpin,cpin,%11000000,2,[bearing.Highbyte,bearing.lowbyte]
lcdout $fe, 1,"BEARING ",DEC BEARING/10
i2cread dpin,cpin,%11000000,1,[bearing1]
lcdout $fe, $c0,"Bearing ", dec bearing1
DEBUG " Compass Bearing ", # bearing,13,10
pause 20

goto main

Microcontroller PIC16F877A (to control the sensors)

The microcontroller to be used to control our sensors is the PIC16F877A, this one has the particularity of having the necessary pins to communicate in the I2C protocol, making it the best option to our case. The following are the main characteristics of this model:

  • Operation Speed: 20Mhz
  • More than 8K x 14 words of memory FLASH
  • More than 368 x 8 bytes of data memory (RAM)
  • More than 256 x 8 bytes of data memory EEPROM
  • Low energy comsumption.
  • Serial Synchronic Port (SSP) with SPI (Master Mode)
  • I2C (Master/Slave)
For more information:

Ultrasonic sensor SRF08 specifications

The SRF08 is one of the sensors with which our surveillance robot will avoid obstacles. In this way, our robot will be able to avoid them and keep on the same path.

This is a high performance distance range sensor. It communicates in the protocol I2C, which is available in the PIC microcontroller to be used to this application.

The SRF08 behaves in the same way than series 24XX eeprom's, except that the adressing in I2C is handled differently.

Some specifications of the sensor:

Voltage: 5v
Current: 15mA Typ. 3mA Standby.
Frequency: 40KHz
Range: 3cm -6m.
Standard Connection I2C Bus.
Light sensor
Units range reported in uS, mm or inches.
Dimensions: 43 x 20 x 17mm height
Weight: 11 g.

Guide to install the CHDK

The CHDK is a program that runs over the factory firmware of several models of canon cameras. Due to its nature, the CHDK is not destructive and in case you don't want it anymore in the camera it was installed in, it can easily be removed.

The following are materials needed to install the CHDK:

Φ SD card
Φ Powershot Canon Compatible Camera. (aqui)
Φ SD card reader
Φ Program CARDTRIKS for Windows users
Φ Hexadecimal editor of your choice

The first thing you have to do is check what FIRMWARE version is included in your camera. For this, we create a Dummy file called vers.req which doesn't need any special contents (It can be a 0 Kb file) It is really important for this step, and for all of them, to have a card reader that recognizes our card as an external disc (or as a standard USB flashcard). If you use the USB cable of the camera, you won't have access to the highest level directory of the card, just to the picture folder.

The file vers.req is copied to the card and after that we need to insert the card in the camera. Turn on the camera in the display mode and press SET for one second. After this, press the DISP button without releasing the SET button, this will cause our FIRMWARE version to appear on the display. In our case, our camera has the GM1.00A.

Once you know the firmware version, download CHDK for the right camera. (http://mighty-hoernsche.de/)

Before installing CHDK on the SD card, we need to set it as we previously described. Windows users will use the program we already mentioned. Mac and Linux users (among other OS based on UNIX) can use the command line to do it. In this case, we formatted the card as FAT16 (just for cards with storage of less than 4gb).

After the command line in the terminal (for Mac users) you use the command dd if=/dev/diskXsX of=BootSector.bin bs=512 count=1 where diskXsX is changed for the card id (something like disk1s1) and this gets copied to your computer in the running sector of the card. The instruction in ubuntu would be dd if=/dev/sdx1 of=BootSector_G9.bin bs=512 count=1 where sdx1 is the card id. This will create the file Bootsector.bin in the "home" file of the user you are currently being at the time.




After this step, you open the file that was copied to the hard disk with an hexadecimal editor and in the 40hexadecimal sector (64 in decimal system) you add the word BOOTDISK, save the file and then do the inverse procedure: You should copy the file to the memory, (in the running sector) in Windows you can use a program for this, in Mac you use a command line in terminal similar to the one used before: dd if=BootSector.bin of=/dev/diskXsX bs=512 count=1 where diskXsX gets replaced by the identifier of the disk, like disk1s1 is. The command line in ubuntu is dd if=BS.bootable of=/dev/sdx1 bs=512, where sdx1 is the card id.
IMPORTANT: in case some of the instructions show you an error message like “dd: /dev/disk1s1: Resource busy” it means that the card is being used by the operating system, so you need to "unmount it," in UBUNTU you can do this from the command line, in MAC you need to go to DiskUtility and select UNMOUNT, it is important to notice that this is not the same thing as ejecting the disc, if you eject the card this will lose the conection to the computer, in this case all we are doing is unplugging the controller that allows the OS to perform actions on the card (like copying files or explore its contents) but the card keeps having a conection to our computer.


Once our card is ready you can install CHDK, the first thing you need to do is decompress the file that was downloaded and place it on the card, all the program goes inside of a folder known as CHDK on the card's root. Once done, you insert the card to the camera but watch out! The LOCK switch on it (Image to the left) must be activated. This switch shows that you can't write files on the card and it is necessary because, in theory, you cannot write on the disk you are using to run the software, but the CHDK overwrites with software this function so the card can also be used to take pictures.

Finally, we just need to turn on the camera and enjoy the CHDK functions.

If you want to use an extra program, go to:
http://chdk.wikia.com/wiki/UBASIC/Scripts
In this webpage they offer a series of extra functions programmed for the CHDK. A really interesting script is the one that senses movement, the demonstration of this program will be done in class.
http://chdk.wikia.com/wiki/UBASIC/Scripts:_Multipurpose_Motion_Detection
To use this scripts, you just need to copy them to the card and load them from the CHDK menu.

Friday, February 20, 2009

PPT sensors

Protocol I2C summary

Whenever multiple devices got connected to a microcontroller, the adress and data lines from each device got connected individually by default. This stole useful pins from the microcontroller, which resulted in several tracks in the PCB and required more components to be connected. At the same time, this made the systems to become more expensive and vulnerable to interference and noise.

To solve this problem, Phillips developed Inter-IC or I2C in the 80s. I2C is a short distance, low bandwidth protocol. All of the devices connect to the network by 2 cables. We already mentioned that we will be using the SRF08 ultrasonic sensor, which is designed to communicate through this protocol.

The following are some of the most important characteristics of this protocol:

•It needs only two lines, the serial data and serial clock (SDA and SCL)
•Each device connected to the bus has an address code that you can choose by software. There is permanently a Master/Slave relationship between the microcontroller and the devices connected to the network
•The bus allows the connection of several masters, since it includes a collision detector.
•The data and address transference protocol allows us to design systems completely defined by software
•Data and address are transmited in 8bit words.

The lines SDA and SCL transport information between the devices connected to the bus. Every device is recognized by its own code or address and it can operate as a transmitter or receive data. Besides, every device can be considered as master or slave. The master is the device that starts the transference in the bus and generates the clock signal. The slave is the addressed device.

The lines SDA(serial Data) and SCL (serial Clock) are bidirectional, connected to the positive voltage through the pull-up resistors. When the bus is free, both lines are on logical high level.

The serial bidirectional data transmission (8-bits)can be done at 100Kbits/s in the standard mode or at 400 Kbits/s in the fast mode.
The quantity of devices that can be connected to the bus is limited, only, by the maximum capacitance allowed: 400pF.

Tuesday, February 10, 2009

Wednesday, February 4, 2009

EYE FI


We found some pictures on Flickr where they opened the EYE FI card, in this way, we can notice how the card is built from the inside. We see that we have a SAMSUNG memory chip, the wireless chip is ATHEROS (the ROCm that is used in cellphones with WI-FI). We also have the GPS chip that is only available on the most expensive version of the card.
http://www.flickr.com/photos/sniperninja123/3245581254/in/photostream/

Here is a webpage where they explain in detail what is every chip and its specifications.(http://www.ikontools.com/articles/eyefi-dissected)

Tuesday, February 3, 2009

Camera Option

This is one of the choices of cameras that we are considering.