Sunday, November 14, 2010

Life in Motion


So, this is a graph showing an example of me walking and then jogging on the treadmill using my device (negative is correct, as forward motion becomes a negative value apparently). Previous graphs were even more radical like the one on the right here, but putting it up, higher from the surface seems to solve that pretty well. I will see if I can improve this further, otherwise I will solve it in code by applying some kind of filter. Note that this is raw data from the sensor, so I guess some kind of filtering needs to be applied anyway... But this is really looking good I must say! Note also that the positive peaks are really few, compared to all the samples made.

Sunday, October 24, 2010

Motion Problem Now Resolved!

So, this is the first prototype using the better ADNS-9500 mouse sensor.

Few months have gone by now mostly because I have done everything I could think of, asked around, trying to solve the issue I had. I have actually thought this could be the issue a few times, but what can one do. The problem I had was that whatever I did, I couldn't get any motion data. The SPI worked, as I could get product id and such, but when I moved the sensor, I got nothing. As you can see in the image to the left, I have highlighted the component that is to blame for it all. This tiny, 1.5mm MOSFET wasn't properly connected (either not soldered properly, or damaged during soldering), and thus the Laser didn't get any voltage, and thus the sensor couldn't detect any motion. This is all solved now, in another prototype I've build, build like the one in the image, but using a similar MOSFET and this SOT23 to DIP Adapter.

So now, finally, the fun starts! It feels like a heavy weight has been lifted, and I can now finally continue with this project! I've actually started with the coding already and even started to create graphs based on the motion data I get...

More images and progress will follow...

Friday, July 9, 2010

Prototype #1


One would think nothing happens here, since the post are so sparse, but I have actually been too busy with this to post anything. The one in the image, is one of the two prototypes I have build using the older sensor. Works pretty well. After a lot of smacking head against the wall, I finally had expected results showing up. I have also build a new prototype based on a better chip than the one showing in the image. The one in the image can handle walk speed, but will not work properly for running speeds. It can handle speeds up to around 1.6m/s. I am currently about to solder the new prototype together, and will reuse most of the code I've made for this prototype! More about the new prototype in the upcoming posts...

If you start walking and have some debug information showing using this prototype, you get something like this:

7 6 5 4 3 2 1 0
0x20 0b 0 0 1 0 0 0 0 0 --- No motion

7 6 5 4 3 2 1 0
0x00 0b 0 0 0 0 0 0 0 0 --- X motion

7 6 5 4 3 2 1 0
0x00 0b 0 0 0 0 0 0 0 0 --- Y motion


7 6 5 4 3 2 1 0
0xA0 0b 1 0 1 0 0 0 0 0 --- Motion detected

7 6 5 4 3 2 1 0
0x01 0b 0 0 0 0 0 0 0 1 --- X motion

7 6 5 4 3 2 1 0
0x02 0b 0 0 0 0 0 0 1 0 --- Y motion


7 6 5 4 3 2 1 0
0xA0 0b 1 0 1 0 0 0 0 0 --- Guess

7 6 5 4 3 2 1 0
0x0E 0b 0 0 0 0 1 1 1 0 --- X motion

7 6 5 4 3 2 1 0
0x1D 0b 0 0 0 1 1 1 0 1 --- Y motion


7 6 5 4 3 2 1 0
0xA0 0b 1 0 1 0 0 0 0 0 --- Yo mama

7 6 5 4 3 2 1 0
0x0E 0b 0 0 0 0 1 1 1 0 --- X motion

7 6 5 4 3 2 1 0
0x2A 0b 0 0 1 0 1 0 1 0 --- Y motion


The first byte (0x20) is from an address showing among other things if motion is detected. Next byte is X motion and next is Y motion. As you can see in the example here, bit 8 (7) is set in that address when motion is detected by the sensor. What I do here is just printing these addresses in an infinite loop, and you get the above when starting to move on the treadmill...

Sunday, April 25, 2010

Teensy 2!


This little thing is damn cool!

I have now been diving into micro-controllers, registers, timers, interrupts... all that to make the multicolored LED dim! Turning the LED on or off is easy. It's hell of a lot more complicated to make it work between on and off. To turn it on or off, I just have to activate some pins. To dim, timers and interrupts are used to create a PWM (Pulse-Width Modulation)!

I'm waiting for the sensor to arrive, but the wait is good, because I can use the time to learn more about this electronic stuff. I just love how it all works with the Teensy. Hook it up with USB to power it, and be able to flash it. You flash with a simple program by just pushing the button on the Teensy! You do the code in C (or assembler if you want). The compiler creates a .hex file, which is used to be flashed onto the device. It's all quite simple, thankfully! This means you can put more effort in how to actually use it, which takes time if you haven't been doing much of this before. But, with my background, and ease of learning, I will figure it out eventually. Also, there is Internet you can use for resources...

I also love how the thing can pretend to be any kind of USB device! It's all up to what you program the microprocessor to tell what it is when the handshake is taking place between the HOST (your computer) and this device. This will solve the driver issues and mouse issues explained before.

Tuesday, April 13, 2010

Digital to Analog

Currently, the usage of the treadmill sends keystrokes. This means digital, on or off, 0 or 1. Now I'm trying to figure out how I can create an even natural experience by mapping the analog mouse events to the game as most games supports this. Just by connecting a XBOX 360 controller, you can play games with the analog sticks, and thus change speed of movement continuously. Now I want to do that with my treadmill.

By the way, current game of interest is Just Cause 2!