[FEASIBLE?] Gyroscope connected to separate microcontroller to measure rotation

Hi,

I have the following problem, with a small remotely controlled car i am developing:
I want to make it turn manually and when i am done turning, for a gyroscope to tell me how much i turned.

Now, the way i have thought of this is the following:

  1. Have the gyroscope connected to another arduino/microcontroller (i am thinking ATTiny85) from the one that controls the motors and has my main logic.

  2. Send signal to secondary controller (from now on referred to as ATTiny85) to start measuring angular displacement ("rotation").

  3. Turn as much as i want (not pre determined how much i need to turn).

  4. Stop turning.

  5. Send signal to ATTiny85 to stop measuring (through an interrupt possibly) and it reply to me with how much rotation it measured, since i told it to start measuring.

So, what do you think of this? Is there a better way to do the same thing?

I am thinking that it can't be done with single microcontroller, since i believe i would have to measure the rotation within my "main" program's logic as i 'm turning and doing other stuff (thus its execution time could be unpredictable, due to the need to read a serial input for example, or whatever else).

I'd love to hear objections and better ways to do this! :slight_smile:

I think you'll have to do some tests to figure out what is achievable or not.

First, since you don't want to track the orientation angle but the rotation between during a limited amount of time, I think only gyros will be enough... But you need to test just to make sure!
This has 2 consequences : you don't need a complete IMU and you don't need a heavy and time consumming data processing.
Thus, I'm not sure you really need a 2nd MCU, since you can communicate with a gyro pretty fast. But let's check it out by doing some more tests...

You need to measure the execution time of your main program's loop. Then, measure the time to get the gyro data and process it. Do the math and you'll find if you can do this with a single MCU... I think it'll be a yes, but make sure by doing all these verifications.

If ever you can't with one MCU, your solution should be the way to go.

I'm quite sure that this can all be done with a single MCU, but you cannot waste any time with delay() statements!

Gyros drift quite rapidly and the drift rate depends on temperature. You will need to correct as well as possible for the drift. Even then, you will probably find that integrating the rotation rate to get the total angle turned will work for only a few seconds, before the gyro needs to be reset.

jremington:
I'm quite sure that this can all be done with a single MCU, but you cannot waste any time with delay() statements!

Gyros drift quite rapidly and the drift rate depends on temperature. You will need to correct as well as possible for the drift. Even then, you will probably find that integrating the rotation rate to get the total angle turned will work for only a few seconds, before the gyro needs to be reset.

Yeah, that's my biggest concern, since i am not completely sure what the execution time will be, or whether there will be any delay statements. There will be reading from Serial port, so that could affect the running time if there are stuff to be read.

So considering that this introduces a constraint on the rest of the code, i am leaning towards following the seperate IC solution...

Thanks to both for your input. I'm eager for the input by others as well!

But a separate microcontroller has to talk to the first one on serial, which then blocks out that serial for whatever else you are doing and it doesn't save any time.

The IMUs like the MPU6050 have their own microcontroller on board that you can program to do this kind of stuff but even that isn't necessary. Just read it often enough using high-speed I2C (which is quite fast) and you will get the data you need.

Unless you are doing something very wrong, serial input should not have much impact on the execution speed of your main motor-control loop. You do need to measure it for yourself so you know what is going on and what changes affect it for better or worse.