ðŸ”®Adafruit sale all weekend long â€“ use the code ADATHX for 15% off! ðŸ”®

Hi mates!
IÂ´m facing a doubt in this project due to my lack of knowledgment with accelerometers, despite my commitment during the weekend :(
First of all, I must say that I wonÂ´t use the SNES pad. Instead, I only want to connect the teensy and the accelerometer adxl335, and put them in a pair of glasses.
The goal is to move the field of view (of a first person shooter game, f.example), moving my head :lol:

So the problem is that in the code available here : http://github.com/adafruit/USBgamepad/b ... _test2.pde
we have this constants for the accelerometer:

Code: Select all | TOGGLE FULL SIZE
`//The average zero acceleration values read//from the accelerometer for each axis:const int cintZeroXValue = 328;const int cintZeroYValue = 328;const int cintZeroZValue = 328;//The maximum (positive) acceleration values read//from the accelerometer for each axis:const int cintMaxXValue = 396;const int cintMaxYValue = 396;const int cintMaxZValue = 396;//The minimum (negative) acceleration values read//from the accelerometer for each axis:const int cintMinXValue = 256;const int cintMinYValue = 256;const int cintMinZValue = 256;`

I think that this values were measured placing the accelerometer in certain positions. For example, I think that the first block (328,328,328) was measured placing the accelerometer horizontally on a table... Am I right?

However using the same accelerometer (adxl335), and placing it on a table I get 302;396 and 327 for x y and z ...I was expecting to get 1024/3=341 for each axis...In addiction the value for the x axis is very unstable, despite having the accelerometer unmovable on the table.

So , what IÂ´m doing wrong ? anyone could help me regarding the calibration positions?

Thanks for all!

Best regards
eduardo
eduardo

Posts: 17
Joined: Thu Mar 04, 2010 11:36 am

a generic reply, but there's going to be local deviations, noise and slight calibration differences to take into account, and your table probably isn't flat.

but they're average and range values, so it should be the average home position, then the max/min ranges.

so add up a sampled range of home xyz. then divide by the number of samples, and thats a simple average.
http://032.la - Null Space Labs.
charliex

Posts: 179
Joined: Sat Nov 28, 2009 5:54 pm
Location: Las Vegas

Charliex!
Thanks a lot for your reply. However what I want to know is: in what positions should I place the accelerometer in order to collect the samples?
best regards

eduardo
eduardo

Posts: 17
Joined: Thu Mar 04, 2010 11:36 am

You probably want to put it in what will be the 'neutral' orientation in actual use.

Posts: 79404
Joined: Sat Feb 07, 2009 10:11 am

Thanks, btw i will give you an example to clarify my doubt.
First , I want to get the average zero acceleration values read from the accelerometer for each axis.
For this IÂ´m placing the accelerometer horizontally on my table. I did the average of a sample and I got 302, 396 and 327 for x y and z.
Considering that IÂ´m correct in my above assumption, now I want to get the the maximum (positive) acceleration values read
from the accelerometer for each axis, and finally the minimum (negative) acceleration values read from the accelerometer for each axis. The problem is that I donÂ´t know how the accelerometer should be placed to get these values :oops:

Can you help me to go further?

best regards

eduardo
eduardo

Posts: 17
Joined: Thu Mar 04, 2010 11:36 am

The zero values should be from the neutral orientation in actual use. If you are calibrating from a flat tabletop, then you should make sure it is horizontal when mounted in your glasses.

The min and max values should be measured at the expected limits of movement. Using your neutral position(probably head up, eyes straight ahead) as a reference, tilt your head to the positions you want to be full forward, full back, full left & right. Take measurements at these angles and those will be your minimum & maximum.

Posts: 79404
Joined: Sat Feb 07, 2009 10:11 am

Hi mates!
Today I had a free time and I decided to pick up again this project!
My doubt lies in the equations used in the tutorial to calculate the mouse movement for each axis.
For example for x axis we have:

intMouseXMovement = cintXSign * ( ( ( (float)( 2 * cintMaxMouseMovement ) / ( cintMaxXValue - cintMinXValue ) ) * ( intAnalogXReading - cintMinXValue ) ) - cintMaxMouseMovement );

Where is this equation coming from? I compared this with the motion equation x=x0+v(t-t0), but theyÂ´re not similar!
this is the link for the tutorial code :

Anyone could help me?

Best regards

Eduardo
eduardo

Posts: 17
Joined: Thu Mar 04, 2010 11:36 am

This equation is converting between sensor units and mouse-move units. It helps to break it down:

( intAnalogXReading - cintMinXValue ) subtracts the minimum scale value from the actual reading to get a value relative to the minimum scale (which is not zero for this sensor)

( cintMaxXValue - cintMinXValue ) results an a value representing the range of valid sensor readings

(float)( 2 * cintMaxMouseMovement ) / ( cintMaxXValue - cintMinXValue ) gives you a scaling factor to convert from sensor readings to +/- mouse movements

Posts: 79404
Joined: Sat Feb 07, 2009 10:11 am

Hi!
Allright! YouÂ´re god!!!! Thanks a lot, and sorry for my lack on maths and electronics :P

Thanks again!
Eduardo
eduardo

Posts: 17
Joined: Thu Mar 04, 2010 11:36 am