I have a Fez Mini with the SMB380 accelerometer, but when i lunch the program with the genuine driver the result is :
‘System.InvalidOperationException’ in Microsoft.SPOT.Hardware.dll
the error occurs in this source code :
static private void WriteRegister(byte address, byte value)
{
write[0] = address;
write[1] = value;
_spi.WriteRead(write, read); <===ERROR
}
hello,
sorry, i was on holidays…
i found the error, the correct code for the bus initilisation is :
SPI.Configuration config = new SPI.Configuration((Cpu.Pin)FEZ_Pin.Digital.UEXT10 , false, 0, 0, true , true,200, SPI.SPI_module.SPI1);
200 is the correct value instead 100
the driver code is false, when we try to obtain x, y and z values, ther are not well compute :
wrong code :
static public void GetXYZ(out sbyte x, out sbyte y, out sbyte z)
{
x = (sbyte)ReadRegister(0x02);
x = (sbyte)ReadRegister(0x03);
......
correct code would be (i hope) :
static public void GetXYZ(out int x, out int y, out int z)
{
int x1, x2, y1,y2,z1,z2;
x2 = (sbyte)ReadRegister(0x02); //LSB 6 7
x1 = (sbyte)ReadRegister(0x03); //MSB 0 7
x = (x1 << 2) | (x2 >> 6);
one question :
with smb380, is it possble to know the direction (right, left, up, down, …) ?
the acceleration value is not enough to obtain this information.
my project : to track the position of an object without GPS, only with accelerometer and gyro.
[quote]with smb380, is it possble to know the direction (right, left, up, down, …) ?
the acceleration value is not enough to obtain this information.[/quote]
The smb380 is a good 3 axis acceleration sensor you can tell how fast you are going and what not in a certain direction. To know true direction and orientation you will want a gyro. The real thing you get to know with a gyro is what is truly down and up. Combining the out put from both a acceleration sensor and a heading hold gyro you can almost get dead reckoning. of course that really depends on how close to dead reckoning you need to get to you can use a cheaper gyro that just shows rate. i have used a couple of these http://store.diydrones.com/ProductDetails.asp?ProductCode=BR-0005-10 before not in the .net world. builtin a previous quad copter based on arduino. With both combined you can be sure that you know the direction you are going from the position you started and how fast and if any terrain caused tilt needing compensation.
right thats why you use both a gyro and a acceleration sensor.
edited to expand on that.
An acceleration sensor is a sensor that measures acceleration or translational motion. A gyroscope is an angular rate sensor - it measures the rate of angular rotation. While angular acceleration sensors do exist, they are rarely used and freaking expensive. A gyro’s angular rate output is integrated to determine angular heading which in turn is used to determine if you have been turning and by how much. When combined with displacement information from your acceleration sensor you can figure out your position.
Both devices can come as something that does both. They just get much more expensive then using 2 of the cheaper devices together.
The problem is not so simple, because if the values of the SMB380 are between -512 and +512, they represente an acceleration, and not a position.
An example : you are on a your zero point, you accelerate (the value is positive), you brake (the value is negative), but your direction is the same in the 2 cases.
my project :
i’m a diver, and one of the diver’s problems is to be able to find the boat after one hour under the sea.
I’m looking for an inertial navigation unit to reach the zero point when i finish my dive.
something a underwater GPS, but GPS is unavailable in water…
Your xyz acceleration add in time = distance and direction traveled from you starting position. The way you do it is determine how far you can go at a certain acceleration an time. If you need to know your turning you can use the x and y to determine at which rate you are turning. you can also add in the z to determine level of accent and decent at the same time. Just be sure to measure time to travel at multiple speeds and directions including ramp up time if you are using some form of PID control. With enough measurements and coming up with a good algorithm you can determine exactly how far you are from your starting position and where. GPS on land or water is very inaccurate for small devices where you can be off by 1.5 meter to 3 meters. I never use it on a dead reckoning robot even with 2-3 GPS modules feeding coordinates. You will never be where it says you are due to the distance it can be off. I have used what i described before to end up .5 inches where i started after a weaving 600 ft course. It will just take time to measure and tune.