Archive for March, 2007

Anderson Mccutcheon

Saturday, March 17th, 2007

Anderson Mccutcheon is probably the most famous non-existent whisky, bearing the name of the most famous non-existent Admiral in the world. The whisky was featured in then eight episode of the third season of Lost, describing the Admiral as the most decorated one to ever serve in the navy, and the whisky being his crowning achievement.

whisky

Being quite fond of whisky, I was rather disappointed to find out that there is no such beverage. If you are looking for something comparable to the whisky mentioned in the episode , I suggest the 40 year old BRUICHLADDICH. While it isn’t the crowning achievement of a decorated admiral, it’s  the finest Scottish whisky you will find in a regualr liquor store.

Cheers

Writing for NEC without CCS’s shift_left

Thursday, March 15th, 2007

CCS is a very nice compiler for PIC family of micro-controllers - the compiler includes a fair amount of built-in functions, many of which deal with bit manipulation - crucial functions when it comes to communications. Too bad I have to write these manually when porting communication to the NEC 78f9418 .

Having a 7 byte bitfield and transmitting it via low-speed PWM is not complex, and this is how the original code looked like, for PIC :

for (i = 0; i < 56; i++) {
shift_bit=shift_left (&irm, sizeof(ir_packet), 1);
send_bit(shift_bit);
}

Simple - 7 bytes are 56 bits, shift_left then accepts the address of irm, which is a structure of type ir_packet, shifted 1 bit to the left. The bit is then sent on it’s way.
Writing this code without the shift_left function proved to be somewhat fun though

packetBytePointer=&(BYTE *)&irm+6;
for(o=0;o<7;o++)
{
transmittedByte=*packetBytePointer;
for(z=0;z<8;z++)
{
send_bit(transmittedByte&0x80);
transmittedByte<<=1;
}
packetBytePointer--;

}

The above piece of code first puts an address to the last byte of the structure into a pointer, then assigns the value that is at that address to a temporary parameter of type BYTE (it's just an unsigned char) , and then simply iterates through it by shifting left and applying the 10000000 mask to it.
When the iteration is done, the address of the pointer is decreased to the begin the procedure on the next (previous memory-wise) byte.
This implementation was actually better in my case than shift_left of CCS , because it does not alter the original structure, so if you are storing your operational parameters in a structure that fits the transmission packet (common for simple devices such as “dumb” thermostats and motors), you don’t need to make another copy of the structure.

Winning a 1700 People Poker Tournament

Saturday, March 10th, 2007

Finally.

One of my hobbies is poker - the combination of mathematics and psychology makes a very natural and comofrtable game for me. I don’t play for real money online, but enjoy playing in big “play money” and Freeroll tournaments. One of the better things about poker, is I can’t see myself  get addicted to it, since it gets quite annoying after around two hours of play. So this hobby goes quite well with my busy schedule, and I play coupla tournaments a month. I play on PartyPoker and on UltimateBet, if you know a better place to play large poker tournaments , let me know.