Shop OBEX P1 Docs P2 Docs Learn Events
Best way to get lean angle of a motorcycle - Page 4 — Parallax Forums

Best way to get lean angle of a motorcycle

124»

Comments

  • W9GFOW9GFO Posts: 4,010
    edited 2013-08-02 18:09
    Dr_Acula wrote: »
    unless... the merry-go-round is on the back of a flat bed truck and the truck is moving up and over a small hill. The Z axis is no longer one gee and you can't tell if it was the hill or the tilt that changed the Z reading..

    The problem is fundamentally the same as trying to fly a plane in clouds - it needs an artificial horizon and gyros are very cheap nowdays.

    It is not the same because it is constrained to the ground. True that there would me momentary fluctuations due to dips and rises but they cannot be sustained and therefore can be dealt with.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-08-02 18:37
    Rich,

    A merry-go-round is not the same as a motorcycle and cannot be used to illustrate the same dynamics. The reason is that it's constrained not to tilt. But a motorcycle tilts in order to acheive dynamic equilibrium, and that equilibrium is reached when the transverse acceleration vector is zero. Rotating a two-axis accelerometer accomplishes nothing towards ferreting out the tilt angle.

    -Phil
  • W9GFOW9GFO Posts: 4,010
    edited 2013-08-02 19:11
    The point of the merry-go-round example was to illustrate that an accelerometer axis pointing straight up will read one gee regardless whether or not it is experience centripetal forces. A motorcycle going around a curve at a 45 degree lean angle, with two accelerometers oriented at 45 degrees to each side of the motorcycle's centerline will have one axis pointing straight up, reading exactly one gee. The motorcycle tilts to average out the accelerations. The individual axis' of the accelerometers will sense the forces individually.

    You should be able to calculate the one gee vector using data from the two axis' rather than actually tilting the accelerometer, you can also find the vector normal to the motorcycle which would be the same as the vector with the highest acceleration.

    The motorcycle responds to a combination of all forces but the accelerometer only responds to acceleration along its axis. On flat ground (no dips or rises) there will always be an angle where the accelerometer will read one gee. If you find that angle then you know where straight up is.
  • ElectricAyeElectricAye Posts: 4,561
    edited 2013-08-02 19:48
    W9GFO wrote: »
    ... On flat ground (no dips or rises) there will always be an angle where the accelerometer will read one gee....

    That's true. The problem is, you can find that 1 G measurement by turning your accelerometer either clockwise or counterclockwise away from the direction of maximum acceleration (the Big A) seen by the accel.
    W9GFO wrote: »
    ... If you find that angle then you know where straight up is.

    And, on a statistical basis, you will be right about half the time because of what I mentioned above.

    I think you are still looking at this problem from one frame of reference (standing with your feet on the ground) while Gorga is speeding around in a different frame of reference (the moving motorcycle).
    ...
    A merry-go-round is not the same as a motorcycle and cannot be used to illustrate the same dynamics. The reason is that it's constrained not to tilt. But a motorcycle tilts in order to acheive dynamic equilibrium, and that equilibrium is reached when the transverse acceleration vector is zero. ...

    What Phil is saying is the gospel truth. What drives everyone crazy with problems like this is that, while gravity and acceleration arise from different phenomena, they often appear to be the very same thing. Once they get mingled together in a frame of reference, you can't tell one from the other. You measure gravity the same way you measure acceleration, so for all practical purposes they are the same thing. So, in a sense, they dissolve into each other and you can't tell one component from another: they summate and then you are stuck rolling around somewhat blind in your very own little frame of reference. Without some kind of outside reference, you can't really see what's happening. Which is why pilots get confused if they can't see out their window and don't know how to read their instruments correctly. It sucks. But gravity and acceleration are just so promiscuous that way.
  • W9GFOW9GFO Posts: 4,010
    edited 2013-08-02 19:51
    That's true. The problem is, you can find that 1 G measurement by turning your accelerometer either clockwise or counterclockwise away from the direction of maximum acceleration (the Big A) seen by the accel.

    Only if you have not been tracking previous readings.
  • ElectricAyeElectricAye Posts: 4,561
    edited 2013-08-02 20:06
    W9GFO wrote: »
    Only if you have not been tracking previous readings.

    With a single accel, I don't think tracking would help. Consider Heater's example again: if you have a glass of beer sitting on Gorga's lap and she drives the motorcycle the way she's supposed to around any number of arcs, then she can gaze upon that glass of beer all she wants to, but she will never see the fluid rise up on one side or the other. What would tracking present to you that the glass of beer would not otherwise reveal?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-08-02 20:10
    Rich,

    You're finally starting to make sense! :) But you do not need a two-axis accelerometer, and I think that's what's throwing people off of your argument. One axis, mounted perpendicular to the seat, is enough, viz:

    attachment.php?attachmentid=103183&d=1375499313

    The tilt angle, a can be computed as follows:
    a = cos-1(1G / Measured Accel.)

    This will work, at least, up until this point:

    733811_545274735517192_1732466692_n.jpg

    Then I think all bets are off!

    -Phil
    344 x 396 - 23K
  • ElectricAyeElectricAye Posts: 4,561
    edited 2013-08-02 20:21
    The problem is, from the inertial frame of reference of the motorcycle, you also have vectors that look like this. And without any other reference, you don't know which ones are the "right" ones to measure. But, as I've already said, as a practical matter, you could probably use this >1 G sensing method so long as you're willing to live with errors generated by vertical accelerations.

    motorcycle_lean2.gif
    344 x 396 - 21K
  • ercoerco Posts: 20,256
    edited 2013-08-02 20:23
    @phipi: That's what I said (or intended to imply) several pages ago. But as Rich so aptly pointed out, you don't get direction of lean nor any potential compensation from acceleration due to dips & crests in the road.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-08-02 20:23
    Okay, you don't get the direction of the lean, just the angle. But I think that's all the OP was after. And, yes, dips and crests in the road do throw a wrench into the works. But at least I think we have some universal understanding to start with -- finally.

    -Phil
  • W9GFOW9GFO Posts: 4,010
    edited 2013-08-02 20:48
    Okay, now put an accelerometer on the handlebars, 90 degrees to the other axis. Can you determine the direction of lean now?

    attachment.php?attachmentid=103184&d=1375500026
  • ElectricAyeElectricAye Posts: 4,561
    edited 2013-08-02 20:52
    W9GFO wrote: »
    Okay, now put an accelerometer on the handlebars, 90 degrees to the other axis. Can you determine the direction of lean now?

    attachment.php?attachmentid=103184&d=1375500026

    I'm afraid not. At 90 degrees to the "Measured Accel" in the drawing, you would read zero. If you didn't read zero, your motorcycle would flop on its side.
  • xanaduxanadu Posts: 3,347
    edited 2013-08-02 21:35
    I tried it with a single accelerometer and it works until your angle becomes constant then it shows you as upright. I guess that is why you need a gyro. This video isn't clear but you get the idea.

    [video=youtube_share;zp9w9E68U8Q]

    If you watch full screen at 720 you can see the LCD display around a corner. I put a lot of power into it and it still read the turn until the steepest part where it bounced back to center(ish).
    {{
    
    ***MODIFIED FOR 10 BIT Y AXIS ONLY USE AT OWN RISK***
    ***SEE PRODUCT PAGE FOR ORIGINAL CODE***
    
    }}
    CON
    
      _clkmode      = xtal1 + pll16x
      _xinfreq      = 5_000_000
    
      CLKPIN        = 8
      DATAPIN       = 9
      CSPIN         = 10
    
      Y_OFFSETVAL   = 50            ' Y-Axis offset compensation value
    
    VAR
    
      long  XYZData[3]
      
    OBJ
    
      Term          : "FullDuplexSerial"     'Used to Communicate to the PC
      SPI           : "MMA7455L_SPI_v2"      'Used to Communicate to the Accelerometer
      lcd           : "SparkFun_serial_lcd"  'Used to Communicate to the LCD  
      
    PUB main
    
      lcd.init(11,9600,2,20)
      lcd.displayOn               
      lcd.cursor(0)
      lcd.backlight(true)
      lcd.clrln(1)
      lcd.clrln(0)
    
      'Initialize the serial COM so that we can see the data on the PC
      Term.start(31, 30, 0, 38_400)
    
      'Initialize the device
      SPI.start(CLKPIN, DATAPIN, CSPIN)
    
      waitcnt(clkfreq/100+cnt)
    
    
      SPI.write(SPI#YOFFL, Y_OFFSETVAL)
      SPI.write(SPI#YOFFH, Y_OFFSETVAL >> 8)
      
      term.tx(0)                    'Clear the Display
      repeat
        term.tx(1)                  'Home the Display
        waitcnt(clkfreq/100+cnt)
        Read10BitData
        Display
        lcd.gotoxy(0, 0)
        waitcnt (clkfreq / 10 + cnt)
      
    
    
    PUB Read8BitData(G_RANGE)
        SPI.write(SPI#MCTL, (10 << 4)|(G_RANGE << 2)|SPI#G_MODE) 'Initialize the Mode Control register
    
        XYZData[1] := SPI.read(SPI#YOUT8)                       'repeat for Y-axis
    
    
    PUB Read10BitData
        SPI.write(SPI#MCTL, (10 << 4)|SPI#G_MODE)                 'Initialize the Mode Control register
        DataIn_High := SPI.read(SPI#XOUTH)                       'repeat for X-axis
        DataIn_Low  := SPI.read(SPI#XOUTL)
        XYZData[0]  := DataIn 
        DataIn_High := SPI.read(SPI#YOUTH)                       'repeat for Y-axis
        DataIn_Low  := SPI.read(SPI#YOUTL)
        XYZData[1]  := DataIn    
        DataIn_High := SPI.read(SPI#ZOUTH)                       'and Z-axis
        DataIn_Low  := SPI.read(SPI#ZOUTL)
        XYZData[2]  := DataIn    
    
    PUB Display
    
        term.str(string(13,"Y= "))
        term.dec(~XYZData[1])
        term.str(string("  "))
        lcd.str(string("     "))
        lcd.dec (~XYZdata[1])
        lcd.str(string("    "))
        
        if (~XYZdata[1]) <1  
          lcd.gotoxy(0, 1)
          lcd.str(string("     LEFT      "))
    
        if (~XYZdata[1]) >1  
          lcd.gotoxy(0, 1)
          lcd.str(string("     RIGHT     "))
        
          
          
    
    
    DAT
    
    DataIn        word              ' Data positioning trick to convert Words to Bytes
    DataIn_Low    byte    0         ' or Bytes to a Word without using any math overhead
    DataIn_High   byte    0
    
    DAT
    {{
    &#9484;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;  &#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;  &#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9488;
    &#9474;                                                   TERMS OF USE: MIT License                                                  &#9474;
    &#9500;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;  &#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;  &#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9508;
    &#9474;Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation    &#9474;
    &#9474;files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,    &#9474;
    &#9474;modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software&#9474;
    &#9474;is furnished to do so, subject to the following conditions:                                                                   &#9474;
    &#9474;                                                                                                                              &#9474;
    &#9474;The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.&#9474;
    &#9474;                                                                                                                              &#9474;
    &#9474;THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE          &#9474;
    &#9474;WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR         &#9474;
    &#9474;COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,   &#9474;
    &#9474;ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                         &#9474;
    &#9492;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;  &#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;  &#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9496;
    }}
    

    I'll probably redo the video part and maybe add a gyro too.
  • xanaduxanadu Posts: 3,347
    edited 2013-08-02 21:37
    Just a thought but you could easily test this in a car going around a corner just manually tilt the sensor like a bike would.
  • ElectricAyeElectricAye Posts: 4,561
    edited 2013-08-02 21:47
    xanadu wrote: »
    I tried it with a single accelerometer and it works until your angle becomes constant then it shows you as upright. I guess that is why you need a gyro. ....

    I am off-the-chart impressed that you would try this out for us! I must be honest that I can't tell much from the video, but I'm blown away that you would give this a go. If you do any more tests, please post them. But also please be careful. During the course of thinking about this problem, I ran across images of "road rash". Ouch.
  • xanaduxanadu Posts: 3,347
    edited 2013-08-03 09:46
    I am off-the-chart impressed that you would try this out for us! I must be honest that I can't tell much from the video, but I'm blown away that you would give this a go. If you do any more tests, please post them. But also please be careful. During the course of thinking about this problem, I ran across images of "road rash". Ouch.

    Thanks! I will be doing some more testing soon. The video is really bad I will redo during the day and figure out a way to make it easier to see the readout. I might wait until the next track day and do some extreme leaning :)
Sign In or Register to comment.