I'm running arduIMU v.D and I cannot get the code to compile if I use either analogRead/Write features. I get the following:

core.a(wiring_analog.c.o):(.data.analog_reference+0x0): multiple definition of `analog_reference'
arduimu.cpp.o:(.data.analog_reference+0x0): first defined here

Something about the way arduimu works seems to break the analog features.It looks like I need to do some direct port manipulation to read analog pin 0-4 (the pins I desire to read). Does someone have some advice on an equivalent piece of code to directly replace:


The reason for me doing this is that I am attempting to make a motion-based transmitter for multicopters, pitch and roll controlled by motion, but I would still need to poll some pots for yaw and throttle.



Views: 478

Reply to This

Replies to This Discussion

Hmm, I am guessing that there is a fundamental issue I am not grasping. Are the analog pins already being used to read the onboard sensors? 

This works for me.

//Potentiometer Connections:
//Wiper to A0
//One End to ground, the other to 5v
//LED blink rate controlled by Potentiometer
void setup()
Serial.begin(38400); //Set Serial out baud rate
pinMode(13, OUTPUT); //Yellow LED is output

void loop()
int value;
value = analogRead(A0); //Get Analog Value 0 - 1024
Serial.println(value); //Display on serial monitor

digitalWrite(13, HIGH); //Yellow LED On
delay(value); //Delay in milliseconds
digitalWrite(13, LOW); //Yellow LED Off

are you also running arduimu code along with that? I can do it standalone, but not while arduimu code is running. I would assume the normal SDA and SCL pins (A4 and A5) are used up, but for some reason any call to analogwrite/read results in the above. There most be something buried in the code that I do not understand. 

If you are using this software version and using hardware version V3:

// Version 1.9 Support for ArduIMU V3 Hardware with MPU6000 and HMC5883 magnetometer 

Then you must have this statement uncommented:

#define BOARD_VERSION 3     // 1 For  new V3

The ArduIMU has 3 versions.  V1 and V2 used all analog channels to get analog values from the separate accel and gyros.  V3 uses the MPU-6000 3 axis accel & gyro which has internal A/Ds that do it for you, thus you have all the analog ports free. I suspect your code is initializing the A/Ds along with their interrupts and then trying to do so again.  I would suggest going into the code and blow away all the code in the #defines for V1 and V2.

The link  below will show you what ports are being used in V3 and which are available for you use.  Currently I am using A0 - A3 with no problems.


Got it, Thanks! I went through and commented out all references to boards < 3 AND I commented out this section.

volatile uint8_t MuxSel=0;
volatile uint8_t analog_reference = DEFAULT;
volatile uint16_t analog_buffer[8];
volatile uint8_t analog_count[8];

I am now able to use analogRead/Write in my code. So I decided to go back to stock code and then just comment out what I show above and NOT comment out any of the defines for < board 3 and it compiles, which I suppose is expected. 

I tried just wrapping that snippet of code up like this

volatile uint8_t MuxSel=0;
volatile uint8_t analog_reference = DEFAULT;
volatile uint16_t analog_buffer[8];
volatile uint8_t analog_count[8];

but when I set the board type 1 or 2 I get issues about declaring variables on compile (even without analogRead/Write in there). I suppose that is because it still compiles the "void Read_adc_raw(void)" despite not needing to. 

So I have a very workable solution now considering I have board ver 3. Thank you very much Al Toma. You rock. 

You are welcome. You stated that you are making a motion-based transmitter for multicopters. Does that mean you are creating a hand held unit utilizing the IMU to output roll pitch which will be transmitted to your multicopter via an RF link like X-bee? Sounds do-able but I would think having several pots or even a 2-axis joystick on the same unit would be a little tricky to control - tilting the whole platform at the same time moving several pots on it seems a bit tricky. Good Luck!

By the way, they don't sell V1 and V2 IMUs any more so you don't really need the code in you project.

Reply to Discussion



Season Two of the Trust Time Trial (T3) Contest 
A list of all T3 contests is here. The current round, the Vertical Horizontal one, is here

© 2020   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service