Tuesday, 31 January 2012

PS/2 mouse interface from scratch

I'm going about the job of interfacing a PS/2 mouse to my AVR micro - so this will be a work in progress kind of job. This is something that millions have done before, but by doing this from scratch, I hope to not only mess it up, but also have fun.
1. Get a mouse, and a 6-pin mini-din female (so we can just plug in) - the mouse needs power, and just 2 data lines, CLK and DATA
2. The system is bi-directional, so to read we configure the pin as an input, and to write we either force the pin low, or 'pull' it high using the built-in pull-up resistance. 11 bits are sent serially: a start (0), 8 data, odd parity and a stop (1).
3. Next we need to send it some commands - the mouse will acknowledge the init command, and thereafter sends 3 bytes every time we send the "read" command.
4. The protocol http://www.computer-engineering.org/ps2mouse/
5. Example arduino sketch showing how to dive the 2 pins needed http://arduino.cc/playground/ComponentLib/Ps2mouse
6. Accurate timing data appears hard to get... 10-16.7 kHz makes it 1/10000 = 10us-6us clock. Some better data was found here : http://www.networktechinc.com/ps2-prots.html a bit of deeper investigation seems to indicate that the device (as opposed to host) needs a few cycles just to catch up every few bits - so 10us probably works out at closer to 25us

Installing AVR Studio
Atmel's new IDE is based on Microsoft Visual Studio 2010, so if like me you are equally at home using programmers notepad or Visual Studio, you should be up and running quickly. Download the new 5.1 version from Atmel download site. It's about 550mb, so it will take a long time.

AVR Studio 5.1 direct links - this bypasses the registration step, and only works if you have already registered. Small download (without runtimes) or the full download (includes .NET runtimes and Visual Studio basis) . And no, it does not include a free copy of Visual Studio 2010, it's just the C/C++ editor, and the Atmel toolchain plus debugger all in one tidy box.

MS call this their language shell, you get the same file and project management features, windows and toolbars, but the compiler and debugger get replaced with Atmel ones. Probably wired a bit like the Android SDK is into Eclipse, which I never really caught onto for lack of desire to learn Java at the time. Partly I was put off Eclipse as a stable platfom after a bad experience with Carbide for Symbian; which was actually fun to learn in the end. So there you have it, AVR studio plays nicely with your existing ISP or debugger hardware all in one UI.

Myshed Free Image Composite editor

Microsoft ICE for short, it's a free tool, take it or leave it style.

It will take you longer to actually capture the pictures to make one of these up than it does to render it. On a 4-core machine it takes about 20 seconds. So for your viewing pleasure, the inside of my workshop. It's currently off-limits due to outside temperatures being a bit too low to work for long. I have insulated it (all the silver bits), which makes it pretty cosy once the temp goes above 10 degrees outdoor.
To make your own stitching, simply google for 'microsoft image composite editor', hit the download button (32 or 64-bit) . If needed install any Microsoft runtime pre-requisites (I had to because this is a  machine rebuild.) When the program opens, optionally set the stitch mode to 'auto'. Start a new project or just drag a bunch of pics all at once into the window and wait. Once that's all done you would have thought you can use your stitched image panorama as a background on dual or even triple monitors? No dice. Windows only lets you configure 1 wallpaper - which is a let-down if you are a purist who hates downloading and installing guff onto the computer. You need a wallpaper manager app to stretch it and place it for you, so for now unless I can script it, it's not happening.

Saturday, 7 January 2012

powershell fascination

Conrad Braam (@zaphodikus) has shared a Tweet with you: "leveitan: Find illegal verbs- $verbs=Get-Verb|select -Expand verb;gcm -Command Cmdlet | select verb |?{$verbs -notcontains $_.verb}" --http://twitter.com/leveitan/status/105743172361125888

Monday, 2 January 2012

Resource links

E-Shopping links (my faves with *), these are more relevant to my Hobby pursuit. Chosen for shortest delivery and cheapest fro small orders in England really..

  • * BitsBox my fave, a small catalog suppplier,cheap postage, immediate delivery
  • * Oomlout great for Arduino bits
  • Quasar electronics they have kits
  • * Rapid Online good selection, huge catalog which also includes hardware and stationary.
  • Maplin Their catalog is a bit stale.
  • Sparkfun also for Arduino users, (in the USA supplier in uk someday)?
  • Coolcomponents Arduino and robotics parts
  • * RSH Electronics Small catalog but with good prices and some bargains
  • HobbyTronics Another small-catalog supplier - cheap and cheery
  • Spiratronics Another small-catalog, very cheap!
  • Farnell perhaps not that easy to use, they are good if you want to spend a lot more than just £40

Sunday, 1 January 2012

Low part-count charger (Part2)

Because we are using a wall-wart (the origional supply for this charger) 100uF input filtering is more than ample. Hence in the pre-boxing picture from the last post, it's a bit hard to see where things are. In the background is the breadboard ith some of the parts still left behind. As is usual for me I order duplicate parts, sometimes in case I blow things up. The other case for spare parts is when you actually want to have a prototype that works, and a finished article at the same time for debugging.
Part 2 adds a 'full' indicator, at the moment the indicator is not bistable, and it does not switch off the charger. Ideally we actually want the trickle-charge step to trip in and out, a little hysteresis should do the trick. Here is the final diagram. (right-click and view image separately to zoom in)

Since I have not got the enclosure I ordered, (which will go under this bit) that's another reason this project is not yet closed off.



You should just be able to see the battery pack connections on the pack (top of shot) and base, I have re-built the connections with some small pieces of un-etched PCB.