Show Posts
Pages: 1 2 [3] 4 5 ... 202
31  Using Arduino / Sensors / Re: Reading Honda MAP sensor without adverse affects? on: August 17, 2014, 11:51:18 am
what answer do you get when the analog voltage results in gearSensor = 550 ?
32  Using Arduino / Programming Questions / Re: FSM diagrams: states and transistions on: August 17, 2014, 11:35:23 am
You can have any convention you like.

If you take the view that the boxes represent the "states",   and the arrows represent the "transitions",     then if you want to label what the actual action is that is taken to transfer from one state to the next,   you have to have captions floating around the picture awkwardly next to the arrows,   as the example in the preceding post shows.

On the other hand,   if you have more of a "flowchart" mindset,   it is the actions or steps of the process which go inside the boxes.   You can use different shapes of box to indicate actions,   final or intermediate endpoints ( "states" ),    and also different boxes for branches.



33  Using Arduino / Motors, Mechanics, and Power / Re: dc motors without arduino motor shield on: August 17, 2014, 05:17:13 am
Not sure exactly what you mean by "alkaline 9V",    it is probably like the other one,  has several tiny batteries in one package  and cannot supply large current.
34  Using Arduino / Sensors / Re: Difficulty Interfacing "High Accuracy Dual Axis Inclinometer TOY0048" on: August 16, 2014, 09:57:41 am
It does tell you,  however,  that the device uses SPI  (  and not I2c,  or analog,  or serial,  or pulses ).

That's better than no information at all.
35  Using Arduino / Sensors / Re: MPU 6050 i2cWrite failed: 2 on: August 15, 2014, 09:25:57 am
You should check very carefully whether the MPU 6050 requires the "stop" or "repeat start" condition.

Unlike freescale devices,  the MPU6050  works with the default setting for Wire,  not the unusual setting.
36  Using Arduino / Sensors / Re: Interfacing ADIS 16210/PCBZ with Arduino on: August 15, 2014, 09:22:23 am
Is google broken in your country ?

http://www.analog.com/static/imported-files/data_sheets/ADIS16210.pdf
37  Using Arduino / Programming Questions / Re: MATHS help reqired for HSI project. on: August 15, 2014, 02:56:36 am
That accelerometer is an analog device.   The "standard" example codes for it,  return an integer for each axis,  apparently normalised to 100 representing 1g.

You mentioned that you are not using the z axis,   so I assume that you have your x and y axes horizontally and your z vertical.  If you have your x axis pointing "forwards" and your y axis pointing sideways,   then,  for very small angles of pitch and roll,   the x and y readings will represent 100 x the sine of the pitch and roll axes,  in radians,  respectively.

Note the limitations here.  That calculation will only work if the device is not actually accelerating anyway,   and also not subjected to a rotational acceleration.  It's going to work for tilted objects,   not spinning objects.  And it is not going to work for large angles of pitch and roll.

You also need to be clear on what part of your calculations require integer and floating point arithmetic.   If you don't want to use floating point types,   you can work around that but you need to be clear on what you are doing.

your statement that int(0.1) results in 1,   seems to be wrong.   Actually, to the best of my knowledge,  C doesn't even have an INT( ) function.   Matlab and Fortran do....        You can cast numbers to an int, like this
Code:
float f = 4.7 ;
int i = (int) f ;                                  //  the result of this is (integer) 4
but that is not actually a function call.

This is how you would calculate the pitch and roll,  representing the tilt of your device in degrees,   where the x and y directions are oriented forwards and sideway,  and z vertical,  provided that the device has no accelerations  and therefore that the numbers coming from the device represent only the static effect of gravity,   and that the numbers are integers normalised to 100 = 1g :

Code:
int x ;  // accelerometer reading
int y ;  // accelerometer reading
int z ;  // accelerometer reading

void loop()
{
   x= accelero.getXAccel() ;
   y = accelero.getYAccel( );

   float  pitch_sine = ((float)x)/100.0 ;       //  this is the sine of the pitch angle

   //  Check that the sine of the pitch angle is within the legal range between -1 and 1
   //  If either part of this section is true,  it means that the device has a substantial actual acceleration,
   //  or that the device is poorly calibrated.

   if ( pitch_sine > 1.0 ) pitch_sine = 1.0 ;
   else if ( pitch_sine < -1.0 ) pitch_sine = -1.0 ;

   float pitch_radians = asin ( pitch_sine )   ;             //  calculates the pitch angle,  in radians
   float pitch_degrees = pitch_radians * 57.3 ;         //  convert result to degrees, multiply by 180/pi

}

For SMALL angles of pitch and roll,  less than maybe about 20 degrees,    you can use the approximation that the sine of the angle ( in radians ),  is not very different to the angle in radians.     Therefore,  you could use this calculation

Code:
int x = accerelo.getXAccel( ) ;              //  x direction component,  normalized to 100 = 1g
int pitch_degrees = x * 57 / 100 ;     

This calculation uses no float math at all.   However,  it will overflow the arduino 16 bit int if the value of x exceeds about 55 .    To be clear why this is,  the product  x times 57 must be less than 32767,  the limit for ints.

However,   this approach is only valid for the range of tilt for which  sine(y) is approximately equal to y ( in radians ) ,  which is for angles less than about +/- 20 degrees,  depending on your tolerance for "approximately".    If you are using this model to measure the range of tilt for which it is appropriate,  then the overflow would not be an issue.











38  Using Arduino / Programming Questions / Re: MATHS help reqired for HSI project. on: August 15, 2014, 02:08:28 am
That code you posted looks like Matlab or something.     No C/C++ code looks anything remotely like that.

39  Using Arduino / Programming Questions / Re: Constructor not called and loop not runnin on: August 14, 2014, 07:22:42 am
Code:
#ifndef MyClass_h


When you start your header file with this,   you need to have a   #define MyClass_h   on the next line.
40  Using Arduino / Programming Questions / Re: [HELP!] Weird GPS data and micro SD card problem on: August 14, 2014, 07:20:44 am
Quote
    GPSstruct A = {dataString,tinseconds,C_lat,C_lon,C_alt,heading,speedmps};

This doesn't even look like a valid c/C++ operation to me at all.       The C_alt variable which you have declared in loop( )  is not the same as the field in your struct.

41  Using Arduino / Programming Questions / Re: [HELP!] Weird GPS data and micro SD card problem on: August 14, 2014, 07:16:02 am
The reason that the "heading" is nonsense,  is because the gps module will only calculate the heading when it is moving,   and usually only when moving at a speed greater than about 4 km/hr.     Unlike a compass,   it has no means of knowing which way you are facing when you are standing still.    It can only determine the direction of your apparent motion when it can compare the position now,  to the position around 1 second ago.

42  Using Arduino / Programming Questions / Re: dht error on: August 12, 2014, 02:24:46 pm
You don't need both of those includes.

And the name of the class seems to be neither dht nor DHT,  in the one I am looking at,  it is DHT22..

Look inside the .h file that you actually use,    the class name is in there,   that is the class name you actually have to use to create an object of that class type.
43  Using Arduino / Programming Questions / Re: Arduino Mega 2560: I2C issues (configured as a i2c slave) on: August 12, 2014, 02:12:56 pm
Code:
/*
 * Function twi_init
 * Desc     readys twi pins and sets twi bitrate
 * Input    none
 * Output   none
 */
void twi_init(void)
{
  // initialize state
  twi_state = TWI_READY;
  twi_sendStop = true; // default value
  twi_inRepStart = false;
 
  // activate internal pullups for twi.
  //digitalWrite(SDA, 1);
  //digitalWrite(SCL, 1);


In arduino/libraries/wire/utility  is a file called  twi.c      and the last two lines in the excerpt posted here are commented out to prevent the activation of the internal pullups for twi  (  which is an alternate name for I2C apparently )
44  Using Arduino / Programming Questions / Re: Arduino Mega 2560: I2C issues (configured as a i2c slave) on: August 12, 2014, 02:03:13 pm
Quote
but I also tried resistors of 47k, 22k, 8.2k, 4.7k .

In case of resistors <= 22k there is no i2c connection at all, >=47k is fine for both Mega and Uno.


That seems bizarre,  since most people report using resistors between 2.2k  and 10k,   and 4.7k  seems to be the most commonly reported value.

In fact,  since you report getting successful results with such weak pull-up resistors,   that seems to me to be all the more reason why there is in fact multiple pull-ups in your arrangement,   some of which you might not be aware of.

45  Using Arduino / Programming Questions / Re: NRF24L01+ , temp sensor and 328P not so low power on: August 12, 2014, 01:56:04 pm
I would think that the radio device is going to be the stumbling block for you there.
Pages: 1 2 [3] 4 5 ... 202