Shop OBEX P1 Docs P2 Docs Learn Events
Accelerometer problems... — Parallax Forums

Accelerometer problems...

ABCDaveABCDave Posts: 4
edited 2006-05-21 14:59 in Robotics
Ok, I'm probably doing something wrong here, so·hopefully someone can point me in the right direction.
·
I use a BS2 with a BOE to develop my projects.· I am currently working a proportional control project and·had everything working on the BS2/BOE.· It was time to migrate over to a faster, more permanent platform - a BS2P w/ super carrier board.· I moved everything over, carefully soldered it all in place, and loaded the software.

Now I'm getting the strangest readings from my Memsic 2125:

·
X Input... 13.668 ms
G Force...· 6.664 g
X Tilt....· 90°

·
Y Input... 13.603 ms
G Force...· 6.560 g
Y Tilt....· 90°

·
That's what I'm getting on a flat table with no movement (may not be perfectly level).· No matter how I move the board, it's showing more or less the same G force.· No matter how I position the board, the angle always shows 90.· However, the X and Y input values will range from 9.9 to 16.5 in a consistent manner when the board is tilted along the axes, so I know the accelerometer is working.· These values are very consistent and even between the two axes, so I'm confident I didn't damage the accelerometer while soldering it to the board.· If I did burn it up,·it would either not work at all or the readings wouldn't be so equal and consistent.·
·
I'm·more or less using the·exact sample code as provided by Parallax.· It is the same code that ran fine on the BS2, only I·changed the header in the program in the first line of code·to accommodate the platform change (BS2 to BS2P), so that's not the problem.· I went from a battery pack to 12v 1a power supply, but I've tried the battery pack on the new platform and the readings are the same.·
·
Could it be the faster speed of the processor throwing off the readings or the math?· If so, does anyone have·sample code for the Memsic with BS2P stamps?· Does anyone have any other ideas as to what the problem is?
·
Thanks!
·
David

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-05-19 05:29
    David -

    If you are sure you are using a BS-2p and not a BS-2px, please ignore this posting. If not, this should help the situation.

    Near the beginning of the program there is a section which selectively sets the appropriate factor, based on the type of Stamp, to use in the Pulsin command. This program was written prior to the introduction of the BS-2px, so an additioanl factor will need to be added. Try adding the following to the existing factors:

    #CASE BS2PX
    Scale CON $0CE

    Please let us know if that improves the situation.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • ABCDaveABCDave Posts: 4
    edited 2006-05-19 13:48
    Thanks for replying, Bruce.

    I'm using the yellow BS2p chip, not the blue 2px.· However...·

    ...I believe you have pointed me in the right direction.· I haven't set up the pulsewidth scale for this stamp.· The sample code I have doesn't have the SELECT/CASE instructions to detect the stamp and·set the factor.· I haven't tried adding the additional instructions yet, but I'm pretty confident you straightened me out.

    Thanks again!
  • ABCDaveABCDave Posts: 4
    edited 2006-05-21 05:35
    Ok, so I got home and·factored in·the scale constant to my program's equasions·and the readings improved, but still weren't right.· I also noticed that in the BASIC Stamp Syntax and Reference Manual v2.2 that this constant was different for PULSIN and PULSOUT.· I would figure they'd be the same, but they aren't.· I had to hack around at the numbers and finally settled on the following value to zero out my angle and G force on a flat level surface:

    Scale·· CON·· $061

    I haven't seen this value documented anywhere.· The program works again, so it doesn't really bother me to use it, but it does have me curious.

    Does anyone know why this value is different for PULSIN and PULSOUT in the manual for the same stamp?· I'm going to be reading pulses from sensors·and sending pulses to motors, so·am I going to have to scale each individually or should this one value I have settled on work in both instances?

    Thanks again!

    David
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-05-21 07:15
    David -

    Although I do see differences for the Stamp BS-2pe and Stamp BS-2px, you said you were using the BS-2p so that shouldn't make any difference. I agree it seems a bit odd however. The differences with the BS-2pe also appeared in the PBASIC Stamp Version 2.1 Manual as well.

    Most accelerometers require a zeroing or calibration step, prior to use. I trust you either went through that process, or it wasn't required for some reason?

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • ABCDaveABCDave Posts: 4
    edited 2006-05-21 14:59
    Hi Bruce,

    I guess I got lucky right out of the box, because my 2125 / BS2 combo was "spot on" the minute I fired it up.· It didn't require any calibration or zeroing.· It wasn't until I changed platforms that it started reading incorrectly.· So I guess tweaking the pulsewidth factor counts as calibration, yes?· I'm just happy it works.· turn.gif
Sign In or Register to comment.