Wed Apr 25 21:12:14 CEST 2012

Video!


The code in the video has since been improved alot. It doesn't drive off the edge(very often) or molest my tripod or rug anymore
It should be noted that this is on my not very grippy and a bit dirty hardwood floor. After ~5 hours of adjusting values back and forth it can stay in the circle without big problems(on my slippery floor). I suspect it won't be as much of a problem on the 5mm steel dohyo at Robot-SM.

Posted by Gabriel Fornaeus | Permanent link | File under: robots, electronics, arduino

Mon Apr 23 04:38:04 CEST 2012

Time for Robot-SM 2012!

This Saturday it's time for this years installment of the national Swedish championship in robotics.
I will participate in the 3kg sumo-class(also known as megasumo) with my robot; Horus Lambda.
It's powered by four Lynxmotion GHM03-motors(300 rpm at 7.2VDC, not sure what they produce at 11.1VDC :). The sensors are two TCRT5000 refletive IR-sensors for the line-sensing and four HC-SR04 ultrasonic range finders for opponent detection. The motor driver is the H-bridge I've posted about previously. Here are some pictures of it during the build process.
The code isn't finished of course, it's not the night before the competition. Videos of it failing to do various tasks will be up during the week.

Posted by Gabriel Fornaeus | Permanent link | File under: blog, robots, arduino

Mon Apr 9 00:21:23 CEST 2012

AVR-Code!

So I've decided to ditch the Arduino-enviroment in favour for "pure" AVR-C.
I have already got an AVR Dragon, so programming is no big problem.
The reason I'm doing this is because I can more and more notice that the Arduino-language, although easy, is a bit limiting, especially in how it handles interrupts. For your( and mine as well) convinience I've set up a git-repo that will contain all my code for AVRs line of microprocessors.
If nothing else is stated, all code is released under GPL version 3.

Posted by Gabriel Fornaeus | Permanent link | File under: linux, electronics, arduino

Wed Apr 4 01:55:08 CEST 2012

An Arduino library

So I decided to write a library for controlling H-bridge-connected motors for the Arduino enviroment. Here's an url to it. For now I'm just calling it "Motor" until I can think of something better. There are (as of yet, more are planned) three function calls; Forward, Reverse and Coast. The names are self explanatory. Example:
/*

   Example motor-control code by Gabriel Fornaeus
   More information at http://hax0r.se

 */

// Set ledPin
int ledPin = 13;
// Motor control
#include 
motor left(6, 7);
motor right(5, 4);

void setup() {
    // Initialize the LED pin as an output:
    pinMode(ledPin, OUTPUT);      
    }

void loop(){

    // Set LED on
    digitalWrite(ledPin, HIGH);
    // Drives forward at 58% speed
    left.Forward(150);
    right.Forward(150);
    // Coasts for one second
    left.Coast();
    right.Coast();
    delay(1000);
    /* PWM-breaking applied for 500 milliseconds 
     (this can cause high current drain, make sure your transistors can handle it)
     */
    left.Reverse(3);
    right.Reverse(3);
    delay(1000);
    // Spin
    left.Reverse(100);
    right.Forward(100);
    delay(500);
    // Coasts for one second
    left.Coast();

    // Turn LED off and wait for one second
    digitalWrite(ledPin, LOW);
    delay(1000);

}

Simple, right?

Posted by Gabriel Fornaeus | Permanent link | File under: robots, electronics, arduino

Wed Jan 4 02:14:05 CET 2012

Working with arduinos from the command line

This is sort of a howto on how I do my development with Arduinos, while there is nothing wrong with the IDE, it's sort of in the way most of the time to me. I prefer using my favourite editor(Vi IMproved of course) and make.
This is kind of tricky, since I'm not that certain as to what the IDE does when it compiles the source in to a hex-file. Luckily, I found a make file that works with Arduino 1.0.

But let's not get ahead of ourselves! First thing we have to do is setup our editor.
The Arduino IDE uses .pde as it's file format of choice. For fancy syntax highlighting we need to add a Syntax file for vim.
First thing that we need to do is create a directory to hold our syntax file.
$ mkdir -p ~/.vim/syntax

Next step is to download the syntax file and put it in the directory.
$ wget http://www.vim.org/scripts/download_script.php?src_id=17108 -O ~/.vim/syntax/arduino.pde
--2012-01-04 01:11:30--  http://www.vim.org/scripts/download_script.php?src_id=17108
Resolving www.vim.org... 216.34.181.97
Connecting to www.vim.org|216.34.181.97|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2258 (2,2K) [application/octetstream]
Saving to: `/home/gabriel/.vim/syntax/arduino.pde'

100%[=======================================================================================>] 2 258       --.-K/s   in 0s      

2012-01-04 01:11:30 (324 MB/s) - `/home/gabriel/.vim/syntax/arduino.pde' saved [2258/2258]

$

Next, we need to add a line to our ~/.vimrc so that vim will recognize .pde-files as arduino files.
" For arduino syntax
autocmd! BufNewFile,BufRead *.pde setlocal ft=arduino

Now vim should recognize .pde-files as arduino-files and you will have wonderous colours flying over your screen in formations of joy.
Next step is creating a directory for your project, let's call it Super ninja robot master control beaver.
$ mkdir -p ~/development/arduino/super_ninja_robot_master_control_beaver
Not that hard, huh?
Next step is downloading a suitable Makefile, I've used a modified version of one I found in this post on the Arduino forum. You can find it here.
$ cd ~/development/arduino/super_ninja_robot_master_control_beaver
$ wget http://hax0r.se/files/Arduino-1.0_Makefile -O Makefile
--2012-01-04 01:23:02--  http://hax0r.se/files/Arduino-1.0_Makefile
Resolving hax0r.se... 62.109.46.153
Connecting to hax0r.se|62.109.46.153|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11782 (12K) [text/plain]
Saving to: `Makefile'

100%[=======================================================================================>] 11 782      --.-K/s   in 0,004s  

2012-01-04 01:23:02 (3,10 MB/s) - `Makefile' saved [11782/11782]

$ 
Now that we have a makefile that will work with the Arduino 1.0 IDE, we need some other things too. We need the binaries and libraries from the IDE itself.
We also need stty, avrdude and avr-gcc, install these with your distributions package manager.
$ cd ~/
$ mkdir .arduino/
$ cd arduino/
$ $ I use a 64-bit system, if you have a 32-bit install, use that file instead
$ wget http://arduino.googlecode.com/files/arduino-1.0-linux64.tgz
--2012-01-04 01:24:50--
http://arduino.googlecode.com/files/arduino-1.0-linux64.tgz
Resolving arduino.googlecode.com... 209.85.173.82
Connecting to arduino.googlecode.com|209.85.173.82|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4351508 (4,1M) [application/x-gzip]
Saving to: `arduino-1.0-linux64.tgz'

100%[=======================================================================================>]
4 351 508   1,24M/s   in 3,3s    

2012-01-04 01:24:54 (1,24 MB/s) - `arduino-1.0-linux64.tgz' saved
[4351508/4351508]

$ tar xf arduino-1.0-linux64.tgz
$ 
We're almost done. We just need to modify the makefile to suit our enviroment.
On line 54 of the makefile there should be a line like this
ARDUINO_DIR = /home/gabriel/.arduino/arduino-1.0/
Change that gabriel(Hey! That's me :) to your username. We need to do one more change before we're done though. On line 44 there is a line that looks like this:
 TARGET = sketch
That will have to be changed for every new project you make, unless you want to call the main file sketch everytime.
Now cd to your super ninja robot master control beaver directory and get coding, I'll wait.
Done? Good. Now type make to compile the source code you just created.
$ make 
[ interesting but very long compiling things ]
  text	   data	    bss	    dec	    hex	filename
      0	   1498	      0	   1498	    5da	applet/sketch.hex
$ 
Well woud you look at that, you compiled it, all by yourself, good for you!
Now we need to upload the code to our Arduino, connect it to your usb-port and make sure you've got the right permissions set up.
$ make upload
stty -F /dev/ttyACM* hupcl
/home/gabriel/.arduino/arduino-1.0//hardware/tools/avrdude -V -F -C /home/gabriel/.arduino/arduino-1.0//hardware/tools/avrdude.conf -p atmega2560 -P /dev/ttyACM* -c stk500v2 -b 115200 -U flash:w:applet/sketch.hex

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9801
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "applet/sketch.hex"
avrdude: input file applet/sketch.hex auto detected as Intel Hex
avrdude: writing flash (1388 bytes):

Writing | ################################################## | 100% 0.22s

avrdude: 1388 bytes of flash written

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

$
That's it. You have now uploaded a bunch of stuff to your arduino(I do not take any responsibiliy, what so ever as to what happens to your hardware or anything else if you follow this guide)

Posted by Gabriel Fornaeus | Permanent link | File under: linux, electronics, arduino

Sat Dec 3 23:33:35 CET 2011

Stockholm Robot Championship 2011

There!
Just got home from Stockholm Robot Championship at Tekniska Museet. I used my robot R.A.L.F to compete in the Linefollower-class. I finished second. I made two videos of the event. Video one and the second one.
It went sort of well, except in the second attempt. There was a spotlight who was at a weird angle at the corner, which made it very difficult to detect.
Now I've started working on my 3kg sumo robot for Robot SM. I probably won't win, since some of the bots are really powerful, but I'll hopefully have a chance at second place and possibly first, if something breaks for the other guy :)

Here are some pictures from the competition. Enjoy!

Posted by Gabriel Fornaeus | Permanent link | File under: robots, electronics

Fri Dec 2 13:58:43 CET 2011

R.A.L.F is finished!

My arduinomega based linefollower R.A.L.F is finished. Even made a video of him following a line on the floor. I ran out off electrical tape, that's why there is some duct tape too there.
He sees the world through three Pololu QTR1RC sensors mounted on some breadboard, with a ribbon cable for connecting it to the Arduino Mega(I know it's oversized for something with one serial line and three input sensors as the only devices, but it was the only one that wasn't in some other project).
The motor controller is a Pololu Qik 2s9v1 Dual Serial Motor Controller. I can highly recommend it. It's very easy to work with and can handle 4.5V - 13.5V, with a continious output of 1A and a peak of 3A.

Posted by Gabriel Fornaeus | Permanent link | File under: robots, electronics

Wed Nov 23 10:06:05 CET 2011

Commence Etching!

We did some etching on monday!
Jesse had tried it a bit on his own(he'd only used the toner transfer method earlier).
We came to the conclusion that per one litre of water, 10 milliliter of NaOH is needed. Developing then takes about ten seconds. Here is Jesse developing the board.
After that you have to rinse the board to make sure it's clean before you put it in the etching tank. We made a clever, ghetto-style board holder out of a pants hanger(not sure about the correct word here) and some tape.
When you are doing this inside it is very important that you make sure you have good ventilation, the fumes coming from the etching solvant could be harmful, or as it says on swedish aerosol cans and the likes; "Sörj för god ventilation!" which if you translate it word for word(which you shouldn't, since the sentence makes no sense if you do) means "Mourn for good ventilation".

Etching in progress. And a finished board.
If I can do it, anyone can. Start etching you people!

Posted by Gabriel Fornaeus | Permanent link | File under: electronics

Thu Nov 17 22:51:08 CET 2011

R.A.L.F

So now he's almost finished, my CD-ROM-tray-based robot. The code is in an early state, but it works quite ok. Just need to adjust the P/D-constants a bit maybe. Here is his entry on Letsmakerobots.com.
The code will be uploaded here and on LMR when I'm finished with it. The only thing left to do on this robot is to mount the Arduino Mega a bit better and get a power-supply for it(since I don't mix motor and sensor/mcu power, saves a lot of trouble). Pictures are mandatory of course.
From the back.
Bottom
And from the side
Enjoy!

Posted by Gabriel Fornaeus | Permanent link | File under: linux, electronics

Thu Nov 17 04:58:18 CET 2011

This just made my day

Found this link on r/electronics. It just made my day a bit better, thank you Thingist.
Enjoy!

Posted by Gabriel Fornaeus | Permanent link