Just a place to put what we're working on.

Home School Fun

Digital Seismograph

Imagine our surprise when windows XP detected the USB controller and loaded a generic driver for it.  Now to communicate with the driver,

After a little research, I discovered that the good people at Microsoft have already done the hard work for me.  “ winmm.dll “ Is full of functions like joyGetPosEx Which returns just about everything about a joystick.  And guess what, bonus! We have 16 bit resolution, not 8bit.  So we will receive A 16-bit integer up to 216 (or 65536).  Sweet! That gives us a lot of precision.  So a few lines of code later we are reading data.   Here is a screen shot.  The spikes correspond to each time we tapped the desk.

Resolution on the graph is times 100. 


Date: 04/12/2009

Really down and dirty code, but it shows our idea can work.   About 30 minutes more and we have a scrolling graph.  To create the effect of a graph I created an array of 500 lines with x1,y1 and x2,y2 locations.  Then pass the values down the line each time the Subroutine is called…



Text Box: Public Sub UpdGraph(iNumber)
    'MAX 32767 each dot = 16.3835 round to 16
    '65535 is actual max
    lbltimeFixed.Caption = Time()
    If lblTime.Left >= 10100 Then
        lblTime.Caption = Time()
    End If
    lblTime.Left = lblTime.Left - 20
    If lblTime.Left <= 100 Then
        lblTime.Caption = Time()
        lblTime.Left = 10100
    End If
    If iNumber > 0 Then
        iTemp = Fix(iNumber / (16 - yMultiple))
        iTemp = 0
    End If
    iTemp = 4400 - iTemp
    For x = 500 To 1 Step -1
        dot(x).Y1 = dot(x).Y2
        dot(x).Y2 = dot(x - 1).Y2
        dot(x - 1).Y1 = dot(x - 1).Y2
    dot(1).Y2 = iTemp
End Sub

Every millisecond or as quick as the CPU gives us a chance, we poll the joystick for its values and then pass input #6’s value to the sub.  The graph is very inefficient due to all the redrawing of the screen.  I will either disable the screen while updating then enable redraw, or switch to DirectX or something made for graphics. 

Now we can measure and record 1 dimension of movement, or rather half of a dimension.  The Peizo is only producing a positive charge when compressed, when released the charge is negative, our design ignores the negative voltage.  So we need six sensors to truly record 3 dimensions of motion.  This will also require some tricky code to bring all the data together and display as a single reading.