Category Archives: Linux

Using u-Center to connect to the GPS on Raspberry Pi

u-Center from u-Blox is a graphical interface which can be used to monitor and configure all aspects of the GPS module on a BerryGPS-IMU or BerryGPS-GSM.

u-Center from uBlox
U-Center

 

u-Center only runs on Windows. It can connect over the network to a Raspberry Pi.  This will require us to redirect the serial interface on the Raspberry Pi to a network port using ser2net.

Pi Setup

Do an upt-get update and then install ser2net;

pi@raspberrypi ~ $ sudo apt-get update
pi@raspberrypi ~ $ sudo apt-get install ser2net

Edit the ser2net config file and add the serial port redirect to a network port. We will use network port 6000

pi@raspberrypi ~ $ sudo nano /etc/ser2net.conf

And add this line at the bottom;

6000:raw:600:/dev/serial0:9600 NONE 1STOPBIT 8DATABITS XONXOFF LOCAL -RTSCTS

This is a breakdown of the syntax for the line above;
TCP port : connection type : timeout : serial port : serial port speed : serial options

you can now start ser2net using;

pi@raspberrypi ~ $ sudo ser2net

And you can use the below command to check if it is running by seeing if the port is open and assigned to the ser2net process;

pi@raspberrypi ~ $sudo netstat -ltnp | grep 6000

If it is running, you should see something similar to the output below;

check result of ser2net

Windows PC Setup and Connecting to the GPS module

You can download u-Center from here.

Once installed, open u-Center. You will get the default view as shown below.  No data will be shown as we are not connected to a GPS.

u-Center default view

The next step, is to create a new network connection and connect to the GPS which is connected to our Raspberry Pi. You can create a new connection under the Receiver and then Network connection menus.

u-Center connect to Raspberry Pi
In the new window, enter the IP address of the Raspberry Pi and specify port 6000. This is the port we configured in ser2net on the Raspberry Pi.
u-Center Raspberry Pi Address

This is what the default view looks like when connected and the GPS has a fix.u-Center connected

 

u-Center

Below I will list of the more useful windows/tools within u-Center.
You can also click on the images below for a larger version.

Data View
This window will show you the longitude, latitude, altitude and fix mode. It will also show the HDOP, which is the Horizontal Dilution of Precision.  Lower is better, anything below 1.0 means you have a good signal.

u-Center Data View
u-Center Data View

Ground Track
This window will show you where the satellites are as well as what time.

u-Center Ground Track
u-Center Ground Track

Skye View
Sky view is an excellent tool for analyzing the performance of antennas as well as the conditions of the satellite observation environment.

u-Center Sky View
u-Center Sky View

Deviation Map
This map shows the average of all previously measured positions.

u-Center Deviation Map
u-Center Deviation Map

Continue reading Using u-Center to connect to the GPS on Raspberry Pi

Create a Digital Compass with the Raspberry Pi – Part 1 – “The Basics”

This will be a multipart series on how to use a digital compass(magnetometer) with your Raspberry Pi.

The magnetometer used in these tutorials is a LSM9DS0 which is on a BerryIMU. We will also point out where some of the information can be found in the Datasheet for the LSM9DS0. This will help you understand how the LSM9DS0 works.

The math and logic in this series can also be used with other magnetometers or IMUs.

We will also go over how to do some basic communication on the i2c bus. As well as using SDL to display the compass heading as traditional compass as shown in the video above.

Git repository here
The code can be pulled down to your Raspberry Pi with;

pi@raspberrypi ~ $ git clone https://github.com/ozzmaker/BerryIMU.git

The code for this guide can be found under the compass_tutorial01_basics directory. 

Overview of a Compass

Raspberry Pi Compass
A traditional Magnetic compass (as opposed to a gyroscopic compass) consists of a small, lightweight magnet balanced on a nearly frictionless pivot point. The magnet is generally called a needle. The Earth’s Magnetic field will cause the needle to point to the North Pole.

To be more accurate, the needle points to the Magnetic North. The angle difference between true North and the Magnetic North is called declination. Declination is different in different locations. This angle varies depending on position on the Earth's surface, and changes over time.

The strength of the earth's magnetic field is about 0.5 to 0.6 gauss .

Continue reading Create a Digital Compass with the Raspberry Pi – Part 1 – “The Basics”

How to Control the GPIO on a Raspberry Pi with an IR Remote

In this post I demonstrate how to use an infrared remote to control the GPIO on a Raspberry Pi.

Normally a remote would be used to control a TV card or XMBC, however they also provide a good interface to control the GPIO on a Raspberry Pi.
Adafruit has a Mini Remote and IR sensor which are perfect for this.

IR ReceiverMini Remote

In this example we will use the remote to control a number of LEDs connected to some GPIOs on a Raspberry Pi.

Connect the IR Sensor to the Raspberry Pi

Connecting the IR sensor to a Raspberry Pi is very easy as there are only 3 pins on the sensor, GND, 3v and Output. We will connect the output to GPIO 18. You can choose another pin, just take note of it as you will need to specify this pin when installing LIRC.
We will also connected up three LEDs to GPIOs 23, 24 & 25, and a 270Ω on the GND sound of each LED.

IRwiring2

Here is my setup;

OLED.front823back_LRG

Continue reading How to Control the GPIO on a Raspberry Pi with an IR Remote

Software PWM on a Raspberry Pi

If you want to control the brightness of a LED, the speed of a DC motor or the direction of a servo, you will need PWM.

The video shows PWM being used to control the brightness of some LEDs.

Pulse-width modulation (PWM) is used to control the amount of power supplied to electrical devices, especially to DC motors, servos and LEDs.

PWM is able to achieve this by quickly turning off and on the power to the device. The measurement for this is duty cycle.

Duty cycles describes the proportion of 'on'; a low duty cycle corresponds to low power, because the power is off for most of the time.  A high duty cycle corresponds to high power, because the power is on most of the time.

Duty cycle is expressed in percent, 50% is when the power is on half the time and 100% being fully on.

pwm

Continue reading Software PWM on a Raspberry Pi

Controlling the GPIO on a Raspberry Pi with a Touchscreen

In this post I show how to control the GPIO on a Raspberry Pi using a touchscreen.
This is a follow up on my previous post Programming for a Touchscreen on the Raspberry Pi

The TFT doesn’t come up too well in the above video. The picture below gives a better idea of how it looks. Click to enlarge

Touch Screen button example

Link to the code;
https://github.com/mwilliams03/Pi-Touchscreen-basic.git

In the above code touchbuttons.c creates three buttons on the TFT which will be used to turn on/off three LEDs.

This can easily be changed to add more buttons.
touchbuttons.c also requires WiringPI and needs to be compiled with gcc -g -o buttonExample buttonExample.c -l wiringPi
Continue reading Controlling the GPIO on a Raspberry Pi with a Touchscreen

Programming for a Touchscreen on the Raspberry Pi

To accept input from a touchscreen we have to use the event interface of the Linux input system. We use the ioctl capabilities of the event interface, in addition to the normal read and write calls to get information from the touchscreen. This blog post explains how to use the touchscreen within your own programs using C as well as writing directly to the framebuffer.

Images of my TFT from a previous post;

TFTTFTTFT

Continue reading Programming for a Touchscreen on the Raspberry Pi

PiBBOT V2 – Balancing Robot using a Raspberry Pi

I have spend the last month creating a new version of PiBBOT (Pi Balancing roBOT) , PiBBOT V2.

This version has a sturdier frame and a LCD display. I replaced the 1.8" TFT with a LCD as the TFT was causing delays in the main loop timing. I also added a very slim battery for the Raspberry Pi.

Main components;

    • RGB backlight LCD 20x4 which shows gyro, accelerometer and complimentary filter angle.
    • Volt Meter to view condition of battery used for motors.
    • RF Receiver RF M4 Receiver - 315MHz. Used to tune PID and then control direction.
    • 1x4 Keypad to turn motors on/off and to reset the gyro.
    • Motors; 9.7:1 Metal Gearmotor 25Dx48L mm with 48 CPR Encoder
    • Wheels; Pololu Wheel 90x10mm
    • IMU; BerryIMU – An accelerometer, gyroscope, magnetometer and barometric/altitude sensor
    • Battery for Motors - 7.2V Tenergy 3800mAh Flat NiMH High Power (38A Drain Rate)
    • Battery for Rasperry Pi - Anker Astro Slim2 4500mAh Ultra-Slim Portable External Battery Charger Power Bank

    Continue reading PiBBOT V2 – Balancing Robot using a Raspberry Pi

    Raspberry Pi with a 3.2″ TFT with Touch control

    I have spent the last few weeks working on getting a SainSmart 3.2" TFT with touch control working with my Raspberry Pi and I have had success.

    You can see an update on this project here;
    https://ozzmaker.com/2013/05/27/raspberry-pi-with-a-3-2-tft-with-touch-control-part-2/

    PiScreen TFT Raspberry Pi

    I have currently connected it up with a breadboard, I now need to work on a more permanent solution.

    Download the Kernel that contains the drivers.

    Click on the images for a larger view.

    Graph
    Graph
    Click the image below for a much larger version
    Graph

    My setup;
    M74HC4040B1R
    74HC4094N
    5v to TFT
    3.3v to ICs
    Reset through 10k resistor
    Back light connected to 3.3v

    I start Xwindows with sudo FRAMEBUFFER=/dev/fb1 startx -- -dpi 60

    Thanks to XaLKiDEoS , Notro, drsb and  valdodov.;
    http://www.raspberrypi.org/phpBB3/viewtopic.php?f=64&t=33679
    http://www.valdodov.com/

    Continue reading Raspberry Pi with a 3.2″ TFT with Touch control