New domain and blog

New domain and blog
Please head over to my new domain to view my blog and current projects

Tuesday, 16 April 2013

Raspberry Pi: Direct connection to Windows 7

This is something I have been wanting to try for quite some time but never really found much info on how to do it. Well I sat down the other day to get it done and realised that it is MUCH easier than I expected.

My objective is to directly connect my Raspberry Pi to my laptop using an ethernet cable. In the next few months I am going to be away from a decent internet connection but I still wanted to do some work on my RasPi. So my Google searching started, finished and here is what to do.

The process uses a built-in feature of Windows 7 called Internet Connection Sharing (ICS). In a nutshell, you can use any Windows computer with more than one network connection, WiFi and LAN, and share the connection to other computers. 

Firstly you need to set up the settings on Windows. You need to go to the properties of your disconnected LAN connection and click on the sharing tab. Then check the box to allow other network users to connect through this internet connection.


The tricky thing to set up is the IP address that you are going to give the RasPi. You need to check the TCP/IPv4 settings under the Networking Tab. I picked an IP address and gave my RasPi a static address so that I know what it is when ever I use this connection.

Next you need to power up your Raspberry Pi and connect to it some way. Either use a WiFi connection that is already set up, an ethernet connection to your router or using the serial port on the GPIO.

You then need to set up the IP address by editing the interfaces file.
sudo nano /etc/network/interfaces
Change the part of the file that refers to your eth0 connection to look similar to below. You might have other settings in there like WiFi IP addresses and passwords but just leave those alone.
iface eth0 inet static 
address 192.168.137.184 
netmask 255.255.255.0

Once you have saved the interfaces file, send the shutdown command so that you can change over the connections. Once powered off, directly connect your RasPi ethernet port to your Windows ethernet port. You should be able to use both straight-through and cross-over cables. Now power up the RasPi.

Once booted up, you should be able to log in with Putty to the static IP address that you set above. 

And that is pretty much it. Another cool thing by connecting this way is that you should be able to power your Raspberry Pi from your computer USB port. This makes transport really easy as all you need is an ethernet cable and a USB cable to get up and running. 

Hope this helps and if you have comments or questions, please leave them below and I'll get back to you as soon as I can.

Greg

Monday, 18 March 2013

Suspension Training workout

I got a rip:60 suspension trainer for Christmas last year and have been using it on and off for the last few months. I started out doing the videos, but after a few weeks I hurt my knee running so took a few weeks off. 

Three weeks ago I started again, but this time with my own program. I used the wall chart that comes with the package and just picked a few moves that I wanted to do. I stayed away from squats and exercises that put too much pressure on my knees so concentrated mainly on upper body moves. 

Here is my routine that I have done five days a week for the last four weeks. I can already see results and will change it up next week.

Do a 10 - 15min warm up before completing any exercise.

10 reps each leg Alternating Lunge with Rear Delt Fly


15 reps Fly


10 reps Lat Pull Down


2 sets of 60 sec Plank using suspension trainer to support your feet

10 reps Tricep Extension with Roll Out


10 reps Bicep Curl


15 reps Plank with crunch to Push Up


30 sec Plank using suspension trainer to support your feet

2 sets of 60 sec Reverse Plank with Abduction


15 reps Push Ups


10 reps Hammer Curl


10 reps each side Plank with Oblique Crunch


Repeat from top once more

Balance on each leg for 30 sec with closed eyes

Stretch and cool down

That should take about 45 min so in total with warm up and cool down should be about 60 min.

Greg

Saturday, 16 March 2013

LabVIEW: CLAD certified

I have been working with National Instruments' LabVIEW software and hardware for about 3 years now. Unfortunately I have not been able to do any courses or qualifications through the companies I have worked for so I just learnt and taught myself as I went along.

All that changed after I moved to the UK. I went to a NI symposium and they offered a Certified LabVIEW Associate Developer (CLAD) exam at the end of the symposium for all those that wanted to take it. 

I decided to go for it and make the most of the opportunity given to me. I thought it went well and was quite confident when I left the exam. However, from my experience, that doesn't always mean a good thing.

Well this morning, after waiting a few weeks, I got an email from NI with my CLAD certificate. I passed and am now CLAD certified. 


I have been waiting a long time to get this certification and finally have it.

Thank you to NI who offer such an exam to those willing to work for it and stay after the symposium has ended.

Greg

Tuesday, 12 March 2013

Raspberry Pi: NAS server

I have been wanting to set up my Raspberry Pi as a Network Attached Storage (NAS) drive for quite some time. I eventually got a chance yesterday to give it a go. Unfortunately the Raspberry Pi USB port can't power my external hard drive and I don't have a USB hub at the moment, so I just used a 16GB flash drive.

First you need to format your external drive with NTFS. Then place a file on it. Any file will do. I chose a text document so that I can open it and view it on the Pi. Once you have set up your drive, turn off your RasPi, plug the drive into the USB port and then turn on the RasPi. It is safer to plug the USB in when the RasPi is off because some versions don't have poly fuses on the USB ports.

Once booted up, log in and check to see if the drive is connected.
  • sudo fdisk -l

You can see that my connected drive is right at the bottom. The drive is called sda and because there is only one partition, it is called sda1.

Next you need to create a folder where your drive is going to be mounted into. I called mine myHadrDrive. You also need to give the folder root access so that when you connect to it you are able to read from it and write to it.
  • sudo mkdir /mnt/myHardDrive
  • sudo chmod 0777 myHardDrive
Next you need to mount the hard drive to the folder that has just been created. Open fstab and add the following line to the bottom of the file where it reflects your setup.
  • sudo nano /etc/fstab

Mount the drive
  • sudo mount -a
Now we need to install and set up the Samba server. This will allow a windows machine to connect to the RasPi over the network. Start by installing the following packages using apt-get.
  • sudo apt-get install samba
  • sudo apt-get install samba-common-bin
  • sudo apt-get install ntfs-config
  • sudo apt-get install ntfs-3g
Once all of those packages are installed, edit the Samba configuration file. It took me a while to get this right but with the help of this video, I managed to get it. 
  • sudo nano /etc/samba/smb.conf
Replace the entire file with the following:
#======================= Global Settings =======================
[global]
workgroup = WORKGROUP
server string = raspnas server
netbios name = raspnas
dns proxy = no
### Logging
log file = /var/log/samba/log.%m
max log size = 1000
syslog = 0
panic action = /usr/share/samba/panic-action %d
### Authentication
security = user
map to guest = pi
#======================= Sharered Folders =======================
[media]
path = /mnt/myHardDrive
guest ok = yes
guest account = ftp
browseable = yes
read only = no
create mask = 0777
directory mask = 0777
writeable = yes
admin users = everyone
#==========================================================

A few points to note:
  • WORKGROUP is the workgroup that the drive will be connected to
  • raspnas is the name of he drive on the network
  • path is the folder that you set up earlier
  • Change the file according to your setup
Lastly you need to restart the Samba service and add the user to the Samba database
  • sudo service samba restart
  • sudo smbpasswd -a pi
Now your Samba server is set up. You still need to do one last thing. You need to make sure that the drive gets connected at startup.
  • sudo apt-get install autofs
Add the following line to the bottom of the config file
  • sudo nano /etc/auto.master

Reboot your RasPi and then you should be able to log on to the shared drive using your Windows machine.

I hope this has helped anyone who was stuck. If you still have any problems leave a message in the comments and I'll try help as best I can.

Greg

Thursday, 28 February 2013

C2000 LaunchPad Piccolo serial comms

So after a few days and many frustrating hours of reading, hacking and playing around, I managed to get two way serial communications working. I am using the USB connection through the FTDI USB-UART converter.

Initially I tried to use the examples but for some reason they just didn't work as they were supposed to. I wanted to then put back the demo application that the C2000 LaunchPad ships with because I knew that that worked with Putty. It took me ages to find the source code which was very frustrating. If you are interested, it is located in TI Resource Explorer -> controlSUITE -> English -> Development Tools -> C2000 LaunchPad -> LAUNCHXL-F28027 -> C2000 LaunchPad Demo.

Once I programmed my LaunchPad with the demo program and confirmed that everything works, I worked my way through it making changes. After a few attempts and many changes, I got it working so that the program can print a string to the terminal, and can also echo back and characters that are sent to the LaunchPad from the terminal.


First impressions of the C2000 LaunchPad:
  • My first impression of using the Piccolo was one of frustration. The examples are not as clear as the MSP430 LaunchPad and the projects are much more tricky to create. I still have yet to create a project from scratch. So far I have just copied and pasted projects and then added my own code.
  • The LED's are also wired in such a way that you have to drive the cathode low to turn the LED on. Therefore in code, setting the pin high turns the LED off and setting the pin low turns the LED on. Not a big deal once you know about this, but took me a while to figure out why my LED's were not behaving themselves as I expected them to.
  • Battling to find the demo source code was also a challenge, but once I got it, it was very well commented and quite self explanatory.
Overall my first impressions are a bit mixed, but the more I explore, the more I am understanding how things are laid out. This is making it clearer.  

My next step for my project is to get the SPI working, which I will start tackling tomorrow. 

If you want to get a copy of my code, you can download it here.

I hope this helped clear the way for you.

Greg

Tuesday, 26 February 2013

TI C2000 LaunchPad unboxing

Yesterday I received my TI C2000 LaunchPad from Element14 for a road test. I have been working with the MSP430 LaunchPad for a few weeks now and am really enjoying what it can do. I am therefore really excited about getting into the C2000.


I plugged it in and got the default program up and running pretty quickly. With it connected to a terminal, you can see the temperature change and get logged. Next I wanted to get the standard flashing LED program running to get a basic feel for the development board.

I assumed that the two development boards, MSP430 and C2000, would be similar, but I was wrong. There is quite a difference in setting up the device and getting it running. I eventually got a simple flashing LED program running.

The example projects are also set up quite differently and it takes a bit of time to figure out how things are laid out.

To get going, I am going to go through the LaunchPad schematic and also the F28027 device datasheet. Once I know what is connected to which port and peripheral, then I can get going properly.

My plan is the following:
  • Get the flashing LED's working - DONE
  • Get serial communications working. LaunchPad to Putty
  • Get SPI working
  • Connect up CC1101 433MHz module to get RF communications working
  • Connect to RaspberryPi USB port and use as a port expander and RF master
For now that is what I plan to do. I will log my progress here as I manage to get each part working. For now I better get reading and start understanding the development board that I have in front of me.

Greg

Wednesday, 12 December 2012

Raspberry Pi meets TI LaunchPad MSP430

A few weeks ago I got a TI LaunchPad. With the help of a few tutorials I managed to get the basic input, output and UART working. As most of the examples that I could find are for CCS, I decided to go that route instead of IAR.

My next step was to get my LaunchPad working with my Raspberry Pi via the USB port. After a bit of playing around and installing a few programs, I managed to get it to work. Below is how I got a program  written, compiled and programmed onto the LaunchPad from the Raspberry Pi.

First you have to install a few programs with apt-get.
$sudo apt-get install binutils-msp430
$sudo apt-get install gcc-msp430

$sudo apt-get install msp430mcu

$sudo apt-get install mspdebug

$sudo apt-get install msp430-libc
You might have to run
$sudo apt-get update
before installing the modules.

Next run mspdebug to make sure that there are no errors. If there are no errors type exit to close the debugger.
$sudo mspdebug rf2500
Now that you have everything installed, we need to create the program. I use nano text editor to write my program.
$sudo nano button_ISR.c

This program uses the two LED's and one push button on the LaunchPad. When the button is pressed, an interrupt is generated and then the LED's are toggled.

Close nano saving the changes.

The program then needs to be compiled.
$sudo msp430-gcc -mmcu=msp430g2553 -g -o BUTTON_ISR button_ISR.c
The program should compile without any errors and now you are able to run the debugger.
$sudo mspdebug rf2500
Now program the device
prog BUTTON_ISR
and run the program
run
CTRL+c will stop the program running and exit will close the debugger.

In the next post I will show you how to communicate between the TI LaunchPad and Raspberry Pi via hardware UART and the USB connection.

Greg

Monday, 10 December 2012

Raspberry Pi: Edimax EW-7811UN WiFi Dongle

I recently bought myself an Edimax Wifi dongle to use with my Raspberry Pi. My router is hidden away so I got tired of running a network cable to my Raspberry Pi. The Edimax WiFi dongle was ideal as it is really inexpensive and very small.

It took a while for me to get it set up correctly but eventually I got there. To set up the WiFi connection, you either need a ethernet cable plugged into your Raspberry Pi or you need to connect via the serial port. I connected via the serial port with a FTDI USB to UART converter as this made it much easier to know when the network was connected. 

First of all plug the dongle into one of the USB ports and then reboot.I have not tested this in a USB hub but I am sure it will work the same. To make sure that the dongle has been started, run 
ifconfig
and make sure that wlan0 can be seen.


The next step is to see if your Raspberry Pi can see your wireless network. Run the following command and look for your network.
sudo iwlist wlan0 scan

Under 'Cell 01' I can see my network. Take not of your ESSID and you will also need your network password.

Once you have established that your Raspberry Pi can see your wireless network, you will need to edit the network interfaces file.
sudo nano /etc/network/interfaces
You will need to add the following:
  auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-ssid 'your ESSID'
wpa-psk 'your password'
Your interfaces file should now look like this. Note that I have set a static IP address so if you still use DHCP then you will not need the static IP address settings like I have.


Restart your network connection by running
sudo /etc/init.d.networking restart
and then run
ifconfig
and you should notice an IP address assigned to wlan0.

Now reboot your Raspberry Pi to make sure that everything is working in order.
sudo reboot
If your connection is up and running after the reboot, then you are all set to go wireless.

Greg

Monday, 29 October 2012

Raspberry PI: Bottlepy and Twitter Bootstrap

I have been using my Raspberry Pi for the last few months quite a lot. I am currently working on a temperature/environment monitor that logs temperature, using a DS18B20, and light conditions using an optical sensor. I also have two LED's and two buttons to test basic input and output.

I am developing the application in python using the BottlePy framework. I chose the BottlePy framework as it is a single file that you add, it is very small and it works with Python 3. To control my GPIO's, I am using the Quick2Wire library. To display the temperature data, I am using Google Charts.


This is a picture of the main temperature logging page so far.

However, the purpose of this post is to show how to integrate BottlePy and Bootstrap by Twitter. According to their website, Bootstrap is a "Sleek, intuitive, and powerful front-end framework for faster and easier web development."

To display this, I am going to use my GPIO code which reads buttons and turns on LED's through a webpage. 


To start off we need python file that will run as the server. Below is a snippet of code. The @route shows that this particular function will be run when /gpio us entered into the browser. The webpage is broken up into four sections. The first controls LED 1, the second controls LED 2, the third gets the state of both buttons and light sensor and then the fourth runs a .c file to flash the LED's.


Now we need to have a look at the html code that creates the webpage. By default, Bootstrap works with the user downloading the .css and .js file. These are then statically linked to the html code. When using the BottlePy framework, I haven't found a way to return a webpage template, AND a static file. Therefore I have found a link where the .css and .js files have been hosted. By using these links, you only have access to the default settings, but they are enough for what I am wanting to do.


You have to link to the .js and .css file and then by using certain classes that have been defined and explained on the Bootstrap website, you can get nice looking buttons, navigation bars, and tables. They have many options to use but these are the three that I used here for my site. 

When a button on the website is pressed, it sends the value back to the python function and the python code will perform the task. With the Flash LED button, the python code calls a .c file that has been compiled and runs when called. 

When requesting the button state, I return hex formatted colours to show the state of the buttons. These the colour in the table. 


The red shows that Button 1 has been pressed, the Green shows that Button 2 is not pressed and the Blue shows that the light level is currently light.

There are many different elements that can be added by using the Bootstrap framework. The documentation is really clear and easy to follow with many examples. 

If you get stuck or need some more explanations give me a shout.

Greg

Embedding Gist code into Blogger

I have been playing with my Raspberry Pi and Linux for a few weeks now. Most of the example code has been published on GitHub so I thought I'd give it a go and see what it's all about.

At first I tried to add a repository and then the code snippets. That didn't seem to work as I liked so had a quick look around and saw that you can add a Gist and embed that a lot better. You are also able to link to a raw piece of code. This will hopefully come in handy as I have an idea on how to use this. If it works I will cover it in another post.

All you need to do is create a GitHub account and add a new Gist. Save the Gist get the embedded link.

When you are writing your post, switch to HTML view and paste the script where you want it to appear in your post. You can then switch back to normal view to finish writing the post.

That's about it really. Pretty simple and quick to add code. This is much easier than some of the other methods that I have seen where you have to edit the HTML code of the template with custom java script code.

Greg