Greetings, Proffessor.

AI Space Game, MyUSB Library, Projects No Comments »

Well, I figured out the problem behind the USB host failing to give the correct connection interrupts - the current draw was too large. The poor 9V battery I’ve been using all this time just couldn’t power the VBUS regulator enough for the USB memory stick, and so the VBUS levels were dropping below the minimum threshold. I’m damned glad I have a JTAG for all this - without being able to see the VBUS error bit set it would have been a needle in a haystack search.

Don’t know what a JTAG is? Here’s an article I wrote about the official Atmel AVR development tools.

Now that I’m getting the connection interrupts, it should be straight forward (if time-consuming) to finish off the host Chapter 9 code and get the host mode in a near-complete state.

As for University, I’m working on a new project. Since the 3D Java code, I’ve since ported the code to VB.NET, as well as to C (with the GDK toolkit for window management on Linux). The latter project was a disaster - horrible performance and very hard to use API.

To break from the graphics mold, I then coded up a rudimentary game of snake, which utilized an experimental linked list library I coded up in Java. That worked well, but I never got to finish it before coming up with my latest idea - a space game!

Actually, a space game with a difference. With the framework almost done, the game should be quite interesting, as no human interaction is possible. The framework allows for multiple ships with multiple teams to be created, each driven by a different AI module. That allows myself (and a few fellow Uni friends) to code up AI modules and pit them against one-another.

Space Game Screenshot

The graphics front-end is completely decoupled from the game back-end, so for accelerated testing the game backend can be driven by a graphics-less console front-end. The best way to get an accurate measurement of one AI module’s performance over another is to make the computer play many, many rounds and check the win totals, so that’s what will happen in the end. For now, the graphical, slowed down front-end serves as a great debugging aid.

Waiting, Waiting on the State to Change…

MyUSB Library, Projects No Comments »

Thousands of years of technological advancements, and for all our intelligence we’re unable to make a single working vending machine. At the current rate, Coke Inc.’s profits are projected to soar this quarter, with at least 76% of that being attributed to their faulty vending machines stealing my money. Bah.

Well, despite my previous entry, I went ahead and had a go at the auto-VBUS management anyway. It’s still not complete, but it does give the expected 300mS pulse on the VBUS line - although despite my best efforts I can’t seem to get it to reset for another connection attempt. Still, I’ve added in the code to allow for the host mode options to specify USB_HOST_AUTOVBUS or USB_HOST_MANUALVBUS in the initialization options. When the latter is used, the VBUS can be turned on and off via the USB_HOST_VBUS_On() and USB_HOST_VBUS_Off() macros.

Annoyingly, I’m yet to get the expected connection interrupt, when a device is inserted. Despite forcing the VBUS on, or using the automatic VBUS management, the interrupt just doesn’t occur. Apparently there’s something I’m missing — time to study the Atmel driver a little more closely around the host connection code, I think.

Blue Light Disco

MyUSB Library, Projects 2 Comments »

Well, my money’s sent, and within a few weeks I should be the proud owner of a set of USBKEY header adapters. That’ll be a relief, having to manually probe the serial pad with a multimeter probe is getting rather tiresome.

Along with the success in getting the UID-select mode to automatically detect which mode to initialize the USB system into (depending on the cable inserted, connecting a host cable causes the system to initialize into host mode) I now have the UID interrupt working as well. Starting the USB driver into UID select mode causes it to automatically switch between master and slave as the cables are inserted or removed.

That’s not bad, so I’m now moving onto the host mode again. OTG is just a funky subset of the device/host modes, so that’ll be last (and as far as I am aware, unique as I don’t believe Atmel’s driver supports it) mode to implement.

With a little fiddling, I’ve now got VBUS voltage generation out of the host mode, which causes my USB memory stick to glow a nice blue when inserted. I had to use the manual control workaround in the datasheet, as the “correct” host VBUS control only powers up for 300ms, before timing out if no device is inserted. Rather than have a complicated retry mechanism, I opted for just having VBUS generated all the time, and then just detect the device insertion.

MyUSB acting as a host

Once complete, I’ll be adding a configuration option to enable the normal VBUS mode, so that a connection with a device can be attempted via a macro, with a second macro indicating success, busy or failure of the connection. That’s for later however, as I want to just get the basics done before branching out into anything more complicated.

I’ve been wondering how much interest in an open source USB AVR driver there is, apart from my own. Anyone else out there planning on using this once it’s done? Anyone?

EVENT: MyUSB Refactoring

MyUSB Library, Projects No Comments »

Well, I’ve got the serial output for MyUSB working perfectly. In order to suit the needs of the end-user, there’s two (mutually-exclusive) serial drivers in the MyUSB library - one simple polled system and another using the streams in <stdio.h>. Since the USBKEY uses a MEGA128 on board, for simplicity I’ve opted to use the latter in the demo code (and for my own experiments) as it simplifies the code and speeds up the development.

Using a Macgyver approach involving breadboard wire and a multimeter probe, I’ve been able to view the serial output on a seperate graphics LCD. That’s been very handy - I can now see what’s going on from a more abstract view that my JTAG offers. The difference is error messages verses register examination, and both tools combined makes development much more pleasant.

After a bit of swearing and hard effort, I’ve refactored the main low level USB code to a much nicer method, which will allow for mode switching via the UID pin of the USB plug. That’s a neat feature of the new mini USB sockets - USB-A style plugs now ground a fifth USB wire which can trigger an interrupt to change over to host mode and vice-versa. That should also help troubleshoot the host mode — I’ve added a new event to the event hooks header file which give error information when the USB system fails to initialize.

Short (Circuit) Post

MyUSB Library, Projects, University No Comments »

Whew, three days already? With University sucking up my time like a giant Dyson vacuum cleaner, the days just fly by. Unlike our expensive Dyson however, Uni’s unlikely to randomly stop working numerous times and be returned with missing parts after being repaired in the near future.

I’ve gotten back into MyUSB work, concentrating on cleaning up the device code before moving on to correcting the host code. I’ve added a few constants to the code, which clear up the “magic” number compares for the request data in the Chapter 9 processing routine. In order to test out the code more thoroughly, I’ve added in basic USART library code which will allow for easy testing of the different USB events, etc.

Speaking of the USBKEY board, I darn near destroyed it while trying to jerry-rig up the USART to my serial cable and almost shorting out the board in the process. Seems bare wires are a dangerous thing — best to wait until Tom manages to create his breakout boards for the USBKEY to ensure reliability (and my safety!).

Today I received a very nice new electronic toy from a company that shall not be named. I can’t wait until it is released officially so I can talk about it - I can definitely see it being a popular item. Alas, yet another project to take some of my attention!

All’s Ship-shape

Misc., MyUSB Library, Projects No Comments »

Looks like .NET is a good candidate for extending my 3D work, although of course it’s still many, many orders of magnitude slower than using accelerated 3D hadware. Still, a quick port of my Java code over to VB.NET yields a much higher framerate for the same level of detail as the former, which opens the door for more techniques to be tried (like texturing). And that’s all without any significant optimizations to the .NET version of the code. I do like the increased simplicity of the .NET framework - it makes life a lot easier for me. Perhaps it’s time to truly retire from programming in aging VB6.

ZoomCityZoom (Tom) of Whizbangdesigns has announced on AVRFreaks his intentions to make breakout boards for the USBKEY’s tiny .5mm header pins. That’s good news for me, as it would allow me to connect up my peripherals without having to solder/desolder each time. I’ll hold off connecting up my Trackpad which I bought off eBay a few weeks ago until I have the breakouts soldered to the USBKey.

3D.NET

Misc., MyUSB Library, Projects No Comments »

Well, for kicks I’ve started porting my Java code (which is up on my site now, by the way) over to VB.NET for kicks - and to see if I can get any speed increase out of it. Actually, I’m quite surprised just how much syntax Java and VB.NET have in common. I’ve never really got into the .NET revolution, with quick programs of mine still being knocked up (sorry, written) in aging VB6, so this is a good learning experience for me.

Another interesting point of similarity is Java’s AWT graphics library with that of .NET’s. I would assume the former was based on the latter with wrappers made for the other Java-supported systems, as the similarities are simply astounding for anyone who has worked with either.
I hope to get back into MyUSB this week and get a rudimentary host system up and running to compliment the currently working and almost finalized device mode.

Wired and Weary

Misc., Projects, University No Comments »

Well, I’m knackered. To get to University each day by 9 I need to be up at 7, for which my tender body is taking its toll mightily. Still, soldier on!

I’ve just about hit the limits for my Java app. I’ve got my omnidirectional (and ambient) lighting working with intensities, drop-off values and colours - I can even make multiple lights and move them around in the simple 3D world. Still, Java is monsterously slow at rendering each triangle, which means I’m about at the point of diminishing returns - any enhancements now will slow down the system to far below acceptable levels (and I’m only getting about 10FPS with a 7,000 polygon model as it is).

I’d rather have a go at the thing in C, which I can optimize quite well, but I can’t get the darn GTK windowing library to work with my C code on the server. I think I’ll benchmark of all things VB.NET next and see how it does in rendering large amounts of triangle primatives.

I’ve started to get quite annoyed at Unix - so complex and so prone to blowing up in your face. It’s darn powerful, but the fact that I spent a very long time debugging my logon scripts after a minute change (which caused a cascade of unrelated errors) today makes me a little less fond of it. It’s nice to be able to pipe the output of a ls command into grep, sort and mail in sequence as one command, but when each command takes 90 pages of manual reading to get to work it seems a little less worthwhile.

Let There be Light!

Misc., Projects No Comments »

Well, I have my lighting system working, although it’s incomplete. This is all good fun!

Currently I can specify an ambient light colour and intensity, which is applied uniformly to every object in the scene. I can also create new lights and position them in 3D space, each also with its own intensity and colour. As each light object contains a 3D point for its position, lights (shown as the “X” on the screenshots below) can be moved and rotated with simple method calls.

3D Engine showing Lighting

Next I’m going to add in falloff values for the lights, so that the light intensity drops off as the distance between the face and the light increases.

3D Engine Progress

Misc., Projects No Comments »

Java really isn’t suited to 3D, or anything graphical at all for that matter.

However, as an “academic exercise” (read: product of boredom) I’ve been playing around with making a basic 3D renderer in Java. Thank’s to my friend Alan, I’ve been able to extrapolate on his 3D point mathematics teachings and turn it into a working basic renderer.

Currently I’ve implemented double buffering to eliminate flickering, backface elimination and Z-ordering, and with all the overloading I’ve written I’ve now got a pretty neat 3D library. I’m yet to write any shading code (hence the reason why the below screenshot is ugly - I’ve had to randomly color each face to make the object visible) but I can load in objects from a basic proprietary 3D shape format of Alan’s creation and render them in 3D space. I’ve also added functions for moving/rotating points and objects, which allows the current demonstration code to display several spinning objects.

3D Renderer Screenshot

My shape class can show objects as either solid rendering (pictured), wireframe, or as a point “cloud”.

All great fun, but the performance is pretty horrible. Once more than about 7,000 faces are loaded in, the framerate slows to only a handful of frames per second - a high-quality Torus Knot of 12,000 faces only manages 3 frames per second.

The Z-Sorting for both objects and faces was originally a basic Bubble-sort of my own writing, but for performance reasons I swapped it out with a more efficient (if more complex) Merge sort algorithm. I had to “borrow” the latter from a tutorial site on the Internet — after two complete attempts of my own I gave up and left the sorting code to the experts.

I’ll try to get some more screenshots up in the next few days, and/or coax the applet into running in a webbrowser for a live demonstration.

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in