LPR530AL gyro readout

Hi arduinoforum,

I'm having trouble getting a reading from the LPR530AL dual axis gyro (both 0x and 4x analogOuts)

i connected 3.3V, ground and one wire to the 4x analog output.

My arduino code:

int val; int gyro;

void setup() { pinMode(7, OUTPUT); pinMode(2, INPUT);

//Serial.begin(9600); Serial.begin(19200); //Serial.begin(38400); }

void loop() { // switch off the magnet (relay switch) val = digitalRead(2); digitalWrite(7, val);

// read gyro gyro = analogRead(4); Serial.print("gyro value X: \t" + gyro); //Serial.print(gyro);

delay(1000); }

I'm getting gibberish on the serial monitor, which kind of freezes... Anything i forgot? should i connect vRef to ground also or is that not necessary? I also tried serveral baudrates, but that should not have anything to do with the gyro reading right?

Thanks!

Okay, found it, it's because you cannot add the gyro readout value and a string i guess.

You are used to Java perhaps? Yes the print functions are very limited on a small microcontroller. I'd always advise getting one thing working at a time before moving to the next - don't put yourself in the position of having made a dozen changes and only then find your code has stopped working, test each change (or set of related changes) so that you have immediate feedback that you got it right!

Thanks for the tip! And yeah, i'ts javascript/actionscript :) not much string to int / into to string stuff needed there :) I am now getting readouts, however, it's hovering at around ~1023 which is the max for a 10 bit ADC, but i'm not moving the gyro... What could this be?

I'm using this guide to get to the angular rotation speed (in degrees, ultimately).

[edit]: okay, wth, to be sure i'm now also measuring Y out 4x, not just the X out 4x, and they're both 1023 exact and not changing. What can be the cause of this?

Oops, never mind again, it was because i copied the Aref line from the guide thread:

analogReference(EXTERNAL); //3.3V

...but i wasn't really supplying the voltage. stupid! i guess i should do as MarkT advises: small changes so you can spot bugs soon.

Okay, i finally got the reading i wanted!

Why can i get a deg/second readout [u]higher[/u] than 300 deg/second? (highlighted in the CoolTerm program) 300 deg/second should be the max. range of my gyro?. I am using this guide, and as i want the [u]degrees per second[/u], not the degree (for adjusting geolocation or something, i did not add the code for the time difference with millis(); ).

P.S:

I was messing around for so long because i could not solder the gyro, because i did not knew if the measuring range and sensitivity were what i was looking for. While moving the gyro, it was sometimes disconnected from the analog output wire... and yeah my mac crashed several times... probably not that much of a best practice :>