Show Posts
Pages: 1 ... 55 56 [57] 58 59 ... 68
841  Using Arduino / Sensors / Re: MMA7260QT Accelerometer Help on: June 13, 2012, 06:05:22 pm
The benefit of the real 'g-force' or the raw analogRead() value for the offset is better to read code.

This is your module: http://www.liquidware.com/shop/show/SEN-3AX/3-axis+Accelerometer+Module
That module is 5V tolerant. It looks as if there is a voltage regulator for 3.3V  on the module.
So you should connect it to 5V.
According to the cheatsheet, also the range selection pins could be connected to 5V or GND.

Mostly the z-axis is up.

If AREF is not connected (to 3.3V) anymore, the default range of the analog input is 5V again.
So you have range 2g selected.

The way you adapted the example code is okay.
I would like to take it one step further (expect some errors in the code, I didn't test it):
Code:
// MMA7260QT Accelerometer
//
// The range is set with two pins (g-Select1 and g-Select2).
// It can be set to : 1.5, 2.0, 4.0 or 6.0 g
// The output signal is regardless of the voltage.
// It is :
//      800mV/g for range 1.5 g
//      600mV/g for range 2 g
//      300mV/g for range 4 g
//      200mV/g for range 6 g
//
// For 2 g range, and the accelerometer at 3.3V,
// and an analog input with 5V reference (=DEFAULT),
// the calculation is this:
//     voltage = raw * 5V / 1023steps
//     g =  voltage / 600mV
//
// However, if the Aref is connected to 3.3V, the
// full range is 0 ... 3.3V for 1024 steps.
//     g = analogRead(channel) * 3.3 / 1023.0 / 0.6;
//

...

void setup()
{
  // The y-axis points up, so the y value should be 1g for the earth gravity.
  // The values are the values at start. The 1g for the z-axis is taken
  // care for later in the program.
  center_x = give_me_my_g (ACC_X);  // value at 0g (horizontal)
  center_y = give_me_my_g (ACC_Y);  // value at 0g (horizontal)
  center_z = give_me_my_g (ACC_Z);  // value at 1g (pointing up)
}

void loop()
{
  // The z-axis offset "center_z" is not at zero g, but at 1 g.
  // So add 1 to the acc_z.
  acc_x = give_me_my_g (ACC_X) - center_x;             // remove the center (the offset)
  acc_y = give_me_my_g (ACC_Y) - center_y;             // remove the center (the offset)
  acc_z = give_me_my_g (ACC_Z) - center_z + 1.0;  // remove the center (the offset), add 1
}

double give_me_my_g (int channel)
{
  double g;
 
  // analogRead can be used without setting the pinMode.
  // 5.0 : The default range of the ADC, (3.3 if Aref connected to 3.3V)
  // 1023.0 : the maximum raw value at the maximum voltage
  // 0.6 : the number of mV/g. It is 600mv/G for 2g range.
  g = (double) analogRead(channel) * 5.0 / 1023.0 / 0.6;
  return (g);
}


An example of someone with that kind of module: http://antipastohw.blogspot.nl/2010/03/making-of-gravitational-rc-driving-by.html

->edit: I thought that the y-axis was up, but it is the z-axis, this post changed for z-axis.
842  Using Arduino / Microcontrollers / Re: Debugging UNO standalone - Help needed on: June 13, 2012, 11:35:38 am
I'm glad you have a workaround.
Thanks for the photo.
843  Using Arduino / Sensors / Re: MMA7260QT Accelerometer Help on: June 13, 2012, 10:40:56 am
That's good I think.

I don't know if your values are good 'g-force' values.

You use the offset to get everything close to 0.0.
For a balancing robot for example, the default for the Z-axis should be 1 g.
If the sensor is horizontal flat, the Z-axis is pointing up, and that would be 1g.
This could be done in the setup() part.
Flipping it upside-down would make the Z-axis -1 g.

In your case, you need to measure the motion, so you need the relative acceleration. So in your case calibrating everything to 0.0 might also be okay.

You might to change your code. Use the offset eighter as the real 'g-force' or as the analogRead() values. At this moment it is not obvious what the unit of "center_z" is. And you also need to add some comments.
844  Using Arduino / Sensors / Re: MMA7260QT Accelerometer Help on: June 13, 2012, 02:06:05 am
If you use your sensor just as in the photo, is it upside-down ?

If you check the datasheet, the zero-g is about 1.65V, but it's not calibrated. So you might have to calibrate the zero-g values to zero in program code.
845  Using Arduino / Project Guidance / Re: Arduino + Twitter + Electric Valve + USB + Plants? on: June 13, 2012, 01:56:12 am
You could read this thread: http://forums.adafruit.com/viewtopic.php?f=25&t=18735

What is outdated ?
846  Using Arduino / Programming Questions / Re: Arduino + Ethernet + DS1307 overflow(?) error on: June 13, 2012, 01:52:50 am
Do you use this libary ? http://arduino.cc/playground/Code/Time

I'm looking at the library right now, but it is not easy to understand.
You could have a ram or stack overflow, or the Time library could have problems with rollover.

You check timeStatus() for timeSet, but can you check which value it is ? Is it "timeNotSet" or "timeNeedsSync".
If it is "timeNeedsSync" you might just ignore that value and try once more.

You might have a rollover problem in you own code.
If you use millis() for example.
Can you measure somehow how long it takes to freeze ? Is it the same every time ?
847  Using Arduino / Microcontrollers / Re: Atmega32 support for arduino 1.0.1 on: June 13, 2012, 01:39:25 am
The question has been asked before : http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1281368658

The answer was: It's not going to work.
848  Using Arduino / Microcontrollers / Re: Debugging UNO standalone - Help needed on: June 13, 2012, 01:35:18 am
That's hard to tell, because there are many things that could be wrong.
The information you give is just a fraction of what would be needed to pinpoint the problem.

Did you try to use the original Uno firmware for both chips ? Does the Arduino Uno use Optiboot? I'm not sure about that.
If you did, the might be something wrong with the hardware of the ATmega16u2. Can you check that once more againgst the schematic of the Uno ?

But why not use an Arduino Uno in the first place ? It already acts as a com-port to the PC, and it is working.

Did you check out the new Arduino Leonardo ? The Arduino 1.0.1 has already examples for the Arduino Leonardo to make it behave like a keyboard of a mouse with its USB bus.
849  Using Arduino / Programming Questions / Re: 74HC595 basics on: June 13, 2012, 01:26:43 am
Don't cross-post:

http://arduino.cc/forum/index.php/topic,109704.msg823827.html
http://arduino.cc/forum/index.php/topic,109711.msg823866.html
http://arduino.cc/forum/index.php/topic,109719.msg823901.html
http://arduino.cc/forum/index.php/topic,109713.msg823871.html
850  Using Arduino / Sensors / Re: Would a 3v Negative Voltage Spike Damage the A/D converter? on: June 12, 2012, 11:24:37 am
It might damage the input.

You can use a resistor of 1k to 10k in series with the input.
That will almost not reduce the maximum input frequency, due to the high impedance of the input.

If you use a diode, use a schottky diode. Most of them can handle high frequencies with ease.


What is the minimum pulse length for an interrupt ? I think it is about 100ns, but I can't read it in the datasheet.
851  Using Arduino / Microcontrollers / Re: Read an ATtiny13 on: June 11, 2012, 05:39:30 pm
Why not buy a very cheap USBasp programmer and read the firmware and also read the fuses.
That way you can always set the original firmware and fuses back.

Once you have that working, you could use the Arduino as an ISP.
This is a good starting point: http://arduino.cc/en/Tutorial/ArduinoISP
852  Using Arduino / Sensors / Re: Gyroscope-L3G4200D & Arduino Mini Pro Compatibility on: June 10, 2012, 08:17:23 pm
The original Arduino Pro Mini is with an ATmega168. But everything should be the same.
I would prefer a Uno, Nano or Pro Mini with an ATmega328.

If the Arduino board doesn't have the 3.3V on board, you could use that sensor from Pololu, which has a voltage regulator itself and even an I2C voltage shifter ( http://arduino.cc/playground/Main/I2CBi-directionalLevelShifter ).

The Nano has got an 3.3V on board. In that case you don't need the sensor board with voltage regulator and you can do without the I2C level shifter.

How to use the pins, is reading the datasheet and checking the Pololu schematic.

CS: datasheet: "1" for I2C. Pololu schematic: already "1" with pull-up resistor.
SDO: datasheet: in I2C mode SDO = SA0, lowest bit of address. Pololu schematic: pulled high, addres bit is '1'.
According to table 13 of the datasheet, the I2C-address will be 0xD3 for reading, and 0xD2 for writing.

So you connect Vin to +5V and connect GND, SCL, SDA. That's it.

The L3G4200D is not yet in the Playground sensor section: http://arduino.cc/playground/Main/InterfacingWithHardware#motion_accelerometer
853  Using Arduino / Sensors / Re: MPU-6050 how to change rate of MPU generated fused data on: June 10, 2012, 07:54:44 pm
You sure take a deep dive into the MPU-6050.

These pages:
http://permalink.gmane.org/gmane.linux.kernel.iio/4339
http://permalink.gmane.org/gmane.linux.kernel.iio/4346
have a function inv_init_config(), which sets the fifo rate at 50Hz. Is that of any help ?

You could ask Jeff.
854  Using Arduino / Sensors / Re: gyroscope L3G4200D on: June 08, 2012, 06:12:51 pm
If you read the datasheet more carefully, it's all there.

DR = Data Rate : two bits for the output data rate in the CTRL_REG1 for 100/200/400/800Hz
BW = Band With : two bits for the Bandwidth selection in the CTRL_REG1. See the table for the Cut-Off.
How this Cut-Off is actually used, is not very clear in the datasheet.
It is used in combination with the filters.
HPF = High Pass Filter. Higher frequencies are passed. Slow motion is filtered out.
LPF = Low Pass Filter. Higher frequencies are blocked, to reduce noisy or jumpy results.

What the best settings are, is hard to tell. You might look for a good example and use that.
855  Using Arduino / Sensors / Re: are these ADXL345 accelerometers broken or they just suck? on: June 08, 2012, 04:21:28 am
I had the same thing. It turned out it was the vibration of my computer on the same table.

Although only your fourth sensor has good readings, it is more likely that there is something with your code or connections.
Start with just one ADXL345 on the SPI bus, and try to get it right.

Hardware:
Is it connected to 3.3V ? Do you use 4-wire SPI mode ? How is the 'CS' connected ?

Software:
Do you use an example or library ? Which one ? Can you upload your code ? Are you sure the bytes are in the right order ?

Do you know there are links in the Accelerator section in the Playground : http://arduino.cc/playground/Main/InterfacingWithHardware#motion_accelerometer

I think you need to calibrate the offset anyway. As fas as I know all MEMS-based sensors need to be calibrated. Check the datasheet for "Offset Calibration".

In the end, they can get broken if they are hit too hard. But the ADXL345 can survive 10.000 g  shock ! That's more than many other sensors.
Pages: 1 ... 55 56 [57] 58 59 ... 68