Thursday, June 12, 2014

Rocket Track - Open source GPS Tracker for Smartphones


Here is an example project with lots of good information.  GPS tracker for finding rockets or other objects.

Xbee communication to object, with GPS on the sending end.  Coupled to a cell phone via bluetooth to display location information on an android phone map display.

http://www.rocketryforum.com/showthread.php?53120-Rocket-Track-Open-Source-GPS-Tracker-for-Smartphones

notes on converting vob to other formats

once you have decoded VOB files (Not subject of these notes) or you recorded your own (which I do on a Magnavox DVD / VCR) they are huge mpeg1 files.  This is just a note to self on how to convert to avi files, with much less gas.  It produces a 350mb or so / hour of play time avi, which is the desirable archive for my recordings.

once you have identified each block of programming vob's cat them together into a single vob.  There doesn't seem to be a problem with that.  Other formats have to be called out in the ffmpeg or avconv command line, but prep for vob files is to just cat them into a bunch of files.

On and example file, here are the VOB files

VTS_01_1.VOB
VTS_01_2.VOB
VTS_01_3.VOB
VTS_01_4.VOB

cat VTS_01_*.VOB > videofile.vob

once you have your intermediate vob, convert it to an avi container as below.

avconv -i videofile.vob -f avi -c:v mpeg4 -b:v 800k -g 300 -bf 2 -c:a ac3 -b:a 128k  videofile.avi

The resulting playback works with the bsplayer (open source codecs) and apple mac playback.  It seems to have keyframe problems playing with windows media player.  but in that case for my purposes, I don't care.  I can use vlc anywhere there is windows.

Stack exchange posting with some more info

http://unix.stackexchange.com/questions/106374/how-to-convert-a-vob-file-to-avi

Ubuntu forum posting

http://ubuntuforums.org/showthread.php?t=1564791

Friday, May 30, 2014

Sunday, May 25, 2014

Xbee Wireless Sensor Gateway with Raspberry Pi


save

http://tinajalabs.wordpress.com/2012/09/02/raspberry-pi-as-an-xbee-wireless-sensor-network-gateway/


Gateway and useful gizmo.




Raspberry Pi as an Xbee Wireless Sensor Network Gateway

Notes about Raspberry Pi, an ARM based pc about the size of a deck of cards which costs $35. I might use it as a replacement for the Asus WL520 GU wifi modems I’ve been using as an Xbee WSN Gateway.

General References

OS

I started out with the 4G SD Card from Newark that was pre-loaded with wheezy-debian. Now I’m using the distro from Adafruit called Occidentalis v0.2.  It includes ssh and other features that makes it easier to confugure.
Copy the image to a 4G SD Card using Win32DiskImager.  Basically you download an OS image to a windows machine and copy it to an SD Card.  When using WinDiskImager, pay close attention to your read/write actions because it’s possible to overwite the wrong drive.
Before selecting an SD Card, look at the list in Verified Peripherals.  Not all SD Cards work the same, and I spent a lot of time trying to launch the OS even though the image copy was successful.  If you get to the point where you’ve successfully copied the image but it won’t boot up, cut your losses and try another SD Card.
  • login as: pi, password: raspberry
  • I set up a root account and did most of the installation as root

Expanding the partition on the sccard

Once installed, expand the SD Card partition to fill the 4G memory space. The image on the 4G sdcard is 1.8G. This describes how to expand the partition to fill the entire 4G.

SSH

Set up SSH so you can access the Raspberry Pi from a terminal program of via Putty and/or WinSCP.
ssh-keygen -t rsa -C "your_email@youremail.com"

XBee connection

I used the CISECO daughter board kit which costs about $6 which has a GPIO connector and a place to hook up an xbee to the serial port on the GPIO.  It derives the 3.3V from the GPIO and it includes an array of through holes for misc prototyping.
  • XBee Radio PCB daughter board- by CISECO – basically a breakout board for the GPIO connections with access to the serial port and 3.3V.
  • Getting started with GPIO and PythonThis is the first of two articles showing basic GPIO on the Raspberry-Pi using the prototype area of the Slice of Pi. This covers basic details on the GPIO pins, setting up a Python library to allow access to the GPIO. There is an example circuit to build on the Slice and some code to get the outputs working. This was originally a blog post on Matts blog at http://lwk.mjhosting.co.uk
pi_001th.jpg
Raspberry Pi with XBee daughterboard, Slice of Pi
Raspberry Pi with XBee daughterboard, Slice of Pi
On the Adafruit distro, Occidentalis v0.2, I was having some issues with reading the serial port in my python code.  I kept getting erros related to the serial port being in use.  Some research got me to this article on the RaspberryPi.org site and this article from Clayton’s Domain.  I edited a file, /boot/cmdline.txt, and this is what it came down to (all on one line):
/boot/cmdline.txt
dwc_otg.lpm_enable=0 rpitestmode=1 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait

Install Apache on Raspberry Pi

Eventually I will want to set up a web interface to allow users to edit the gateway config items, like the network protocol and to manage the various sensors, python scripts, etc.  For now, I’m just going to manage it it by ssh command line.
  • http://tinkernut.com/wiki/page/Episode_320
  • Webmin- “Webmin is a web-based interface for system administration for Unix. Using any modern web browser, you can setup user accounts, Apache, DNS, file sharing and much more. Webmin removes the need to manually edit Unix configuration files like /etc/passwd, and lets you manage a system from the console or remotely.”
  • Raspcontrol- PHP based Dashboard application. More about status then configuring.

Installing Python components

Rasberry Pi, default linux install, has python already installed.
I needed these modules to allow me to access various web services like Cosm (pachube), Thing Speak, Open.Sen.se, and my own SOAP based service that I wrote in C#.

pyserial

We need some extra libs to run the sensor programs.
Check if python is installed and what version is installed
python -V
Change directory:
cd /home/tinaja/downloads/
WGet the file then unpack it:
wget http://sourceforge.net/projects/pyserial/files/pyserial/2.5/pyserial-2.5.tar.gz/download
tar -zxvf pyserial-2.5.tar.gz

cd pyserial-2.5
python setup.py install

simplejson 2.6.1

simplejson 2.6.1 is compatible with python 2.5.
Change directory:
cd /home/tinaja/downloads/
WGet the file then unpack it:
wget http://pypi.python.org/packages/source/s/simplejson/simplejson-2.6.1.tar.gz
tar -zxvf simplejson-2.6.1.tar.gz

cd simplejson-2.6.1
python setup.py install

suds

The suds libs provide services for SOAP calls.
Need to install python’s setup tools:
apt-get install python-setuptools
Change directory:
cd /home/tinaja/downloads/

wget https://fedorahosted.org/releases/s/u/suds/python-suds-0.4.tar.gz
tar -zxvf python-suds-0.4.tar.gz

cd python-suds-0.4/
python setup.py install

eeml

Used by Cosm (pachube)
http://pypi.python.org/pypi/python-eeml/1.1.0
? git clone git://github.com/petervizi/python-eeml.git

# cd /home/tinaja/downloads/
# wget http://pypi.python.org/packages/source/p/python-eeml/python-eeml-1.2.0.tar.gz
# older version - wget http://pypi.python.org/packages/any/p/python-eeml/python-eeml-1.1.0.linux-i686.tar.gz
# tar python-eeml-1.2.0.tar.gz
# python setup.py install

Code

I’ve loaded the python code I’m using on GitHub:
https://github.com/TinajaLabs/gateway_raspi

Wifi

The Raspberry Pi can be wifi enabled with a USB based wifi device. The main concern would be with power consumption; the raspberry pi runs off of a 5V (currently 700mA) supply (like a cell phone charger) and a wifi device might strain the load.
For now (8.26.2012) the wired ethernet configuration works great.  It can just plug into a IP provider modem.

To change the boot-up text

Did this to brand the OS as one I set up.  Only for show…
edit /etc/moto.tail
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.

Type 'startx' to launch a graphical session

This version, from Adafruit's Occidentalis v0.2, set up by:
 _____ _              _         _          _         
|_   _(_)_ __   __ _ (_) __ _  | |    __ _| |__  ___ 
  | | | | '_ \ / _` || |/ _` | | |   / _` | '_ \/ __|
  | | | | | | | (_| || | (_| | | |__| (_| | |_) \__ \
  |_| |_|_| |_|\__,_|/ |\__,_| |_____\__,_|_.__/|___/
                   |__/ TinajaLabs.com, Summer 2012
-----------------------------------------------------

To set a program to start at boot-up

To automatically run the main python script, allsensors.py, when the computer starts…
Edit /etc/rc.local and add the python line shown below:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi

# add this for Tinaja Labs sensor tracking
python /home/tinaja/allsensors.py &

exit 0

To set up Tomcat Server

At some point I might want to set up a Tomcat server and use it with some Java apps.  Later.

Java

To watch the message log file

This allows you to see the system messages generated by the script as it sends various sensor readings to the web services.
cd /var/log/
tail -f messages

To kill the Tinaja python script

Look for the process id of the python script with this command:
ps aux # for a full list
ps aux | grep python  # to see only python processes
Take note of the process id number and issue this command:
kill 9999 # where 9999 is the process id number
That’s all I have for now, hope you found something useful here.

**********************************************

another example page

http://www.desert-home.com/2013/09/raspberry-pi-and-xbee.html


I used pip to install xbee and got version 2.1.0 the command was: sudo pip install xbee Then you can use pip to tell you where it wound up. Once you get it installed, you can just import it and start using it.

promiscuous mode monitor:

http://www.desert-home.com/2012/10/monitoring-my-xbee-network.html

**********************************

Another Xbee python tool:  Skinner

http://jeffskinnerbox.wordpress.com/2012/12/22/selecting-xbee-radios-and-supporting-softwaretools/

**********************************

Earlier xbee effort with breadboard buildup for Xbee

http://lookmanowire.blogspot.com/2012/07/raspberry-pi-and-xbee.html

   corollary, enabling Raspberry Pi for 



Tuesday, May 13, 2014

Arduino Mega 2650 pin mapping

Arduino Mega 2650 pin mapping

Arduino Mega 2560 PIN diagram
The source SVG file is also available for download: PinMapping2560.zip
Arduino Mega 2560 PIN mapping table
Pin NumberPin NameMapped Pin Name
1PG5 ( OC0B )Digital pin 4 (PWM)
2PE0 ( RXD0/PCINT8 )Digital pin 0 (RX0)
3PE1 ( TXD0 )Digital pin 1 (TX0)
4PE2 ( XCK0/AIN0 ) 
5PE3 ( OC3A/AIN1 )Digital pin 5 (PWM)
6PE4 ( OC3B/INT4 )Digital pin 2 (PWM)
7PE5 ( OC3C/INT5 )Digital pin 3 (PWM)
8PE6 ( T3/INT6 ) 
9PE7 ( CLKO/ICP3/INT7 ) 
10VCCVCC
11GNDGND
12PH0 ( RXD2 )Digital pin 17 (RX2)
13PH1 ( TXD2 )Digital pin 16 (TX2)
14PH2 ( XCK2 ) 
15PH3 ( OC4A )Digital pin 6 (PWM)
16PH4 ( OC4B )Digital pin 7 (PWM)
17PH5 ( OC4C )Digital pin 8 (PWM)
18PH6 ( OC2B )Digital pin 9 (PWM)
19PB0 ( SS/PCINT0 )Digital pin 53 (SS)
20PB1 ( SCK/PCINT1 )Digital pin 52 (SCK)
21PB2 ( MOSI/PCINT2 )Digital pin 51 (MOSI)
22PB3 ( MISO/PCINT3 )Digital pin 50 (MISO)
23PB4 ( OC2A/PCINT4 )Digital pin 10 (PWM)
24PB5 ( OC1A/PCINT5 )Digital pin 11 (PWM)
25PB6 ( OC1B/PCINT6 )Digital pin 12 (PWM)
26PB7 ( OC0A/OC1C/PCINT7 )Digital pin 13 (PWM)
27PH7 ( T4 ) 
28PG3 ( TOSC2 ) 
29PG4 ( TOSC1 ) 
30RESETRESET
31VCCVCC
32GNDGND
33XTAL2XTAL2
34XTAL1XTAL1
35PL0 ( ICP4 )Digital pin 49
36PL1 ( ICP5 )Digital pin 48
37PL2 ( T5 )Digital pin 47
38PL3 ( OC5A )Digital pin 46 (PWM)
39PL4 ( OC5B )Digital pin 45 (PWM)
40PL5 ( OC5C )Digital pin 44 (PWM)
41PL6Digital pin 43
42PL7Digital pin 42
43PD0 ( SCL/INT0 )Digital pin 21 (SCL)
44PD1 ( SDA/INT1 )Digital pin 20 (SDA)
45PD2 ( RXDI/INT2 )Digital pin 19 (RX1)
46PD3 ( TXD1/INT3 )Digital pin 18 (TX1)
47PD4 ( ICP1 ) 
48PD5 ( XCK1 ) 
49PD6 ( T1 ) 
50PD7 ( T0 )Digital pin 38
51PG0 ( WR )Digital pin 41
52PG1 ( RD )Digital pin 40
53PC0 ( A8 )Digital pin 37
54PC1 ( A9 )Digital pin 36
55PC2 ( A10 )Digital pin 35
56PC3 ( A11 )Digital pin 34
57PC4 ( A12 )Digital pin 33
58PC5 ( A13 )Digital pin 32
59PC6 ( A14 )Digital pin 31
60PC7 ( A15 )Digital pin 30
61VCCVCC
62GNDGND
63PJ0 ( RXD3/PCINT9 )Digital pin 15 (RX3)
64PJ1 ( TXD3/PCINT10 )Digital pin 14 (TX3)
65PJ2 ( XCK3/PCINT11 ) 
66PJ3 ( PCINT12 ) 
67PJ4 ( PCINT13 ) 
68PJ5 ( PCINT14 ) 
69PJ6 ( PCINT 15 ) 
70PG2 ( ALE )Digital pin 39
71PA7 ( AD7 )Digital pin 29
72PA6 ( AD6 )Digital pin 28
73PA5 ( AD5 )Digital pin 27
74PA4 ( AD4 )Digital pin 26
75PA3 ( AD3 )Digital pin 25
76PA2 ( AD2 )Digital pin 24
77PA1 ( AD1 )Digital pin 23
78PA0 ( AD0 )Digital pin 22
79PJ7 
80VCCVCC
81GNDGND
82PK7 ( ADC15/PCINT23 )Analog pin 15
83PK6 ( ADC14/PCINT22 )Analog pin 14
84PK5 ( ADC13/PCINT21 )Analog pin 13
85PK4 ( ADC12/PCINT20 )Analog pin 12
86PK3 ( ADC11/PCINT19 )Analog pin 11
87PK2 ( ADC10/PCINT18 )Analog pin 10
88PK1 ( ADC9/PCINT17 )Analog pin 9
89PK0 ( ADC8/PCINT16 )Analog pin 8
90PF7 ( ADC7 )Analog pin 7
91PF6 ( ADC6 )Analog pin 6
92PF5 ( ADC5/TMS )Analog pin 5
93PF4 ( ADC4/TMK )Analog pin 4
94PF3 ( ADC3 )Analog pin 3
95PF2 ( ADC2 )Analog pin 2
96PF1 ( ADC1 )Analog pin 1
97PF0 ( ADC0 )Analog pin 0
98AREFAnalog Reference
99GNDGND
100AVCCVCC

Friday, April 18, 2014

pan / tilt unit for pi

This can be done with different servos, etc, from scratch, but this is a nice unit to have as a starting point.

lifted from the following blog entry:

http://blog.dawnrobotics.co.uk/2013/10/using-the-dagu-pantilt-kit-with-the-raspberry-pi/

Using the Dagu Pan/Tilt Kit with the Raspberry Pi

The Pan/Tilt kit that we sell, developed by Dagu with the guys over at Let’s Make Robots, is a great way to mount mobile sensors on your robotic projects. In this tutorial we look at how you can control the Pan/Tilt kit with a Raspberry Pi and the Python programming language.


Required Materials and Equipment

Assembly

In order to control the servos of the pan/tilt kit with the Pi, we need to provide the servos with power, and connect their signal lines to GPIO pins on the Pi. Nearly all RC servos have the same wiring layout, although the colours may vary slightly. On the pan/tilt servos, the red (middle) wire is Vcc, the brown wire is Ground and the orange wire is the signal wire.
Connect the servos to the Pi as shown in the circuit diagram below. To begin with, we’d recommend that you get the servos working before you fully assemble the Pan/Tilt kit, as this way you can work out where the centre points of the servos are.
Circuit Diagram
Circuit Diagram – Made using Fritzing
 
External Servo Power
External Servo Power – Diagram made using Fritzing
As the the servos in the Dagu pan/tilt kit don’t require much current, we can power them from the 5V line of the Pi. If you’d prefer to power them from another power supply, or if you’re using different servos that require more current, or a higher voltage, then you can modify the circuit, as shown in this image.

Understanding Servo Motors

Unlike standard DC electric motors, which turn continuously at a given speed, servo motors contain control circuitry which is constantly trying to drive the servo motor to a set angle. Most servo motors are given their target angle by sending a Pulse Width Modulated (PWM) signal along their signal wire. A PWM signal consists of a pulse that repeats at a fixed frequency (usually close to 50Hz for a servo motor), the width of the pulse determines the angle that that we want the servo to move to.
Most servos will be centred with a pulse width of approximately 1500μs, and then turn left or right with smaller or bigger pulse widths. The minimum and maximum allowable pulse widths vary from servo to servo but are usually close to 800μs and 2200μs respectively. You should avoid trying to move a servo beyond its minimum and maximum limits, as this can damage the servo.

Controlling the Pan/Tilt Kit with Python

Once you’ve assembled the circuit, you can control the servos using this Python script. This script requires the RPIO Python library, which can be installed with the following steps
sudo apt-get install python-dev python-pip
sudo pip install RPIO
To use the script run
sudo python py_pan_tilt_control.py
The script will then sit in a loop, waiting for one of 3 commands. A ‘p’ will move the pan servo, ‘t’ will move the tilt servo, and ‘e’ will run an exploration animation, scanning the pan/tilt head back and forth. You can specify either an angle in degrees, or a pulse width in μs for the ‘p’ and ‘t’ commands by putting a number straight after them (no space). The program treats any number less than 500 as an angle in degrees, and all other numbers and a pulse width. As an example
: p90 - Will move the pan servo to 90 degrees
: p2000 - Will set the pan servo's pulse width to 2000μs
: t50 - Will set the tilt servo to 50 degrees
: e - Will the start the exploration animation
The script is a bit too long to explain in detail, but the important bit occurs on lines 144 to 151
?
142
143
144
145
146
147
148
149
150
151
#-----------------------------------------------------------
# Create ServoPWM instances to control the servos
panServoPWM = ServoPWM( PAN_PWM_PIN,
    minAnglePulseWidthPair=( 45.0, 1850 ),
    midAnglePulseWidthPair=( 90.0, 1400 ),
    maxAnglePulseWidthPair=( 135.0, 1000.0 ) )
tiltServoPWM = ServoPWM( TILT_PWM_PIN,
    minAnglePulseWidthPair=( 45.0, 1850 ),
    midAnglePulseWidthPair=( 90.0, 1500 ),
    maxAnglePulseWidthPair=( 180.0, 500.0 ) )
This allows you to specify 3 ( angle, pulse width ) pairs for each servo, that tell the script which pulse width corresponds to each angle. The script can then work out the pulse widths to use for other angles by using linear interpolation. The precise pulse widths will vary from servo to servo, so you should experiment with different pulse widths to get your servos turning accurately, and then adjust the ( angle, pulse width ) pairs accordingly.
Once you have your servo motors turning accurately, you can then finish assembling your pan/tilt kit. This approach takes much less time than hurriedly assembling the pan/tilt kit when you first get it, and then having to take it apart again to get it moving accurately, which was our initial approach. :)
In order to hold our pan/tilt kit steady as it moved, we mounted the complete circuit onto a bit of foamboard.
Assembled Circuit
Assembled Circuit

Taking Things Further

Pan/Tilt Kit with Camera
With the pan/tilt kit up and running, you can now mount sensors on it, and give them a much wider field of view than they would have if they were just mounted statically. The obvious sensor to mount for the Raspberry Pi is the camera, and we’ll hopefully have a look at using the camera with the pan/tilt kit in a future post.


Thursday, April 17, 2014

Two interesting bits to look at, omxplayer and fm transmission direct from clocks on Pi board


The Pi board can be set up to do FM broadcasts and an example is here:

http://makezine.com/projects/raspberry-pirate-radio/

Another article mentioned a media player that can be used when on the Pi in text mode, omxplayer

Also here is essentially an Arduino Uno which lives on the top of a Pi GPIO.

https://www.youtube.com/watch?v=GBeTOGnuUMM

board purchase / support site is here:

http://www.dawnrobotics.co.uk/pi-co-op-raspberry-pi-arduino-add-on-board/

£16.99, obviously from UK.