Friday, August 28, 2009

The Pirate Bay Sold - Alternatives

The Pirate Bay has been sold. Here are some alternative sites: http://torrentfreak.com/25-great-pirate-bay-alternatives-090822/

BTJunkie, Demonoid and EZTV are the best.

Saturday, August 22, 2009

Bicycle Speedometer Project

Here's a new project I've been thinking about building: a bicycle speedometer.

At it's core, it's just a simple reed switch hooked up to a PIC microcontroller's CCP module (in capture mode) which measures the period of the turning of the wheel. Based on the period data, the microcontroller then calculates the speed and displays the information to the user on an LCD screen. Now, to dive in deeper...

This project can, of course, remain as simple as a mere speed measuring device or can be expanded into a full bicycle computer which maintains trip logs (time, distance, speed, keeping track of rest breaks), control headlights based on ambient light and so on.

The main speed measuring module consists of a reed switch mounted on one of the front forks. A strong magnet shall be placed on one (or more) of the spokes. Every time the wheel turns, the magnet will pass the reed switch and close the circuit, sending a signal to the microcontroller. The microcontroller is then interrupted by the event and the CCP module then measures the period. To compute the speed of the bicycle, only the circumference/diameter of the wheel and the period must be known. Although only one magnet is required, more can be placed to allow for greater accuracy. On the PIC's side, an appropriate external crystal shall be used with the CCP's timer to allow for millisecond timing. With the appropriate crystal, the CCP can then measure the period (in milliseconds) of the wheel to produce very accurate speed readings. Readings can be presented to the user every 1 second, for example. The LCD can be of HD44780 type or this or this or one of the graphic LCDs at Futurlec. The LCD should be small and readable yet consume as little power as possible. The microcontroller itself will be in sleep mode most of the time to conserve power.

A real time clock and SD card (via SPI interface) can also be added to the project to allow for data logging and to add a simple real time clock. The RTC will maintain time via a "backup battery" and the SD card would be written to every now and then.

The entire computer could be powered by batteries. But since the computer consumes less than a few mA at most, a solar panel is also possible. Or it would also be possible to use the energy generated by the bicycle and store it in capacitors.

As for the core of the computer, any PIC would do for such a relatively computationally non-intensive job. However, I was thinking of using the dsPIC33FJ128GP802 :)

Free Blogger Templates

BTemplates 

BTemplates is a gallery that shows, describes and ranks the best templates for Google’s platform for blogs. It was the first blogger templates gallery created in March 2008 and currently has the largest collection of templates.

Sonsivri

Sonsivri is a really great forum pertaining to the discussion of electronics and microcontrollers. Has a lot of other goodies as well :)

Friday, August 14, 2009

Pictures of my first home-made PCB

DSCN5945 DSCN5946  DSCN5949DSCN5947

 

The first 3 pictures are of the normal component side view. The last picture shows the copper side.

Thursday, August 13, 2009

UART Example for DSPIC33 (DSPIC33FJ128GP802)

#include <p33FJ128GP802.h>

_FOSC(OSCIOFNC_ON & FCKSM_CSDCMD & POSCMD_NONE);	//Oscillator Configuration (clock switching: disabled;
							// failsafe clock monitor: disabled; OSC2 pin function: digital IO;
							// primary oscillator mode: disabled)
_FOSCSEL(FNOSC_FRCPLL);					//Oscillator Selection PLL
//_FOSCSEL(FNOSC_FRC);					//Oscillator Selection no PLL
_FWDT(FWDTEN_OFF);					//Turn off WatchDog Timer
_FGS(GCP_OFF);						//Turn off code protect
_FPOR(FPWRT_PWR1);					//Turn off power up timer

void InitUART1() {
	// This is an EXAMPLE, so brutal typing goes into explaining all bit sets

	// The HPC16 board has a DB9 connector wired to UART2, so we will
	// be configuring this port only

	// configure U2MODE
	U1MODEbits.UARTEN = 0;	// Bit15 TX, RX DISABLED, ENABLE at end of func
	//U2MODEbits.notimplemented;	// Bit14
	U1MODEbits.USIDL = 0;	// Bit13 Continue in Idle
	U1MODEbits.IREN = 0;	// Bit12 No IR translation
	U1MODEbits.RTSMD = 0;	// Bit11 Simplex Mode
	//U2MODEbits.notimplemented;	// Bit10
	U1MODEbits.UEN = 0;		// Bits8,9 TX,RX enabled, CTS,RTS not
	U1MODEbits.WAKE = 0;	// Bit7 No Wake up (since we don't sleep here)
	U1MODEbits.LPBACK = 0;	// Bit6 No Loop Back
	U1MODEbits.ABAUD = 0;	// Bit5 No Autobaud (would require sending '55')
	U1MODEbits.URXINV = 0;	// Bit4 IdleState = 1  (for dsPIC)
	U1MODEbits.BRGH = 0;	// Bit3 16 clocks per bit period
	U1MODEbits.PDSEL = 0;	// Bits1,2 8bit, No Parity
	U1MODEbits.STSEL = 0;	// Bit0 One Stop Bit
	
	// Load a value into Baud Rate Generator.  Example is for 9600.
	// See section 19.3.1 of datasheet.
	//  U1BRG = (Fcy / (16 * BaudRate)) - 1
	//  U1BRG = (36850000 / (16 * 9600)) - 1
	//  U1BRG = 238.908854 //Round to 239
	
	U1BRG = 239;

	// Load all values in for U1STA SFR
	U1STAbits.UTXISEL1 = 0;	//Bit15 Int when Char is transferred (1/2 config!)
	U1STAbits.UTXINV = 0;	//Bit14 N/A, IRDA config
	U1STAbits.UTXISEL0 = 0;	//Bit13 Other half of Bit15
	//U2STAbits.notimplemented = 0;	//Bit12
	U1STAbits.UTXBRK = 0;	//Bit11 Disabled
	U1STAbits.UTXEN = 0;	//Bit10 TX pins controlled by periph
	U1STAbits.UTXBF = 0;	//Bit9 *Read Only Bit*
	U1STAbits.TRMT = 0;	//Bit8 *Read Only bit*
	U1STAbits.URXISEL = 0;	//Bits6,7 Int. on character recieved
	U1STAbits.ADDEN = 0;	//Bit5 Address Detect Disabled
	U1STAbits.RIDLE = 0;	//Bit4 *Read Only Bit*
	U1STAbits.PERR = 0;		//Bit3 *Read Only Bit*
	U1STAbits.FERR = 0;		//Bit2 *Read Only Bit*
	U1STAbits.OERR = 0;		//Bit1 *Read Only Bit*
	U1STAbits.URXDA = 0;	//Bit0 *Read Only Bit*


	U1MODEbits.UARTEN = 1;	// And turn the peripheral on

	U1STAbits.UTXEN = 1;
	// I think I have the thing working now.
}

int main() {
	ADPCFG = 0xFFFF;				//make ADC pins all digital	
	
	//PLL setup:
	CLKDIVbits.PLLPRE = 0;          // N1=2: PLL VCO Output Divider Select bits; 0 -> /2 (default)
	PLLFBDbits.PLLDIV = 42 - 2;     // M=40: PLL Feedback Divisor bits; 42 - 2 = 40 -> 40 x multiplier
					// (divisor is 2 more than the value)
	CLKDIVbits.PLLPOST = 0;         // N2=2: PLL Phase Detector Input Divider bits; 0 -> /2
	
	//40 x: 73.700000 MHz = 36.850000 MIPS
	//42 x: 77.385 MHz = 38.6925 MIPS
	//43 x: 79.2275 MHz = 39.61375 MIPS
	
	while(OSCCONbits.LOCK != 1);	// Wait for PLL to lock
	RCONbits.SWDTEN = 0;      // Disable Watch Dog Timer
	
	TRISA = 0b00000000;
	TRISB = 0b00000000;
	
	
	asm volatile ("mov #OSCCONL, w1  \n"
				  "mov #0x46, w2     \n"
				  "mov #0x57, w3     \n"
				  "mov.b w2, [w1]    \n"
				  "mov.b w3, [w1]    \n"
				  "bclr OSCCON, #6");
				  

	RPINR18bits.U1RXR = 7;
	RPOR3bits.RP6R = 0b00011;
	
	asm volatile ("mov #OSCCONL, w1  \n"
				  "mov #0x46, w2     \n"
				  "mov #0x57, w3     \n"
				  "mov.b w2, [w1]    \n"
				  "mov.b w3, [w1]    \n"
				  "bset OSCCON, #6");
	

	InitUART1();
	
	while(1) {

		U1TXREG = 'H';
	}
		
	return 0;
}

Wednesday, August 12, 2009

Tungsten Carbide Drill Bits

I just received my order of 1/32" tungsten carbide drill bits with 1/8" shank. The 1/32" size is very good for drilling general purpose holes in PCBs. I simply used a Dremel and drilled the holes by hand. The tough part is centering the drill bit on the hole (on the copper side), but once you have it centered, the drill goes through very quickly. I didn't have any trouble with drilling and did not snap any bits.

Thursday, August 6, 2009

Pure Gnome/KDE on Ubuntu

I’ve used this so many times to clean my system. A simple command to get back to a pure Gnome or pure KDE Ubuntu/Kubuntu system – especially if you have both desktops installed.

http://www.psychocats.net/ubuntu/puregnome

or

http://www.psychocats.net/ubuntu/purekde