Skip to content

Conversation

@damgaardmr
Copy link

No description provided.

mindThomas and others added 30 commits December 13, 2018 16:24
Linker file changed to accommodate for heap in D1 memory space which needs a pause after boot before stabilization and usage.
FreeRTOS configured to support MCUXpresso FreeRTOS plugin for Eclipse for debugging.
RX messages are stored in message queue in USBCDC object.
Library functionality is not finished though - needs functions for reading messages and transmitting, preferably queue based
…g serial characters in a similar fashion to the Arduino Serial.write and Serial.read
Interrupt feature currently under test and not fully working yet
…created but estimator library development is not complete yet
Added comments for Sliding mode controller
Notice that LQR controller takes in angular velocity in body frame
Notice that MATLAB Coder generated Sliding mode controller does not take in angular velocity reference
Can not compile due to missing ARM Math library during linking
Verified compilation on Linux
Fixed issue with Hard Fault due to stack overflow
Tested with 200 Hz duplex communication
This allows debugging messages to be sent to the PC with a simple call to "Debug::print(...)" or "Debug::printf(...)"
DFU bootloader can be used to update the firmware over USB
mindThomas and others added 29 commits February 26, 2019 08:04
Accelerometer calibration and gyroscope bias + alignment calibration can be carried out individually
First time the velocity controller is well working for Kugle V1
Tested sliding mode without Equivalent control and higher gains with promising results
Balance is still wobbly and oscillating
Allowed independent gains for the three sliding surfaces (K, eta and epsilon)
LQR controller seems to give similar performance to the Sliding mode controller ???!
OBS! Velocity estimator is still not concluded functional.
1. Using q_dot sliding manifold with factor 2 error
2. Using updated/improved QEKF but in non-sensor driven configuration, with bias estimation enabled but without acceleration detection enabled
3. Using LPF for velocity estimation - thus NOT using velocity estimator
4. Using Euler-based PI velocity controller but with omega_references disabled
Q_dot sliding mode had an error in the inverse matrix (factor of two). This required the gains to be modified.
However if Qdot in equivalent control is included the system becomes very sensitive and prone to noise.
These gains (and without Qdot in equivalent control) works well.
Sliding mode controller gains has been greatly reduced to make the controller slower
LQR Velocity controller implemented. Automatic integral start up implemented allowing the user to move and position the robot after startup.
Velocity estimation works very well with this updated Extended Kalman filter using a combination of accelerometer measurements for acceleration estimation and encoder measurements for velocity estimation/correction
- SMBus communication
Copy link
Owner

@mindThomas mindThomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have now reviewed the code. Please see my comments at each file/line.
Note also that I did not find any modifications to the Include directories. Didn't you change which directories to include in the Eclipse (System Workbench) project settings such that the Battery library etc. was included?


/* Create the main thread which creates objects and spawns the rest of the threads */
xTaskCreate(MainTask, "mainTask", 1024, (void*) NULL, MAIN_TASK_PRIORITY, &mainTaskHandle);
xTaskCreate(MainTask, "mainTask", 1024, (void*) NULL, MAIN_TASK_PRIORITY, &mainTaskHandle); // udkommenter igen
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should not be committed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it the comment that you want removed? The rest is the same

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the comment should not be committed.

Battery * battery1 = new Battery();
Battery * battery2 = new Battery();
PWM * powerLED = new PWM(PWM::TIMER17, PWM::CH1, POWER_LED_PWM_FREQUENCY, POWER_LED_PWM_RANGE);
PowerManagement * pm = new PowerManagement(*enable19V, *enable5V, *battery1, *battery2, *powerLED, POWER_MANAGEMENT_PRIORITY);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Power management initialization can not be moved down since the 12V power should be turned on as quickly as possible to avoid the onboard computer turning off if the embedded processor is reset (eg. during debugging or just as a general reset)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However I need the LSPC and timer object in the powerManagment object, so these objects have to be initialized before powerManagment?


if(batteryAssamblyChargePercentage<BATTERY_LOW_PERCENTAGE){
batteryLOW = true;
Debug::printf("battery low /n");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to leave this debug line in?
If so, please note that the "new line" character is '\n' and not '/n'

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to leave it for now, since the power LED is not yet that visible :)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, it makes sense. In that case please modify the new line character.

_powerMode = POWERMODE_OFF;
Enable(true, false); // start with 19V turned on and 5V off

osDelay(2000);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not have a 2 second delay in a constructor. In that case move the below from this constructor into the Power Management thread "PowerManagement::PowerManagementThread" as an initialization part

@@ -0,0 +1,34 @@
//
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is wrongly committed! It should be removed from the commit and pull request.

* Thomas Jespersen, TKJ Electronics
* Web : http://www.tkjelectronics.dk
* e-mail : thomasj@tkjelectronics.dk
* ------------------------------------------
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you have made this you can consider to add some extra lines here in the top to indicate that you are the author of this part

* Web : http://www.tkjelectronics.dk
* e-mail : thomasj@tkjelectronics.dk
* ------------------------------------------
*/
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you have made this you can consider to add some extra lines here in the top to indicate that you are the author of this part


while(1){ // loop until the device becomes available and the configuration can be changed
if(thisObjPtr->SetCurrentLimitEEPROM()){ // stop task
if (thisObjPtr->batteryBoardEepromTaskHandle){ // free memory associated with the task
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the comment misleading - you are not freeing memory related to the task
But I see how you suspend and resume. However there is almost no overhead in creating and destroying threads. So you could also just destroy the thread completely similar to what is done here: https://github.com/mindThomas/Kugle-Embedded/blob/master/KugleFirmware/Libraries/Applications/BalanceController/BalanceController.cpp#L962


# STlink Debug clock frequency
set CLOCK_FREQ 4000
set CLOCK_FREQ 8000
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't commit this change. Debug frequency has been lowered purposely

@@ -1,9 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not commit this file change. Leave out these changes to the Eclipse configuration files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants