Tuesday, December 29, 2009

Mini review of "Brain Rules" by John Medina



I am not sure how I came across the book "Brain Rules" by John Medina, but I had put it on my Christmas wish list and got it as a gift. My hopes before starting reading it was that I was going to pick up a few tips and be inspired to change my ways of doing things in a more brain friendly way.

The book chapters are sectioned in what Medina calles "brain rules" or principles of how the brain is working. The chapter titles are exercise, survival, wiring, attention, short-term memory, long-term memory, sleep, stress, sensory integration, vision, gender and exploration. The actual brain rules for each topic can be found on medinas site: http://www.brainrules.net/. The videos on the site are quite good for catching the essence of each rule too and for repetition as well.

Each chapter usually uses plenty of examples of how the brain is working, usually experienced by the author himself. The examples are coupled to brain research and brain anathomy in a humorous way. At the end of each chapter Medina has a few ideas on how the brain rules can be put to practical use.

Many chapters are quite captivating and I found myself fascinated on how complex the brain actually is. The most important points I picked from the book are:

  • Learning is better done while exercising. Try to combine the two if possible.
  • Create strong pictures when you really want to remember things.
  • Teach and learn in periods of about 10 minutes at a time. The brain loses attention and gets bored after this time.
  • Recreate the environment of where you learned something when you want to recollect it.
  • Understand every word in a sentence that you want to understand.
  • In a presentation: Catch the audience's attention at an early moment.
  • Use plenty of examples when you want to explain something.
  • Multitasking is a waste of time.
  • Learn by doing. The brain is an expert at adapting to new tasks.
  • The best way of really learning something: Repeat every 10 minutes for three times and then repeat the most important things every 3-4 days.
  • Get sufficient sleep.
  • Avoid long term stress. Ask the question "am I in control?" if you are not sure if you are stressed.
  • Strengthen learning by using many senses at a time.
  • Your learn much by watching pictures in combination with relevant text, but more with narration and videos.
  • Reduce the amount of text in powerpoints - The brain is lazy and avoids reading text.
  • Vision is the most powerful sense and actually uses half of the brain's processing power.
  • Women capture the emotional details while men see the gist when experiencing acute stress.
So was the book worth reading? I think it was ok reading the book, but I think Medina got a little to detailed for my taste. I never wanted to be a brain scientist. I got what I wanted in the end: some great techniques for improving learning backed up with science. I will put it to practise - no doubt about it.

Thursday, October 15, 2009

How to locate, read and write property lists for iPhone

I had a real headache trying to figure out how to read and write property lists yesterday. It should have been an easy task, and I did everything according to the manual.

Here is what I wanted to do:
  1. Locate a property list created in xcode
  2. Read the XCode property list to a NSDictionary
  3. Append one or more extra items to the NSDictionary
  4. Save the updated NSDictionary to disc
The problem was that the iPhone has a sandboxed area called "Documents" where you can read and write property lists, but the property list you created in xcode is not located in this folder.

If you create a property list "MyPlist.plist" for an application called "MyApp" in XCode it will be located here:

appPath/MyApp.app/MyPlist.plist

Where "appPath" is a string that you can only get while running the app. You can get the whole path to the plist by using this code:

NSString *path = [[NSBundle mainBundle] pathForResource:@"MyPlist" ofType:@"plist"];

This file could be read from, but not written to due to the location on the iPhone.

But I wanted to save data to the iPhone. This could only be done in a property list located here:

appPath/Documents/MyPlist.plist

To locate the folder "Documents" where I have rights to both read and write I can get the path by using this code:

NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory=[paths objectAtIndex:0];
NSString *path=[documentsDirectory stringByAppendingPathComponent:@"History.plist"];

Reading and writing to the property list from a NSDictionary could be done with the following code:

Reading: NSDictionary *dict=[[NSDictionary alloc] initWithContentsOfFile:path];
Writing: [dict writeToFile:path atomically:YES];

Here is the whole code put into action:

NSMutableDictionary *dict;

//Reading plist created in xcode
NSString *path = [[NSBundle mainBundle] pathForResource:@"MyPlist" ofType:@"plist"];
if ([[NSFileManager defaultManager] fileExistsAtPath:path]) dict = [[NSMutableDictionary alloc] initWithContentsOfFile:path];

//Reading plist stored on device
NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory=[paths objectAtIndex:0];
path=[documentsDirectory stringByAppendingPathComponent:@"MyPlist.plist"];
if ([[NSFileManager defaultManager] fileExistsAtPath:path])
{
NSMutableDictionary *tempDict = [[NSMutableDictionary alloc] initWithContentsOfFile:path];
//Merging dictionary created in xcode with dictionary stored on the iPhone
[dict addEntriesFromDictionary:tempDict];
}

//Creating dictionary if it doesn't exist
if (dict==nil) dict=[[NSMutableDictionary alloc] init];

//creating and adding array to dictionary
NSArray *array=[NSArray arrayWithObjects: [NSDate date], [NSNumber numberWithDouble:double1], [NSNumber numberWithDouble:double2], [NSNumber numberWithDouble:double3], [NSNumber numberWithDouble:double4],nil];
[dict setObject:array forKey:@"First Array"];

//writing dictionary to plist on device
[dict writeToFile:path atomically:YES];
[dict release];

Wednesday, September 02, 2009

How to connect icd3 ac162049 with a PIC microcontroller.


I confess I'm a hopeless beginner when it comes to Microchip's PIC microcontrollers. After playing around several years with AVR microcontrollers I figured it was time to go for the hobbyists second choice - the PIC.

My first impression is that Atmel has outpriced themselves after earlier being able to deliver cheap developer boards like the STK500. I wanted a programming device that was able to program DIL devices for rapid prototyping and for hobby projects and ended up buying an Microchip ICD3. I also bought a AC162049 universal programming module to be able to program several different DILs without having to make circuit boards first.


I am familiar with some other chips from Microchip, and have always found the datasheets quite understandable. With the ICD3 it was a completely different story. I was not able to connect to the dsPIC33FJ128MC that I knew was compatible with the ICD3. After looking around a bit I found out how to communicate with the device:

  1. Connect a 4.7-10 kOhm pullup resistor from one of the two VDD wires to the _MCLR pin.
  2. Connect all other wires except VPP to the pins in the datasheet for the microcontroller. GND wires should be connected to Vss. PGC and PGD should be connected to any of the pins starting with PGC or PGD. I used PGC1 and PGD1.
  3. Open MPLAB IDE and choose "Configure-Select Device". Choose the device you are using.
  4. Open "Programmer-Select Programmer"and select "MPLAB ICD3".
  5. Open "Programmer-Settings-Power" and check "Power target circuit from MPLAB ICD3".
Now you should be able to connect to the microcontroller. For me it was the setting for the power that I missed. After using a voltmeter I found that the microcontroller didn't have any power.

Tuesday, March 24, 2009

Simple TWI / I2C communication with AVR ATMega8 and TC1321 DAC

I wanted to set up and test the D/A-converter TC1321 with a AVR, but had no previous knowledge of TWI. These are my experiences:

To make things easier I used a AVR with built in TWI function. I got a little confused on this subject when I read on AVR Freaks that for example the ATTiny26 had TWI function. Actually the microprosessors with a lowercase "y" in the comparison chart has USI which can be used for TWI. The uppercase "Y" for TWI indicates that the uC has built in TWI functionality. With such uCs you can include the to get some free predefined twi-codes.

To connect to a TWI device you need to connect the SCL and SDA lines to the uC. For ATMega8 it is PC4 (SDA) and PC5 (SCL). You then need to connect each of these via a pullup resistor to the source voltage (5V). For this connection I used two 220 ohm resistors.



So to sum up: I found it easier than I thought to interface the TC1321. Reading through descriptions that others have made describing both reading and writing to a slave (EEPROM etc) was not necessary when the only thing I wanted was to send data.

I found it easier than I had thought to communicate with the TC1321. First you need to set up the SCL-clock rate. You can calculate the TWBR with this formula:
TWBR=(fCPU/fSCL-16)/(2*4^TWPS)

So if you run your uC at fCPU=8MHz and you want fSCL=100kHz and try to use a prescaler TWPS=0 you get TWBR=(8e6/100e3-16)/(2*4^0)=32. So you start by setting:

TWPS=0;
TWBR=32;
To send data to the TC1321 you can use two protocols: 1-byte format (8-bits) and 2-byte format (10-bits). The progress of sending data is made in a sequence like this:

1-byte format:
START
SLA+W
COMMAND
DATA
STOP

2-byte format:
START
SLA+W
COMMAND
DATA
DATA
STOP

In between every sending you check the status codes by looking at TW_STATUS. The SLA+W is actually only the slave adress, 0x90.

Here are some functions that can be used to send data to the TC1321:


So to sum up: I found it easier than I thought to interface the TC1321. Reading through descriptions that others have made describing both reading and writing to a slave (EEPROM etc) was not necessary when the only thing I wanted was to send data.

Sunday, March 01, 2009

Mini review of "The 4-hour work week" by Timothy Ferris




I came across this book as I was looking for material before having a inspirational lecture about mathematics to new high school students. I ended up having a lecture of why you should embrace learning different things and the importance of knowing a little about most things in life. This is actually what Timothy Ferris was looking for when he decided to break out of his 9-5 traditional work as an employer ("slave" in his words) and start managing his own future. He wanted to work less, earn more and spend the extra time and money he had for traveling and enjoying life while he still was young and able to live it.

The book is a blue print on how to [D]efine your goals in life ("dreamlines"), [E]liminate time wasting and start focusing on realizing those goals (by using Pareto's principle and Parkinson's law), [A]utomate your business (by using outsourcing and the wonders of computers) and [L]iberating yourself from current work and the life you are living.

I really liked the book: It gave me a kick in the butt to start focusing on progressing towards my most important goals. Even though the internet business modell is perfect for people having a big home market, many of the tips are quite transferrable to everyone wanting to start up something new.

I am not dreaming about traveling the world throughout my life anymore, but I still would prefer having more time for hobbies and family. I think this book gave me gigant leaps towards achieving this.

Thursday, February 26, 2009

Flux welder (FCAW) converted to MIG (GMAW)

I got a nice welder from my wife Sunniva this christmas that was flux core only. After reading a bit about welding I decided to check if it was possible to convert my welder to MIG with gas shielding (Argon or Argon/CO2). This is attractive since you could make much nicer welds, poisonous fumes are minimized and you should in theory be able to weld both stainless steel and aluminium.

After opening up the torch I found that it contained a gas valve that had a threaded hole. I bought a small bottle gas kit for a different welder, made threads on the straight part of the quick coupling and bought a longer nylon tube for the quick coupling with the same diameter. Now I am able to do both flux core and gas shielded welding.

Wednesday, February 25, 2009

Error with CDrom in xp (Code 32) finally fixed

As an action oriented man it is a little bit embarrassing to admit that I have had problems using my hp laptop cdrom drive for several years now. I have not done anything about it since I thought it was a hardware problem and data can nowadays allways be transferred in other ways (usb, wifi).

Yesterday I got surprised when I saw that I was able to boot from an ubuntu linux cd without problems. When I on top of that saw that no virtual cdrom drives (virtual clonedrive, magicdisc) were working either I was determined to fix what now was a windows problem.

I saw that all cdrom drives were registered as active in windows device manager, but all had an exclamation sign suggesting something was wrong. When looking in properties I got the following error:

(Norwegian)
En driver(tjeneste) for denne enheten er deaktivert. En alternativ driver kan gi samme funksjonalitet. (Kode 32)


(English)
A driver for this device was not required, and has been disabled (Code 32)The first suggestion was that I should include CTFMON.exe in the startup, but this did not change anything.


I finally found Microsoft's Q314060 showing me how to fix the problem:


Step 1: Start Registry Editor

Start Registry Editor.

Step 2: Delete the UpperFilters registry entry

  1. In Registry Editor, expand My Computer, and then expand HKEY_LOCAL_MACHINE.
  2. Expand SYSTEM, and then expand CurrentControlSet.
  3. Expand Control, and then expand Class.
  4. Under Class, click {4D36E965-E325-11CE-BFC1-08002BE10318}.
  5. In the details pane of Registry Editor, on the right side, click UpperFilters.

    Note You may also see an UpperFilters.bak registry entry. You do not have to remove that entry. Click UpperFilters only.
    • If you see the UpperFilters registry entry in the details pane of Registry Editor, go to step 6.
    • If you do not see the UpperFilters registry entry, you still might have to remove the LowerFilters registry entry. To do this, go to "Step 3: Delete the LowerFilters registry entry."
  6. On the Edit menu, click Delete.
  7. Click Yes when you receive the following message:
    Are you sure you want to delete this value?
The UpperFilters registry entry is removed.

Step 3: Delete the LowerFilters registry entry

  1. In the details pane of Registry Editor, on the right side, click LowerFilters.

    Note You might see a LowerFilters.bak registry entry. You do not have to remove that entry. Click LowerFilters only.

    If you do not see the LowerFilters registry entry, unfortunately this content is unable to help you any more. Go to the "Next Steps" section for information about how you can find more solutions or more help on the Microsoft Web site.
  2. On the Edit menu, click Delete.
  3. Click Yes when you receive the following message:
    Are you sure you want to delete this value?
    The LowerFilters registry entry is removed.
  4. Exit Registry Editor.

Step 4: Restart your computer


Thursday, February 19, 2009

Mini review of "The renaissance soul" by Margaret Lobenstine




I had this book on my wish list since I picked up the title when reading comments to the blog post "The Top 5 Reasons to Be a Jack of All Trades" from Tim Ferris' blog. I was happy when receiving this as a christmas gift and started reading it immediately. During my recent vacation to the Canaries I got the chance to finish the book. Here are my personal impressions of the book:

  • I was expecting to learn a practical time management system from the book. Time management is covered in 22 pages and is not very practical in my opinion. Margaret basicly says that you should put down up to four focal points, calculate how much time you have left for them and put them in your calendar. I don't like using the calendar when it's not necessary. I rather put up my most important tasks for a day and try to finish them. These are all prioritized according to my focal points. This makes you focused, but still flexible. I picked up this tip from "zen to done" from Zen habits.
  • The book is written more like a novel than a practical guide. It is full of stories of clients that Margaret succesfully helped out after coaching them.
  • The title is "The renaissance soul", but I didn't expect the author to use this phrase as much as she does. OK, so the test said that I am a renaissance soul - this does not make me some special, rare creature that should behave differently than any others. Most people need some kind of structural aid to be effective in their day to day work.
  • Even though I didn't like the book very much I found some metaphors quite good: A) When trying to find which focal points to pick then think of them as ice-cream that you can pick a four-flavor sampler from and change whenever you like. B) When faced with a situation involving change you are like a lobster breaking out of it's shell in order to grow: First the shell is a thin membrane without protection and you fear this before you leave your original cozy shell. You later realize that your new shell is bigger and harder and more protective than the old shell.

Friday, January 30, 2009

iPhone VPN connection to Vista is now working

Something strange happened the other day. I haven't used the iPhone VPN connection since the post was written because I had no use for it. Now I wanted to try it again. This time I got access to all the other ip adresses that were previously hidden for me. I tested this from work so I know I wasn't locally connected. Three things were changed since the last time I tried: The iPhone got new firmware (2.2.1), the wireless network administration was changed from RALink to Windows and Windows Vista probably got some new updates. That's really strange, but oh so cool!

Tuesday, January 20, 2009

Nondestructive cooling for Dreambox DM800 HD


I got sick and tired of the Dreambox DM800 HD locking up all the time and read several places that this was due to heating problems. This happens especially when you run HD channels.

The Dreambox DM800 HD does not contain a fan, so I decided to include one myself. I did not want to destroy anything or cut any wires so I started looking at different pins/connectors that I could connect a fan to. Two options were candidates: the header next to the Broadcom cpu (JTAG header?) and the power supply to the internal SATA harddrive that I have got. Neither were easy to find any good information as to what voltage they had or if they could source sufficient current. I decided to use the same trick that everyone else are using: Connect to the USB port.

I found an old 12V cpu fan that I salvaged from an old computer and stripped the wires. I had a spare USB male to USB female cable that I removed the shielding from, cut the red and black wires, stripped them and connected them to the wires for the fan. Now the fan was running ok. The wires for the fan now goes nicely through the hole where the eSATA connector earlier was connected.

The USB 2.0 standard gives a maximum current of 100mA. At 5V this would be 0.5W. My fan was supposed to draw 1.5W at 12V, but the DM800 has no problem running it. It even seemed to have no problem booting up the first time I connected the power plug.
Posted by Picasa

Wednesday, January 07, 2009

VPN connection from iPhone to Windows

After some fumbling around I finally figured out how to make a VPN connection from my iPhone to my Windows Vista PC.

To start out I used the guide "Setting up the Vista Point-to-Point Tunneling Protocol (PPTP) Virtual Private Network (VPN) Server". It is a great guide on how to set up a Windows to Windows PPTP VPN connection. The client side is not very well covered, but could easily be found elsewhere on the internet.

I had to set up port forwarding on both the ADSL modem as well as on my wireless router for port 1723. No other changes of settings were necessary on the routers.

After finishing the guide I could not get a VPN connection from either a windows client or from my iPhone. Some web guides have the advise to set the "account" on the iPhone with the syntax "Hostname\Username". This does not change anything. The trick to get a connection is to connect through a different subnet than the VPN server is connected to. This means connecting the iPhone via 3G or a different WiFi Network than the server is physically connected to. This makes sense since you do not need to go to the internet to make a VPN connection if you are allready connected locally.

Now I have a VPN connection from my iPhone to my Vista PC, but I still haven't figured out what I can use the connection to. The iPhone does not have any browser software to browse through local folders on the VPN server and when pinging the subnet I only get reply from the two local adresses for the VPN gateway and the incoming VPN client. I have tried making a port forward to a vnc server, but that didn't work out. I have thus so far not been able to do anything useful with the connection. If anyone have suggestions on how to make it useful, please publish a comment.

Friday, January 02, 2009

PIC desulfator

Look what I got in the mail today: A PIC based desulfator from
courtiestown marine. It took a few hours to solder it, but now it is
ready. Now let's ressurrect some old batteries!