rip_report
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rip_report [2016/04/04 01:01] – joaomatos | rip_report [2016/04/21 21:04] (current) – joaomatos | ||
---|---|---|---|
Line 7: | Line 7: | ||
{{: | {{: | ||
+ | |||
** ITENS ORDERED ** | ** ITENS ORDERED ** | ||
Line 42: | Line 43: | ||
Testing 3: | Testing 3: | ||
{{youtube> | {{youtube> | ||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | **WEEK 5** | ||
+ | |||
+ | **LQR Approach** -> | ||
+ | I'm following two different papers to find the LQR derivation for a rotary inverted pendulum. The state space model from the two papers are different , and i found two different [K] matrix for my model . ( changing the model parameters to my parameters and using Matlab to solve the ARE and get the [K] matrix ( I'm using Q as diag(100, | ||
+ | to tune the gains from the model that gave me the best balance.I tried to use the LQR gains from the MathWork program but the response was not very good. | ||
+ | |||
+ | I'm now using a full state feedback ,using the gains from LQR. I found a bug on the AngularSensor with motor controler - if you start the MotorRotationCount | ||
+ | and rotate the motor to the negative direction , it will give sometimes a very wrong reading | ||
+ | . So i had to insert on the code a 360 degree rotation on the motor | ||
+ | before the system start working to use the Motor position as the (Actual counter - 360) | ||
+ | to avoid these kind of wrong readings. | ||
+ | |||
+ | I found that limiting the motor maximum power to around 40~~50 of maximum power the system balance better. ( using saturation -100 x 100 the motor vibrates a lot when changing the turning direction). I tried to apply a filter on the velocity calculation (using average from 4 measures) but the system performance does not improved. Other strange thing happening is that sometimes in the middle of the balancing i got a " | ||
+ | |||
+ | {{:: | ||
+ | **MATLAB CALCULATION** | ||
+ | |||
+ | ---- | ||
+ | |||
+ | {{:: | ||
+ | {{:: | ||
+ | {{:: | ||
+ | [[http:// | ||
+ | |||
+ | ---- | ||
+ | |||
+ | {{:: | ||
+ | **SECOND PAPER** {{:: | ||
+ | |||
+ | |||
+ | ---- | ||
+ | **BALANCE SITUATION**: | ||
+ | |||
+ | {{youtube> | ||
+ | |||
+ | **Difference between my model and the available on the internet** -> | ||
+ | The control method is pretty similar to the majority of papers that i found | ||
+ | on the internet - Full state feedback using LQR to find the gains. One thing | ||
+ | that the guy from MathWork ( and Prof Kawata) | ||
+ | The guy from MathWork uses transfer functions blocks to find the velocity | ||
+ | (input angle , output velocity). Prof Kawata is using the StateSpace block model to derive the velocity | ||
+ | (input angle , output velocity ). And i'm using the manual method | ||
+ | (Angle-PreviousAngle)/ | ||
+ | The Motor Input we are all using the same ( [K]*[x] ) (x as the matrix with the two angles and two velocities). | ||
+ | |||
+ | {{:: | ||
+ | {{:: | ||
+ | {{:: | ||
+ | {{:: | ||
+ | {{:: | ||
+ | |||
+ | |||
+ | **Next steps** | ||
+ | * I sent the email with the parts i need to Paresh and he ordered the parts monday, but they did not arrive at the lab yet ( friday ). When i get the parts i will: | ||
+ | |||
+ | * First i will run the MathWorks model with the E-Motor and see what was the problem with my code. If the Simulink model could balance the pendulum with this motor after trying to tune the LQR gains the problem is my code. If the Simulink model could not get close to a balance , the problem should be the motor. | ||
+ | |||
+ | * After, i will replace the E-motor for a XL-motor and try to run the Simulink model. (the pendulum length is the same and the Brick the same , so the Gains should be very close to the tuned gains). I will find the gains that balance in the Simulink model and i will use this gains on the NQC code and see what happens (if the code is OK , the balance should be good on NQC too). If the balance is not OK the code has something wrong. | ||
+ | |||
+ | |||
+ | ** WEEK 6 ** | ||
+ | * **Day1** : I'm still waiting the parts so today i spent more time refining the gains and modifying a few things on the code. I was looking at the Simulink model from Professor Kawata and he is using a different input equation. He uses the traditional [K]*[states] but he adds another factor ( a constant times the signal of the arm velocity ). This can be the reason that his model is balance way better than the MathWorks project. | ||
+ | |||
+ | |||
+ | Voltage Calculation. ( the standard [K] from LQR times the Matrix with the states ) | ||
+ | |||
+ | | ||
+ | |||
+ | |||
+ | factor: | ||
+ | |||
+ | | ||
+ | |||
+ | * **Day 2 and 3**. No progress. The sensor already arrived at the lab but i'm still waiting the XL- Motor. Tomorrow (Thursday) the motor should arrive and i will start the final tuning of the system. During the weekend the project should be finished! | ||
+ | * **Day 4 and 5**: Already got all the necessary parts to build the final structure. The final structure is done. The balance with the XL-motor is way better than the E-motor. The XL motor is way more powerful and robust (I could easily rotate the E-motor by hand , and the XL motor is pretty difficult to rotate it by hand). The XL motor oscillates less when changing the rotating direction. I got a good balance using Simulink and the balance using NQC is getting better. I identified two things that the NQC code needs to improve. One is the velocity calculation , i will have to find a way to apply a filter , without loosing much processing time. And looks like the time between each loop on the Simulink is a little bit faster than the NQC (I'm using a function to get the sensors data , i will try calculating all the sensors data in a separated task and using global variables - this values can be available at all time). | ||
+ | |||
+ | {{:: | ||
+ | |||
+ | * **Day 6**: I'm trying to find what is limiting the balancing on the NQC code. The Simulink code is running smooth ( see video ). I'm using the same algorithm on the NQC code. What i did today: | ||
+ | * 1-> I tried first with my original code to do a little gain tune , because the Simulink gains did not work with the NQC code.I could not tune the 4 gains to improve the balance the way it was needed .So i start to look for possible mistakes on the code. | ||
+ | * 2-> | ||
+ | * 3->I checked if my references was the same of the Simulink model (Positive/ | ||
+ | * 4-> | ||
+ | |||
+ | {{:: | ||
+ | |||
+ | * 5->I tried to fix the input issue: first i tried to do a gain tune to make the two input to be the same on the same conditions ( same motor angle and pendulum angle) - NO SUCCESS , always a little difference (1~3). But at least the difference got a little smaller.I had to change some variables type ( ex: on the Simulink , the block that get the angle send an integer value , and i was using a float variable on the API to get the angle ( using this sensor from mindsensors the API is the same as a regular motor (MotorRotationCount). | ||
+ | * 6->With the time between interval OK and the Positions gains " | ||
+ | * 7->I started to change the methods to calculate the velocity. I) using the dt as the CurrentTick - PreviousTick (API's from the Bricx program ) II) Calculating dt with a function to handle the time between loops ( similar to the code of the WhipBalance that we used on class ). III) Calculating three values in a row and taking an average. IV) I'm now working on using the average of previous values (similar to the code of the WhipBalance that we used on class), i will use an average of 5 previous values to calculate the velocity. | ||
+ | |||
+ | |||
+ | | ||
+ | | ||
+ | |||
+ | **Day 7:** | ||
+ | * I'm now calculating the velocity using the average from 4 previous values and the balance got significantly better but still not as good as running on Simulink (using the exactly the same gains). The balance can get better with a little gain tuning - which i'm trying right now. I thought that the interval between loop was OK , but i think this can be causing the Simulink to balance better ( see the two videos on the Building Tutorial Tab ) .Another thing that is different is the motor behavior . Running on Simulink we can't notice the motor "input spikes " , it accelerate and break very smoothly . Runing on NQC we can notice the motor "input spikes" | ||
+ | |||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | ---- | ||
+ | |||
+ | |||
+ | **WEEK 7 ** | ||
+ | Now that the NQC is running smoothly the next steps are: | ||
+ | |||
+ | - Finish the swing up control. | ||
+ | - Fill up the spreadsheet with the necessary parts for the RIP Box. | ||
+ | - Do the a detailed version of the building instructions | ||
+ | - Do the step - by - step coding in the Bricx Command Center | ||
+ | - Explain the theory behind the NQC code | ||
+ | - LQR Theory - how to find the gains | ||
+ | |||
+ |
rip_report.1459756876.txt.gz · Last modified: by joaomatos