Archive for the 'Computing' Category

PIC10F Assembly "Hello World"

So for a project, I’m using a PIC10F due to their very small size (in a SOT23-6, wow) and low cost.  They don’t have interrupt support, but they do have a timer, watchdog timer and a comparator.  You can do some fairly funky things with them.  However, I’m opting to use assembly for this project since it’s probably going to be simpler this way, as the stuff I need to do is very timing critical (reading sensors without interrupts = lots of polling).  Also I think I can squeeze the size of the program down better than a C compiler might do.

But I ran into a roadblock.  There are no documentations of assembly code listings for the PIC10F, and very few resources online.  So here’s a little snippet for you, which blinks an LED on pin GP2:

	list      p=10F222            ; list directive to define processor

#include
        ; processor specific variable definitions

    #define LightOn bsf GPIO,2  ; turn drive output on
    #define LightOff bcf GPIO,2 ; turn drive output off

;**********************************************************************
	ORG     0x1FF             ; processor reset vector
	ORG     0x000             ; coding begins here

    cblock 0x18 ; this is where we declare what to call user memory locations
      DelayTime:3       ; reserve 3 locations for delay counters
     endc

	goto Init
Start:
	clrwdt
	LightOn
	call Delay
	LightOff
	goto Start

Init:
    movwf   OSCCAL      ; load factory osccal value at start-up
    bcf     OSCCAL,0    ; do NOT output osc/4 on GP2 (IR sensor input)
    movlw   b'00000000' ; set all GPIO low at startup
    movwf   GPIO        ; load port latches
    movlw   b'00000000' ; All GPIO pins are outputs
    tris    GPIO        ; set I/O directions
    movlw   b'11011000'	; wake-up on pin change disabled, weak pull-ups off
                        ; Timer0 clock select on GP2 internal
    option              ; write to OPTION_REG

    ; clear all user RAM/variables on boot

    movlw  0x10         ; initialize pointer
    movwf  FSR          ; to RAM start
	goto Start

Delay					  ;
    movlw   D'2'          ; 2 = a delay period of approximately 500mS

Delay2                    ;
    movwf   DelayTime     ; pre-load W & enter at Delay2 for different delays
    movlw   D'232'        ;
    movwf   DelayTime+1   ;
    movlw   D'255'        ;
    movwf   DelayTime+2   ;
Dloop
    clrwdt                ; 1
    decfsz  DelayTime+2,f ; 1
    goto    $-2           ; 2/1
    decfsz  DelayTime+1,f ; 1
    goto    $-4           ; 2/1
    decfsz  DelayTime,f   ; 1
    goto    $-6           ; 2/1
    retlw   0             ; 2

	end

Delay routine and general structure is shamelessly stolen from Bruce on PICbasic.co.uk.

Hopefully, someone will find this useful :)

Colour Code

Something I came up with this afternoon with the help of Fluffy, and for a project that we’ll be doing in the somewhat near future.

It’s a code, using colours. See if you can crack it ;)

Facebook thinks I'm from Jenny's block

Yeah, Jenny from mah block!

Uhh, no.

Infrequenty Asked Questions II

Ah, time for another happy installment.

  • User: Hi, are you a helpdesk person?
  • Me: Yes ….
  • User: There’s a wasp in Level 2 Computer room … can you get rid of it for me?
  • Me: Um.  I’ll call security.
  • User: Hi are you IT support?
  • Me: Yes ….
  • User: My the tap in my kitchen is leaking.

In a feedback form:

  • User: The noise level in Level 4 Extension is unacceptable!  I can’t concentrate, it’s  like a discussion area!
  • Supervisor: Level 4 Extension *is* a group discussion area.
  • User: My document isn’t coming out in colour!
  • Me: (looking at their print history) that’s because you printed it to a black and white printer.  There’s 2 colour printers, colour2 and colour3.
  • User: Oh.  Can I get a refund?
  • Me: Because you sent it to the wrong printer?  No.
  • User: My document didn’t print
  • Me: (looking at print history) that’s because you don’t have enough credit.  And you’re not likely to either
  • User: What?
  • Me: Unless you happen to have £13,000 in pound coins on your person.

(turns out they had put the pages they wanted to print into the copies section, and so were ordering something like 242,526 copies of a 60 odd page document. )

**UPDATE**

Had to squeeze this one in:

  • User: I’ve tried to print a document in colour and it’s not coming out.
  • Me: (looking up the job) Ah well, that’s because you printed it on a black and white printer.  In a computer room on the other side of campus.
  • User: Oh.  Can I get a refund?
  • Me: Uhh, no.

(I eagerly await the day when someone accidentally prints something on another campus, and then they ask me where the printer is)

*twitch*

I’ve been working on my second year project for the last …. 12 hours now.  Most of the backend is done.  It looks like this:

As I snapped this screenshot, I noticed that my BlueJ window was exactly 1337 pixels wide.  That’s surely got to be a good sign, right?

Now, before someone goes off on a rant “Oh, NMEA parsing isn’t hard, I did it in a Python script!”.  I’ve got to do a bit more than just updating Location information.  I have to generically parse all NMEA sentences and check if they’re valid or not, and depending on whether they’re a Proprietary sentence or not I need to switch send the data to the right sort of object.  I’ve got measurements coming in on the stream which gives me Temperature, Humidity, Pressure and vertical acceleration.  I need to be able to dispatch these Measurements to the right places so they can be updated in the GUI. Also, each one of these Measurements needs to be associated with a Location.  I also need to be able to throw Exceptions which can be sensibly handled by the clients. Also everything needs to be completely documented.

It’s not particularly hard, just big and long. The class to turn the GGA sentences into Locations was the easy bit.

Now: I’m going to watch some BSG and go to sleep before my shift in 10 hours.

Bleeeding!

Error'd: OrCAD knows what's best for my Vias

Oh, OrCAD.  If it weren’t for these little gems of error messages, I’d throw it out the window.

Infrequently Asked Questions

Some of the wonderful questions I get asked at helpdesk:

Hi, I just got a printer with my laptop and it doesn’t work.  Does it have anything to do with the University Website?

(In the Library)
Where are the books?

  • User: Printer 1 is jammed!
  • Me: Um, no it isn’t.  What’s your username?
  • User: ***
  • Me: Right, well, it’s definitely not jammed because you didn’t print anything – you don’t have any printer credit left
  • User: Credit?
  • Me: Yes, you have to pay for printing.  Sometimes your Department will give you an allowance but if you go over that you have to pay it yourself.
  • User: What, I have to pay for it?  Out of my own money?
  • Me: … yes.
  • User: Psh, screw that.  I’m using Printer 2 instead.
  • Me: … you have to pay for that one as well.
  • User: What about the one in Rutherford?
  • Me: Yes, you have to pay for ALL of the printers around campus, unless you’re an Electronics students and their printers are free
  • User: Oh, how do I become an Electronics student?
  • Me: I think changing your degree over a 50p document may be a little extreme.

After being told to plug their console into the network so we can register it

  • User: I’ve plugged it in like you said, what’s next?
  • Me: Um, you’ll need to turn it on as well.

At 1800, just as the office is closing

  • User: Hi, I need an appointment because I can’t get on the Internet. I need it TODAY
  • Me: Well, I’m sorry, but I’m just about to lock the office up now. I can book you an appointment for tomorrow though.
  • User: No, no, it’s got to be TODAY. I have an assignment in tomorrow
  • Me: *sigh* What’s the problem?
  • User: Mah laptop won’t turn on.
  • Me: Well, I’m afraid we can’t help you with that, you’ll need to see a computer repair shop. I can give you a list of places who could help …
  • User: Nah nah, they won’t be open will they?
  • Me: No, they won’t – for the same reason we’re not!

There will be more.

IBM X31 Chipset Borkage

So, I grab my lappy this morning and find that it’s locked up for no reason.  Again.  It’s almost certainly a hardware problem, as I’ve seen it lock up during OS installs too.

Then I go to reboot and I get four beeps, which apparently means “System Board is broken”.  Rut roh. After a bit of googling, I find this blog post which details how to reflow the chipset (!!!) to fix cold solder joints.

So, after disassembling the thing completely  according to the service manual, down to the System Board, I get some tinfoil, a heat gun and give it a try.  After using the tinfoil to mask the other areas of the system board, I did the following:

  • Let the gun warm up for a minute
  • Point the gun at the chipset from about 30cm, swirling for about 2 minutes, whilst occasionally bringing the gun closer
  • For 30 seconds,I held the gun about 5cm away from the chipset.
  • For a minute, I held the gun at 30cm
  • Then I turned the gun off and allowed it to cool for 20 minutes.

It’s now booting OK, and I’m running memtest86+ to see how it goes.  I hope it works!

Nano Tweaks

Right now, I’m writing a novel. Before I started this I wondered about how I was going to write all this down, and I decided to do so using LaTeX and nano.

My nano configuration

My nano configuration

A lot of people think that nano is an editor only for newbies. Not so! Whilst it is minimal, it has a good set of features that allow you to be productive without having to remember syntax for commands, worry about buffers or having to switch modes all the time. Not only that, it’s damn small:


fish@jackson:~$ ls /bin/nano
-rwxr-xr-x 1 root root 143K Apr 8 2008 /bin/nano

Compared to:

fish@jackson:~$ ls /usr/bin/vim.basic
-rwxr-xr-x 1 root root 1.5M Jan 31 2008 /usr/bin/vim.basic

So now that I’ve tempted the non-believers, here we go!
Continue reading ‘Nano Tweaks’

Talking into mobiles

This is a trend I’ve noticed, mostly whilst working in the Library.

I’ve seen people talking on a mobile phone, and actually move the phone away from their ear and in front of their mouths when they speak.  I don’t quite understand what the point of this is – and it kinda spits in the face of telecoms engineers that made the GSM system full-duplex.  They are intentionally limiting their phones to half-duplex (i.e. you can either talk or listen, not both at the same time).  Also, mobile phones are designed such that the microphone is in the right place to pick up your speech at a sensible level when the phone is held to your ear.  Putting it right up against your lips just makes your voice overly loud and makes the signal clip – even when you’re speaking quietly.  Phones have compressers and limiters in them such that your voice is intelligible, regardless of how loudly you’re speaking. 

The other odd thing is that I’ve only ever seen black people doing this.  Not once have I seen any other ethnicity doing this – which in itself is disturbing (just describing it makes me sound racist). 

Most perplexing.