Posted on Leave a comment

Raspberry Pi Timelapse Video Generator Script & Full Script Pack Download

To cap off the series of scripts for doing easy timelapse video on the Raspberry Pi, here’s a script to generate a H.264 video from the images.

#!/bin/bash
INPUTFOLDER=$1
INPUTNAME=$2
OUTPUTNAME=$3

if [ -z $1 ]
    then
    	echo "Raspberry Pi Timelapse Video Generator Script v1.0"
		echo "2015 Ben Thomson 2E0GXE"
		echo "This script will take an image folder created by the timelapse script & convert it into H.264 Video"
		echo "This script expects some options in the following format:"
		echo "./makevid.sh <Folder> <File Prefix> <Output Video File Name>"
		echo "<Folder>"
		echo "The folder name with all the images"
		echo "<File Prefix>"
		echo "The file prefix before the frame number. Do not include the underscore before frame number."
		echo "<Output Video File Name>"
		echo "The output file name. The .mp4 file extension will be added by the script."
		echo "Running this script on the Raspberry Pi itself is likely to be very slow. Recommend running on a fast"
		echo "PC with a multicore CPU for high framerate."
		exit 0
fi

avconv -r 10 -i ./$INPUTFOLDER/"$INPUTNAME"_%d.jpg -r 10 -vcodec libx264 -crf 20 -g 15 $OUTPUTNAME.mp4

echo $INPUTNAME
echo $INPUTFOLDER
echo $OUTPUTNAME

This should be run on a powerful PC rather than the Pi – generating video on the Pi itself is likely to be very slow indeed.

I have also done a quick update to the timelapse generator script to generate images of the correct size. This helps save disk space & the video generation doesn’t have to resize the images first, saving CPU cycles.

#!/bin/bash

INPUTFILE="$1"
INPUTFILE+="_%d"
FRAME_INTERVAL="$2"
FRAME_INTERVAL_MIN="1250"
RUNTIME="2073600000"
DATE=$(date +"%T_%m-%d-%y")
if [ -z $1 ]
    then
		echo "Raspberry Pi Timelapse Script v1.2"
		echo "2015 Ben Thomson 2E0GXE"
		echo "Images will be taken in 1920x1080 format for transcoding into video."
		echo "This script expects some options in the following format:"
		echo "./timelapse.sh <File Prefix> <Frame Interval>"
		echo "<File Prefix> The script will prepend this name to every image as a unique capture session identifier."
		echo "A sequential number is appended to the end of the filename for frame identification."
		echo "<Frame Interval> This is the interval between frames, in milliseconds. Minimum 1250."
		echo "This minimum is required to retain stability & prevent dropped frames."
		echo "Every time the program is started, a new folder with the current date & time is created for the images."
		exit 0
fi
if [ $FRAME_INTERVAL -lt $FRAME_INTERVAL_MIN ]
	then
		echo Frame Interval Too Low!
		echo This will cause dropped frames! Exiting!
		exit 0
fi

mkdir -p ./$DATE-$1
echo Image Folder $DATE-$1 Created
echo Image Capture Interval $FRAME_INTERVAL ms 
echo Starting Timelapse Capture... CTRL+C To Exit...
raspistill -k -n -ex auto -awb auto -mm average -w 1920 -h 1080 -o ./$DATE-$1/$INPUTFILE.jpg -tl $FRAME_INTERVAL -t $RUNTIME

echo Timelapse Complete!
echo File Prefix: $INPUTFILE
echo Frame Interval: $FRAME_INTERVAL ms
echo Folder Name: $DATE-$1

[download id=”5595″]

73s for now!

Posted on 1 Comment

SainSmart Frequency Meter

Thanks to Lewis, M3HHY for lending me this one 🙂

Here’s a quick look at a Sainsmart frequency counter module. These are useful little gadgets, showing the locked frequency on a small LCD display.

It’s built around an ATMega328 microcontroller (µC), and an MB501L Prescaler IC. The circuit for this is very simple, and is easily traced out from the board.

Frequency Counter
Frequency Counter

Here’s the back of the board, with the µC on the left & the prescaler IC on the right. This uses a rather novel method for calibration, which is the trimmer capacitor next to the crystal. This trimmer varies the frequency of the µC’s oscillator, affecting the calibration.

Input protection is provided by a pair of 1N4148 diodes in inverse parallel. These will clamp the input to +/-1v.
The prescaler IC is set to 1/64 divide ratio. This means that for an input frequency of 433MHz, it will output a frequency of 6.765625MHz to the µC.

The software in the µC will then calculate the input frequency from this intermediate frequency. This is done because the ATMega controllers aren’t very cabable of measuring such high frequencies.

The calculated frequency is then displayed on the LCD. This is a standard HD44780 display module.

LCD
LCD

Power is provided by a 9v PP3 battery, which is then regulated down by a standard LM7805 linear regulator.

Readout
Readout

I’ve found it’s not very accurate at all at the lower frequencies, when I fed it 40MHz from a signal generator it displayed a frequency of around 74MHz. This is probably due to the prescaler & the software not being configured for such a low input. In the case for 40MHz input the scaled frequency would have been 625kHz.

 

Posted on Leave a comment

Water Management System PCB Revisions

OK, a few revisions have been made to the water management PCB, mainly to reduce the possibility of the brushed DC motors in the water pumps from causing the MCU to crash, with the other changes to the I/O connector positioning & finally upgrading the reverse blocking diode to a 10A capable version rather than 5A.

Water Management PCB
Water Management PCB

Thanks to Mayhew Labs with the WebGerber image generator for the render.