Monday, 23 February 2015

PC Engines APU1D

The APU1D from PC Engines (released end of March 2015)

The CPU is a AMD G series T40E 1 GHz dual bobcat core with 64bit support, has 3 on-board Gigabyte network sockets and supports m-Sata SSD and one SATA plus power connector, and for expansion have 2 miniPCI express slots. The board has two options for memory the APU1D has 2GB and the APU1D4 has 4GB. The power ranges from 6 to 12 watts and is powered by a just 12v PSU.

APU1D image of board

Full hardware specification can he found here http://www.pcengines.ch/apu1d.htm

Sunday, 14 December 2014

Arduino tells the time in words

Arduino WORD CLOCK Project

Found this project Micro Word Clock and decided to give it a go, I couldn't find any code for Arduino so I mashed up some code, the code works however I want to add a flashing asterix to show seconds.

Equipment needed:

  • Arduino Uno

  • 8x8 LED Matrix with MAX7219

  • SparkFun Real Time Clock Module (DS1307)


The 8x8 LED matrix is 32mm x 32mm  so the math was easy each cell needed to be 4mm², I started by using Microsoft EXCEL to get the letters in a grid however I couldn't get the cells size to be 4mm X 4mm ( 3.97mm X 3.97mm) so I tried Openoffice and guess what no problem.  Once all letters was added you need to center text left to right and top to bottom, make all cells background black and text white, the font I used was consolas size 8.  I have added the files with the source code on github.

Wiring:

RTC DS1307

  • Connect SCL to A5

  • Connect SDA to A4

  • Connect 5V and GRD


MAX7219 - 8x8 LED MAtrix

  • Connect DIN to Pin 8

  • Connect CS to Pin 9

  • Connect CLK to Pin10


Code:
https://github.com/catchcoder/arduino/tree/master/Max7219_8x8led_with_RTC

Images:

IMG_0636 IMG_0637

Monday, 8 December 2014

How to enable SPI on Raspbery PI and enable SPI module for Python


  • Enable SPI on Raspberry PI

  • Enable SPI for use in Python






Enable SPI on Rasperry PI


From the command line type:
sudo nano /etc/modprobe.d/raspi-blacklist.conf

You will then see
2014-12-04-100914_568x125_scrot


Comment out the blacklist spi-bcm2708 by prefixing it with #

2014-12-04-100618_533x137_scrot


 Press and hold 'CTRL' and press 'O',  then press 'ENTER', then close nano with 'CTRL' + 'X'

You will need to reboot the type:
sudo reboot

When it has restarted you can test if it is working by typing 'lsmod', this display kernel modules loaded, you can wee from the image below the spi_bcm2708 module is now loaded,

2014-12-04-101948_405x237_scrot


SPI is now enabled on the Raspberry PI




 Enable SPI for use in Python


To enable SPI to be used in python you need to install the python module for interfacing with SPI.

You will need internet access so you can download the code from github.
git clone https://github.com/doceme/py-spidev

2014-12-04-105003_609x43_scrot


Once you have cloned the py-spidev you will need to change to the directory and use python to install  the module.
cd py-spidev
sudo python setup.py install

2014-12-04-105310_575x147_scrot


It is now possible to use import spidev more information can be found here http://tightdev.net/SpiDev_Doc.pdf
import spidev

Thursday, 16 January 2014

Free Windows software

Video Tools

  • Handbrake - HandBrake is a tool for converting video from nearly any format to a selection of modern, widely supported codecs. http://handbrake.fr/

  • VLCPlayer - Open-source cross-platform multimedia player and framework, which can also stream audio and video in a number of formats - https://www.videolan.org/vlc/index.html


Linux Tools

Editors

Hard disk tool

File managers

  • Free commander -  is an easy-to-use alternative to the standard windows file manager. The program helps you with daily work in Windows http://www.freecommander.com

  • Total commander - a file manager replacement for Windows 95/98/NT/2000/XP/Vista/7. http://www.ghisler.com


Compression

  • 7zip - is a open source file archiver with a high compression ratio. GUI and command line options. GNU LGPL license. http://www.7-zip.org


WIFI Scanner

Sunday, 30 October 2011

Arduino scare trick or treaters

How to scare trick or treaters with a delayed evil laugh when the door is opened.

Items required
Arduino
Surface door contact
10K Resistor
Speakers

Connect the door contact to pin 2 and 5v with a pull down 10k resistor connected to pin2 And ground
Connect the speakers (mono) to pin 11 and ground

Extra software required:

Sox or Audacity :to convert MP3 to wav 8bit
http://sox.sourceforge.net/
http://audacity.sourceforge.net/

You will need to convert the file using  sox audiodump.wav -c 1 -r 8000 -u -b evillaugh.wav

Wav2c : used to convert the audio wav file to code as seen at bottom of the code below (https://github.com/olleolleolle/wav2c)

Code

https://github.com/catchcoder/arduino

Monday, 9 May 2011

Arduino Happy Birthday source code

Arduino source code
/*  Happy Birthday Melody with flickering Candle
*  By Chris Hawkins
*  with modified code from the  Melody example
* (cleft) 2005 D. Cuartielles for K3
*
*
* Taken from (cleft) 2005 D. Cuartielles for K3
*
* The calculation of the tones is made following the mathematical
* operation:
*
*       timeHigh = period / 2 = 1 / (2 * toneFrequency)
*
* where the different tones are described as in the table:
*
* note  frequency  period  timeHigh
* c 1         261 Hz          3830  1915
* d 2         294 Hz          3400  1700
* e 3         329 Hz          3038  1519
* f 4         349 Hz          2864  1432
* g 5         392 Hz          2550  1275
* a 6         440 Hz          2272  1136
* b 7         493 Hz          2028 1014
* C 8         523 Hz         1912  956
*
* http://www.arduino.cc/en/Tutorial/Melody
*
*
*/

int speaker = 6;
int led1pin = 9; // RED LED
int led2pin = 10; // Yellow LED
int button =4; // state swicth to play music
int x = 0;
int buttonState = 0;
int length = 28; // the number of notes
char notes[] = "ccdcfe ccdcgf ccCafed bbafgf"; // a space represents a rest
int beats[] = { 1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1, 1,1,1,1,1,1,1,1,1,1,1,1,2};
int tempo = 300;

void playTone(int tone, int duration) {
for (long i = 0; i < duration * 1000L; i += tone * 2) {
digitalWrite(speaker, HIGH);
delayMicroseconds(tone);
digitalWrite(speaker, LOW);
delayMicroseconds(tone);
}
}

void playNote(char note, int duration) {
char names[] = {
'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C'   };
int tones[] = {
1915, 1700, 1519, 1432, 1275, 1136, 1014, 956   };

// play the tone corresponding to the note name
for (int i = 0; i < 8; i++) {
if (names[i] == note) {
playTone(tones[i], duration);
}
}
}

void playmusic ()
{
for (int i = 0; i < length; i++) {
if (notes[i] == ' ') {
delay(beats[i] * tempo); // rest
}
else {
if (i % 2 == 0)
{
analogWrite (led1pin,200);
analogWrite (led2pin,100);
}
else {
analogWrite (led1pin,100);
analogWrite (led2pin,200);
}
playNote(notes[i], beats[i] * tempo);

}

// pause between notes
delay(tempo / 2);
}
digitalWrite (led1pin,LOW);
digitalWrite (led2pin,LOW);
}

void setup() {
pinMode(speaker, OUTPUT); /* Speaker to play tune */
pinMode(led1pin, OUTPUT); /* Red led from tri colour LED */
pinMode(led2pin, OUTPUT); /* Yellow led from tri colour LED */
pinMode (button, INPUT);  /* Start playing melody button */
}

void loop(){
buttonState = digitalRead (button); /* check if button pressed */
if (buttonState == HIGH){
playmusic();
}
}

Sunday, 9 May 2010

Acquisition of temperature data to SD Card

I have managed to hack together from various sites a temperature data logger thats writes to a 2GB SD Card, firstly I had a blown up laptop motherboard and so I desoldered the SD card socket this was not very easy as they are surface mounted and is not designed to be removed. I then soldered 9 header pins to it and used a glue gun and melted glue all around the soldered part to strenghten it, afterwards I found a better way it was to use a MicroSD convertor to a standard SD card adaptor and soldered header pins to it.



or MicroSD adaptor



Library Used:

AF_SDLog library. from http://www.ladyada.net/make/gpsshield/download.html

I also have used the Sparkfun FAT16 library and examples <HERE> for use with there shield <HERE> and changed the '#define CS    8' on line 33 to '#define CS    10' in the examples to work with my build.

Code




/************************************/

/*            SD card temperature Logger         */

/*                             Version 1.e                          */

/*                           Chris Hawkins                      */

/************************************/


#include "AF_SDLog.h"

#include "util.h"

#include <avr/pgmspace.h>



AF_SDLog card;

File f;


#define ledBusyPin 8

#define powerPin 9

#define temperaturePin 0

#define BUFFSIZE 99

#define buttonStartStop 7


int buttonState = 0;         // current state of the button

int runState = false;     // previous state of the button

float lastPressed =0;


char buffer[BUFFSIZE];

uint8_t bufferidx = 0;

uint8_t i;


unsigned int logCount;



// blink out an error code

void error(uint8_t errno) {

while(1) {

for (i=0; i<errno; i++) {

digitalWrite(ledBusyPin, HIGH);

digitalWrite(powerPin, HIGH);

delay(200);

digitalWrite(ledBusyPin, LOW);

digitalWrite(powerPin, LOW);

delay(200);

}

for (; i<10; i++) {

delay(300);

}

}

}


void setup()

{


Serial.begin(9600);

putstring_nl("\r\nData logger");


// configure PINS

pinMode(ledBusyPin, OUTPUT);

pinMode(powerPin, OUTPUT);

pinMode(buttonStartStop, INPUT);

digitalWrite(powerPin, HIGH);


// check SD card - FAT 2GB

if (!card.init_card()) {

putstring_nl("Card init. failed!");

error(1);

}

if (!card.open_partition()) {

putstring_nl("No partition!");

error(2);

}

if (!card.open_filesys()) {

putstring_nl("Can't open filesys");

error(3);

}

if (!card.open_dir("/")) {

putstring_nl("Can't open /");

error(4);

}


// Check for next file in sequence 00 to 99

strcpy(buffer, "TMPLOG00.TXT");

for (buffer[6] = '0'; buffer[6] <= '9'; buffer[6]++) {

for (buffer[7] = '0'; buffer[7] <= '9'; buffer[7]++) {

putstring("\ntrying to open ");

Serial.println(buffer);

f = card.open_file(buffer);

if (!f)

break;

card.close_file(f);

}

if (!f)

break;

}


if(!card.create_file(buffer)) {

putstring("couldnt create ");

Serial.println(buffer);

error(5);

}

f = card.open_file(buffer);

if (!f) {

putstring("error opening ");

Serial.println(buffer);

card.close_file(f);

error(6);

}

putstring("writing to ");

Serial.println(buffer);

putstring_nl("ready!");


delay(250);


// clear buffer

strcpy(buffer,"");

}



void loop(){


// get button state

buttonState = digitalRead(buttonStartStop);


//  if button pressed and 2 seconds passed

if (buttonState ==HIGH && (millis() - lastPressed)>2000) {

lastPressed = millis();

runState = !runState;


}

// if the state has true then log temperature data

if (runState == true) {


// build string to write to card

sprintf(buffer, "%s,%d,%u,%d\n",getDate(),getTime (),logCount++,getTemperature());


//log data to SD Card

logData();


}

}



int getTemperature(){


//getting the voltage reading from the temperature sensor

float temperature = getVoltage(temperaturePin);


//converting from 10 mv per degree wit 500 mV offset

temperature =  (temperature - .5) * 100;


return temperature;

}


unsigned int getTime(){

//replace with RTC code once added

return  (millis() /1000);

}


char* getDate (){

//replace with RTC code once added

return "24/04/2010";

}

float getVoltage(int pin){

return (analogRead(pin) * .004882814); //converting from a 0 to 1024 digital range

// to 0 to 5 volts (each 1 reading equals ~ 5 millivolts

// using TMP36 temperature sensor

}


void logData( )

{


digitalWrite(ledBusyPin, HIGH);// LED on for witting to card


// get string length

bufferidx = strlen(buffer);


// write data to sd card

if(card.write_file(f, (uint8_t *) buffer, bufferidx) != bufferidx) {

putstring_nl("can't write!");

error(5);


}


digitalWrite(ledBusyPin, LOW);// LED off to show finished writting to card


}

/* End code */





Sample of output to SD card



Schematic