Shop OBEX P1 Docs P2 Docs Learn Events
Accelerometer Data Logging — Parallax Forums

Accelerometer Data Logging

rough_woodrough_wood Posts: 61
edited 2009-05-25 05:07 in Propeller 1
I am looking to log Acceleration data with respect to time using the 3Axis, Propeller, and my laptop in my car. Is there a good way to do this?

I am currently working on hacking the Accelerometer Demo to work off DuplexSerialPlus rather than VGA and somehow export the data.

I'd like to get the data into Excel, probably by somehow outputting Comma Separated Values in a txt file or something similar.

The goal is to see how quickly the G's tansfer from Throttle to Brakes, and turning one side to the other, as well as how high G's a car pulls when cresting a hill or climbing through a trough.

Any advice? I am very new to Propeller.

Thanks

Comments

  • Little-endianLittle-endian Posts: 91
    edited 2009-05-25 02:16
    I'm not sure about this, but after recently watching Hanno's GoogleTalk presentation on ViewPort, I'm wondering if this is something that could be easily accomplished using ViewPort.
  • kwinnkwinn Posts: 8,697
    edited 2009-05-25 02:32
    Hyperterm and the prop USB cable should work for that if you can get the serial data out on the right pins.
  • rough_woodrough_wood Posts: 61
    edited 2009-05-25 02:44
    I ended up making a file out of the demo then copied from the Serial Terminal and brought it into Excel as comma separated values.

    I'll see if I can find out how to throw the Spin code in here. I changed the 3Axis and the Tick Tock object.
  • rough_woodrough_wood Posts: 61
    edited 2009-05-25 02:52
    This is my edited 3 Axis Demo
    {{
    *********************************************
    * H48C Tri-Axis Accelerometer VGA_DEMO V1.1 *
    * Author: Beau Schwabe                      *
    * Copyright (c) 2008 Parallax               *               
    * See end of file for terms of use.         *               
    *********************************************
    Revision History: 
    Version 1.0 - (Sept. 2006) - Initial release with a TV mode 3D-graphics cube
    Version 1.1 - (March 2008) - 3D-graphics cube removed  
                               - Basic VGA mode display used instead of TV
                               - Added 600nS padding delay around Clock rise and fall times
    }}
    {
         220Ω  ┌──────────┐
      P2 ──│1 ‣‣••6│── +5V       P0 = CS
         220Ω  │  ┌°───┐  │ 220Ω          P1 = DIO
      P1 ──│2 │ /\ │ 5│── P0      P2 = CLK
               │  └────┘  │ 220Ω
       VSS ──│3  4│── Zero-G
               └──────────┘
    Note1: Zero-G output not used in this demo                          
    Note2: orientation
             Z   Y    
             │  /    /   °/  reference mark on H48C Chip, not white dot on 6-Pin module 
             │ /    /    /
             │/     o   white reference mark on 6-Pin module indicating Pin #1
              ──── X
           ThetaA - Angle relation between X and Y
           ThetaB - Angle relation between X and Z
           ThetaC - Angle relation between Z and Y
     
    Note3: The H48C should be powered with a 5V supply.  It has an internal regulator
           that regulates the voltage down to 3.3V where Vref is set to 1/2 of the 3.3V 
           In this object, the axis is already compensated with regard to Vref. Because
           of this, the formulas are slightly different (simplified) compared to what is
           stated in the online documentation.
     
    G = ( axis / 4095 ) x ( 3.3 / 0.3663 )
            or
    G = axis x 0.0022
            or
    G = axis / 455
    
    An expected return value from each axis would range between ±1365.
    i.e.
     ±455 would represent ±1g
     ±910 would represent ±2g
    ±1365 would represent ±3g
    }
    CON
      _CLKMODE = XTAL1 + PLL16X
      _XINFREQ = 5_000_000
            CS = 0
           DIO = 1
           CLK = 2 
    VAR
        long vref,x,y,z,ThetaA,ThetaB,ThetaC,days,hours,minutes,seconds
    OBJ
        H48C  :     "H48C Tri-Axis Accelerometer"
        Dup   :     "FullDuplexSerialPlus"
        Time   :     "TickTock2"
    PUB DEMO_TEST
      'start and setup Accelerometer
     waitcnt(clkfreq*2 + cnt)
     H48C.start(CS,DIO,CLK)
     Dup.start(31, 30, 0, 57600)
     Time.start(0, 0, 0, 0)
     Dup.tx(16)
      repeat
         'vref := (H48C.vref*825)/1024   '<-- Here's how to get vref in mV
         vref := H48C.vref               '<-- Here's how to get vref in RAW
              
         'Note: The returned value for X, Y, and Z is equal to the axis - Vref
            x := H48C.x*100/455   '<-- Here's how to get x 
            y := H48C.y*100/455  '<-- Here's how to get y
            z := H48C.z*100/455  '<-- Here's how to get z
          'Note: The returned value is in Deg (0-359)
          'remove the '*45)/1024' to return the 13-Bit Angle
        ThetaA := (H48C.ThetaA*45)/1024   '<-- ThetaA is the angle relationship between X and Y
        ThetaB := (H48C.ThetaB*45)/1024   '<-- ThetaB is the angle relationship between X and Z
        ThetaC := (H48C.ThetaC*45)/1024   '<-- ThetaC is the angle relationship between Y and Z
        'Dup.Str(String("X "))
        Time.Get(@days, @hours, @minutes, @seconds)
        Dup.Dec(seconds)
        Dup.Str(String(", ")) 
        Dup.Dec(x)
        Dup.Str(String(", "))
        'Dup.Str(String(13, "Y "))
        Dup.Dec(y)
        Dup.Str(String(", "))  
        'Dup.Str(String(13, "Z "))
        Dup.Dec(z)
        Dup.Str(String(13))
         
        'Dup.Str(String(13, "ThetaA "))
        'Dup.Dec(ThetaA)
        'Dup.Str(String(13, "ThetaB "))
        'Dup.Dec(ThetaB)
        'Dup.Str(String(13, "ThetaC "))
        'Dup.Dec(ThetaC)
        waitcnt(clkfreq/10 + cnt)
        'Dup.tx(16)
    
    


    Then for the edited Tick Tock:

    '' From Parallax Inc. Propeller Education Kit - 6: Objects Lab
    ''File: TickTock.spin
    VAR
      long stack[noparse][[/noparse]50]
      byte cog
      long days, hours, minutes, seconds  
    
    PUB Start(setDay, setHour, setMinutes, setSeconds) : success
    {{
    Track time in another cog.
      Parameters - starting values for:
        setDay     - day
        setHour    - hour
        setMinutes - minute
        setSeconds - second
    }}
      days := setDay
      hours := setHour
      minutes := setMinutes
      seconds := setSeconds
      
      Stop
      cog := cognew(GoodTimeCount, @stack)
      success := cog + 1
    
    PUB Stop
    ''Stop counting time.
      if Cog
        cogstop(Cog~ - 1)
        
    PUB Get(dayAddr, hourAddr, minAddr, secAddr) | time
    {{
    Get the current time.  Values are loaded into variables at the
    addresses provided to the method parameters.
      Parameters:
        dayAddr  -  day variable address
        hourAddr -  hour variable address 
        minAddr  -  minute variable address
        secAddr  -  secondAddress
    }}
      long[noparse][[/noparse]dayAddr]  := days
      long[noparse][[/noparse]hourAddr] := hours 
      long[noparse][[/noparse]minAddr]  := minutes
      long[noparse][[/noparse]secAddr]  := seconds
      
    PRI GoodTimeCount | dT, T
      dT := clkfreq/10
      T  := cnt
      
      repeat
        
        T += dT
        waitcnt(T)
        seconds ++
    
    

    Post Edited (rough_wood) : 5/25/2009 5:45:02 AM GMT
  • PhilldapillPhilldapill Posts: 1,283
    edited 2009-05-25 05:07
    Just a note, rough_wood - code can be better formatted using the little # symbol. You just paste your code in there, and it preserves the indentation. Way to go!
Sign In or Register to comment.