Total Pageviews

Friday, June 15, 2012

Raspberry Pi! anyone?

I just got my long awaited Raspberry Pi, super small and cheap computer, from element14 at S$48. The Pi equipped with everything you will need for typical computer, USB, Ethernet port, HDMI, SD card slot and audio output.


List of additional hardware:

  • HDMI - to - DVI cable : because my monitor not support HDMI :(
  • USB with external powered hub : I plan to use WiFi- USB device later which power supply from USB alone is not enought.
  • SDHC (hi-speed SD card) class 6 : from information I can find, the Pi only support SD or SDHC card, not micro-SC card with adapter, with class 4 or more (speed issue I guess?).
This three item cost me about S$82, hope I can learn a lot from it. Let's try ...

First, prepare your SD card

I used the "Easy way" from this link which in short include just two step. First, download Win32DiskImager which is a tool to copy your image file (will get to this in step 2) into your SD card. Step two, download image file, the Debain "squeeze" is recommended one.

Two, connect your hardware

Next obvious step is to connect a required hardware - keyboard, mouse, screen and SD card (you prepared in the first step). For power port, I use my phone charger which luckily a micro USB and provide 1A maximum. Power from USB port alone is not enough for the Pi because its need 700mA while USB 2.0 can provide 0.5A maximum.


Last step, hold your breadth and power it up

When you plugged power cord in you will see a red and green LED onbord the Pi start to blink and (hopefully) your screen flushing with output like this,


And after awhile, it will ask you to input login name (default: pi) and password (default: raspberry). When that's done, you are ready to go! use command "startx" to launch an X window system and you got this


Hoorey! you just got yourself a brand new tool to learn lots of new things!

Tuesday, June 5, 2012

LabView diagram for H-bridge control

Well, after wiring all the cable it's time for programming! My tools of choices for this quick jobs is LabView from National Instrument.

Setting up serial communication in LabView can be done using just 4 block, Open port, Send data, Receive data and Close port. Put everything in While-loop adds a few button and even-case and we are good to go!

My code is shown below :


Well, what the point of seeing my code? would it be nice if you can just copy + past and run above code without having to drag and drop everything yourself? Here is another thing I love about LabView, you can just copy above picture (it is .png file) then open your newly open LabView windows and drop the picture on the window, then tada~~~ there is a ready to run VI for you.

Some useful tip
Do not change direction of your motor abruptly, stop a motor first then change. This is to prevent current surge in your circuit especially when you don't have any current protection circuit like mine!

Warning!
Before connect your motor to power source, it would be wise to test the H-bridge circuit first! Relay of the same side must not close (current able to pass through) at the same time, otherwise current will pass from source (say 24Volt.) directly to Ground which will burn all of your cables and relays.

Quick jobs : H-Bridge circuit to drive a motor

To day my supervisor just pop in and throw me 8 solid-state-relay (SSR) and ADAM-4068 (Serial-I/O device) and ask me to wire a circuit to control a motor for his robot.

ADAM-6048 is a handy device that let you control digital input and output via RS-485, serial communication given a protocol in its manual. Output of ADAM is rated at 0.5 ampere so I use it to control the SSR which can operate up to 40 ampere each.

Circuit diagram is as follow, bigger line means high current cable :


Note :
RL0 NO -- Relay channel 0 of ADAM, Normally Open pin
RL0 COM -- Relay channel 0 of ADAM, Common pin

When output set to "high", current will able to flow from COM to NO. Best to imagine it as a simple switch, when push both pin will connect and let a current flowing. Then pin 1 and pin 2 of SSR will connect and let a (high) current pass through the motor.

Warning!
Unlike normal relay, SSR let current pass in only one direction, from pin 2 to pin 1 and from pin 4 to pin 3 as I indicate + and - sign in above diagram. I blown 2 SSR because of this ignorance!


SSR I'm using are Maxwell's MS-DD6040.

Sunday, June 3, 2012

Getting start with ROSARIA

After get ROS installed, let's get ARIA working. ARIA is an open-source software to communicate with ACOS (low-level control of our Pioneer3-AT). ROSARIA is name of ARIA package in ROS.

I came across this post about how to get ROSARIA install,
http://answers.ros.org/question/11962/require-help-using-rosaria/

I follow the recommended answer and got ROSARIA install successfully. There are some points that I would remind you, before you install the package as mentioned in the post you should go to your working folder first. If you follow the ROS tutorial as I recommended, your working folder is the "ros_workspace" folder in "home" directory. After ROSARIA package is installed, make sure you don't miss the "rosmake" part!, you will get folder "hg" in "ros_workspace".

Also note that the "teleop_base" path will not work as it is no longer support in ROS Electric, but don't worries we will talk about it later.

When everything is ready, let's try it out!

Step1: Safety first!

The most important thing in working with everything with moving part is safety! Take a look around and grab anything that can fit underneath your bot's belly to lift it up, all the wheels should not contact the ground and move freely. This is important because we don't know what gonna happen after we powered our robot for the first time or after we run a new piece of code.

Step2 : Connect to the robot

Now that your robot hang helplessly above ground it's a time to bring it to life! Get you RS-232 ready and plug it to the Pioneer DB9 socket, then plug another end to your computer (of course). Then power your bot up and release the emergency switch (the red button switch).

Step3 : First contact

First thing first, you need to figure out which communication port you are using. ROSARIA default value of port is ttyUSB0, for those USB-to-Serial converter. In my case it's old-school serial port ttyS0.

Bring up you terminal and go to your ROS workspace folder.
$ cd ros_workspace 

In first terminal, bring ROS up to work
$ roscore 

Leave the first terminal untouch and open another terminal and go to your workspace again, now run.
$ rosrun ROSARIA RosAria _port:=/dev/ttyS0

In above code, you may change the "/dev/ttyS0" part to your connected port such as "/dev/ttyUSB0", "/dev/ttyUSB1" or "/dev/ttyS1".

When you press enter, your robot should make a beep-beep sound and have something show-up in your terminal.

Congratulation! you just bring your robot up to life for the first time!


Installing ROS

When you got Ubuntu running then installing ROS is very simple, even for those who never use Ubuntu and never deal with command line before. All you need to do in to launch a terminal up and copy&paste a few command (then press 'Enter'!) from installation instruction from this link.

Note that you can't use ctrl+v and ctrl+c shortcut-key in termical, you can use shift+ctrl+v and shift+ctrl+c or mouse-right-click then paste and mouse-right-click then copy instead.

After follow all the steps, which will take you sometime to download and setup, I would highly recommend you to follow a tutorials, especially the first one  installing and configuring you ROS environment, in order to make sense of how ROS work, how to use it and some special terms that you will need to known in order to change and modify a code.

The whole tutorials take me just a couple of days to finish and its cover all the fundamentals topics I need for the project.

Note
In case of you can not find how to bring up a terminal -> http://www.psychocats.net/ubuntu/terminal.

Start using ROS!

I would like to make a document of how I implement ROS framework on my robot. Everything I wrote here are working in progress, it's the way I do but not proven, which should be good enough as a guidance to get you up and running faster.


Let's start from what I have in hand.

Hardware


Robot platform : Pioneer3-AT


  • My lab bought this guy without any on-board computer and additional sensors. It does come with low-level controller, called ARCOS, which later we will communicate with it vai RS-232 port. The robot also come with wheel encoder and basic PID velocity control, so at the end of the day we just send our desired speed to ARCOS to make it move.
  • To communicate with ARCOS, Pioneer is shipped with open-source SDK called ARIA which provide an interface for controlling and receiving data from all Pioneers platform.

Software

  • Because the robot didn't come with on-board computer, I will put a computer on top of it. The computer run the following software.
    • Linux Ubuntu : Ubuntu 11.10 (32-bits) - Oneiric Ocelot. It's the latest Ubuntu version at the beginning of this project, at the time of writing this post there is version 12, but that's not matter anyways.
    • ROS :  ROS Electric. We're going to learn a good deal about this ROS!