LOGIN
Gaurav Yadav
6
Collaborator
quadcopter (Project Leader)
 · MumbaiIndia
Share
Report
Get Link
QUESTION
Open

How to get a fast response from microcontroller ?

Guys, I need help here. I have worked on self balancing platform, or a gimbal before, and what i noticed is that there was quite a delay in the response from the motors to the time the IMU gave updated values. I couldn’t quite get the reason. Is there a way to ensure that whenever you are making any such project that requires you to reflect the readings from the accelerometer or gyroscope to the actuators, it happens in a flash? I do understand that these sensors would be updating values at say 100Hz, and putting my logic inside the value updation loop would slow down the entire loop and thus might end up with buffer overflow. Can anyone guide on this?

Contributions
Kevin Tom

Explained how to optimize a script

3 likes 
Like
Award Contribution
Load 7 previous comments
Gaurav Yadav
6
Collaborator
quadcopter (Project Leader)
 · MumbaiIndia
Share
Report
Get Link

I am going try PID in the code and check the difference. Thanks for the info.

Like
1 like 
Award Contribution
Share
Report
Get Link

Hi, The idea of using PID controllers is the way to go, they are perfect for this aplicattion and the de-facto standard. About the delays, there two main reasons for why they are happening, the first option is the code and the way you are programming the microcontroller, and the other is as you have been discussing, the inertia of the physical system, the problem are not the ESCs because of the high refresh rate so the other options are the motors. Can you tell me about the microcontroller you are using and also about the motors?

Like
3 likes 
Award Contribution
Gaurav Yadav
6
Collaborator
quadcopter (Project Leader)
 · MumbaiIndia
Share
Report
Get Link

Mateo Echeverri, i was using Arduino Uno and micro servo sg90 for the gimbal Project. I saw this delay in response in that project. Maybe the reason is micro servos cant rotate faster than a particular speed, but i feel there is something to do with response time.

Like
2 likes 
Award Contribution
Pedro Cunha
3
Collaborator
Mechanical and Aeronautical Engineer
 · Rio de JaneiroBrasil
Share
Report
Get Link

Gaurav Yadav how are you doing the communication IMU-Arduino? Are you using interrupts? I think that is the best way to handle the readings from IMU! With interrupts you will always be receiving data from IMU… you don`t need to finish the for loop and then update the data (if I understood it right “Once the for loop completes, the microcontroller takes updated values”).

There is a link about interrupts: https://www.allaboutcircuits.com/technical-articles/using-interrupts-on-arduino/

(in this article, he says “What’s awesome about this is that it structures your system to react quickly and efficiently to important events that aren’t easy to anticipate in software.”) Maybe this can help!

Like
3 likes 
Award Contribution
Gaurav Yadav
6
Collaborator
quadcopter (Project Leader)
 · MumbaiIndia
Share
Report
Get Link

Thanks @Pedro Cunha for the info. I will go through it.

Like
2 likes 
Award Contribution
Mechanical Engineer
 · MumbaiIndia
Share
Report
Get Link

if you want faster response from your microcontroller , your program should be continuous ;i.e. suppose your program is like that
const int left motor 1=9;
const int left motor 2=10;
const int right motor 1=11;
const int right motor 2=12;
write your program in following manner
const int left motor 1=9;const int left motor 2=10;const int right motor 1=11;const int right motor 2=12;
if you write like that microcontroller reading becomes less than before because microcontroller reads your first line after some delay it reads your second line. but if you write in continuous manner every delay after every command will be eliminated and response time should be faster than before . Since delay time is not too much but if your program is bigger than 100 lines then elimination of delay become worthful and microcontroller will process and impliment your program in mean time . Most of games program is based on above technique .

Like
3 likes 
Award Contribution
Leave a reply...
DISCOVER
CHAT
HIRE
ACTIVITY
FEED
New Post
Help
Start Project
Online Users
Share Link