ADC & Calculations

Started by kjellosan January 22, 2005

Hi there

I have been trying for the last weeks to get different accelerometers
and gyro's to work together with my BX24. Finally I have got the
board from rotomotion to work. It contains one accelerometer
(adxl202) and a Tokin cg16do.

I have some problems with the readings and getting them scaled
correctly.

My readings at the moment is for the adxl202 Integer 500 (with
GetAdc) when it is laying flat on the table.
When I tilt it 90 Degrees one way I get a reading of 294 and similar
688 when I tilt the opposite way.

The output measured with my voltmeter is 2.50V when laying flat on
the table and 1.47V and 3.44V when tilted. I want my readings to show
Integer 0 to 1023 in my program, which means 512 when it is flat on
the table.

The output from my Gyro is 2.19V when laying still. This reading I
also would like to have around 512 when still, and in a range from 0
to 1023 when tilted. The Gyro has a sensitivity of 90 degr./sec. This
value will show the rate of tilt i believe.

Does anybody have a suggestion on how to do the calculations so I get
this right ?

I want to be able tp get the values scaled so I can use them in a
kind of Kalman fliter. Maybe you also know what the weights I can use
on the values to fuse them togehter ? As you probably have
understood, I will use these in a balancing robot.

Thank you for response.



I haven't done this before but here are my thoughts:

1. You probably need to do some more measurements to determine the
linearity and center of the device. For example the average of your two
readings (294 and 688) is 491 and not 500. Is this measurement error or
is one side of the device different to the other? Is this something you
need to take into account with your calculations?

2. It seems like you want to normalize to a different range i..e from
294..688 to 0..1023. The basic math is fairly straightforward with some
floating point calculations e.g CInt((CSng(x-294))*2.6)-1 should do it.
But you do really want to normalize to this range? Would 0..255 or
-127..+127 be better? Or even some other range?

I would do a google search for other people who have used these devices.
I think the hard bit will be to find something suitable and the easy bit
is translating from their language (C, Basic, Asm etc) to BasicX.

Hope this helps,
Mike

>Hi there
>
>I have been trying for the last weeks to get different accelerometers
>and gyro's to work together with my BX24. Finally I have got the
>board from rotomotion to work. It contains one accelerometer
>(adxl202) and a Tokin cg16do.
>
>I have some problems with the readings and getting them scaled
>correctly.
>
>My readings at the moment is for the adxl202 Integer 500 (with
>GetAdc) when it is laying flat on the table.
>When I tilt it 90 Degrees one way I get a reading of 294 and similar
>688 when I tilt the opposite way.
>
>The output measured with my voltmeter is 2.50V when laying flat on
>the table and 1.47V and 3.44V when tilted. I want my readings to show
>Integer 0 to 1023 in my program, which means 512 when it is flat on
>the table.
>
>The output from my Gyro is 2.19V when laying still. This reading I
>also would like to have around 512 when still, and in a range from 0
>to 1023 when tilted. The Gyro has a sensitivity of 90 degr./sec. This
>value will show the rate of tilt i believe.
>
>Does anybody have a suggestion on how to do the calculations so I get
>this right ?
>
>I want to be able tp get the values scaled so I can use them in a
>kind of Kalman fliter. Maybe you also know what the weights I can use
>on the values to fuse them togehter ? As you probably have
>understood, I will use these in a balancing robot.
>
>Thank you for response. >
>