-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Perform preliminary firmware tests on the AMC-BLDC #84
Comments
The architectural model could become the following:
Some considerations:
|
All good 👍🏻 A couple of comments:
We should keep adhering to the way we did it on AMCBLDC: a Simulink parameter defined in the dictionary that is used to initialize the internal structures, thus NO dedicated inputs to the architecture.
Definitely Warning Be careful as we shall still deal with the CAN-based part of the dictionaries. At the moment, this is the dictionary hierarchy: Important The dictionary Tip Actually, the name |
Good point, the GlobalConfiguration includes estimation velocity mode, the lambda for rms computation and so on, not really configurable stuff.
I suggest this dictionary structure:
Important The supervisor at the moment cannot support 4 messages (or more generally, events) per tick, but only one. |
Oki 👍🏻
Indeed, let's get rid of it 👍🏻
This appears to be a severe limitation. |
Taking inspiration from the implementation in the original supervisor, I readded the multiple processing of CAN messages (called generically Received Events) in the following fashion. The inputsDispatcher was changed in such a way that every time it is called, it iterates over the MAX_NUMBER_EVENTS array of events, and with a switch-case pattern (suggested by matlab) it runs the appropriate functions and stateflow events The generated code is the following, which to me seems simple and effective enough: /* Consume N events per tick */
for (ei = 0; ei < MAX_EVENTS_PER_TICK; ei++) {
switch (supervisor_U->ReceivedEvents[ei].event_type) {
case SupervisorEvents_SetLimit:
supervisor_SetLimits(supervisor_U->ReceivedEvents[ei].
limits_content.overload,
supervisor_U->ReceivedEvents[ei].
limits_content.peak, supervisor_U->
ReceivedEvents[ei].limits_content.nominal,
supervisor_U, supervisor_Y, supervisor_DW);
break;
case SupervisorEvents_SetPid:
supervisor_SetPid(supervisor_U->ReceivedEvents[ei].pid_content.type,
supervisor_U->ReceivedEvents[ei].pid_content.P,
supervisor_U->ReceivedEvents[ei].pid_content.I,
supervisor_U->ReceivedEvents[ei].pid_content.D,
supervisor_U->ReceivedEvents[ei].
pid_content.shift_factor, supervisor_Y);
break;
case SupervisorEvents_SetMotorConfig:
supervisor_Y->ConfigurationParameters.motor =
supervisor_U->ReceivedEvents[ei].motor_config_content;
break;
case SupervisorEvents_SetTarget:
supervisor_SetTarget(supervisor_U->ReceivedEvents[ei].
targets_content.jointvelocities,
supervisor_U->ReceivedEvents[ei].
targets_content.motorcurrent,
supervisor_U->ReceivedEvents[ei].
targets_content.motorvoltage, supervisor_Y,
supervisor_DW);
break;
case SupervisorEvents_SetControlMode:
supervisor_DW->requiredControlMode = supervisor_U->ReceivedEvents[ei].
control_mode_content;
b_previousEvent = supervisor_DW->sfEvent;
supervisor_DW->sfEvent = supervisor_event_SetCtrlMode;
if (supervisor_DW->is_active_ControlModeHandler != 0U) {
supervisor_ControlModeHandler(supervisor_U, supervisor_Y,
supervisor_DW);
}
supervisor_DW->sfEvent = b_previousEvent;
break;
}
} Note that if a ReceivedEvent is not recognized in type, it is simply skipped. This part might need to be tested before being integrated into the AMCBLDC architectural model. |
Nice! |
Super! |
What is needed to complete the integration is now the interfacing of the CAN Decoder and the Motion controller. |
We're working in a fully parallel "branch" of development (actually, it's a dedicated folder) meaning that you're dealing with a copy of the current AMCBLDC structures. Hence, it should be safe to adapt the CAN Decoder without impacting what is running now on the boards. |
Today I was able to adapt the CAN decoder so that it could be attached to the new motion controller, and successfully generate the cod, both in C++ 03 and C99 . The signal |
The following commit in my fork allows compilation of the new version of the AMCBLDC: mfussi66/icub-firmware@b0cc008 . Steps I performed:
|
On the old architecture, I think we have something very similar, although I actually don't remember how we did it. |
I think I figured out a way that is a bit more simple and I think elegant: The CAN decoder stateflow chart has an option called "Initialize outputs every time the chart wakes up": if that is enabled, at the beginning of each Ts the outputs are reset to the initial values, which I think is a sensible option for the decoder. In C code, this means that the output variables are reinitialized every time But now it works as expected: amcbldc.mp4 |
Super! Very elegant, indeed. Perhaps, it could be beneficial to drop a comment somehow in one FSM to bring up this important mechanism of initialization, especially for the newcomers. |
Done that. After connecting the motor, it does not spin, because the current does not attempt to reach the setpoint. Debugging it at the moment. |
We now have the working current controller, but the motor does not spin:
This was caused by the CAN decoder that would send only a partially set MotorConfiguration struct. Therefore, Vcc and Vmax were = 0. I solved it by adding the following line on top of the can decoding of the motor config message: |
Aligned F2F with @mfussi66:
|
I also fixed a mistake (caused by me) that caused the motor not to be enabled after fault button, now the sequence:
is correctly handled, just as before. However, setting the FOC Ts to 45us makes the motor spin with more oscillations, is this expected? |
Hi @sgiraz I don't seem to find the test results we did while checking the performance of the It's important to verify the quality of control. |
Hi @mfussi66 Did you check that the HAL is configured to have the correct PWM rate as well? |
Yes, I was rebased on the latest devel which had the changes in the hal and its commits. I must note that this behaviour seems to be happening also with the devel. Maybe it's just a matter of tuning up the current pid? They have never been touched, even between different motor models. |
Ok, I thought you noticed the behavior while switching to Ts = 45 us, whereas it wasn't like that with the previous Ts. It's true that we can tune the PID gains, but our understanding is that changing Ts doesn't cause any macroscopic change in the logged quantities (e.g., current, position, velocity), keeping conditions (e.g., motor, setup, board) unvaried. Can you confirm that, @mfussi66, with your current setup? |
That's what I mean, both I can verify that by trying both devel and refactor with Ts = 45 us and Ts = |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
When inspecting the control mode switches to finalize the tests on the board, I noticed three occasions that I think are worth attention. See the plot below: I put arrows on the three events:
The Vq sent as feedback is scaled by Vcc. But if the same value is set as reference (such as a bumpless change of control mode), the value is scaled by Vmax. If Vmax < Vcc , the applied voltage lowers. |
Working as expected ✔
Targets.voltage needs to be scaled by Vcc and not Vmax. |
This is the last point to address: I'll also check if it happens in the original version of the architectural model. |
Indeed, it seems that it happens also with the upstream architectural model, see the video. Given that this workflow is very unlikely to happen, it might be useful to notify it in a separate issue with low priority. MATLABWindow_hnlp1F7PTL.mp4 |
Agree 👍🏻 |
Follow-up issue created: I think you can consider this task completed, @mfussi66 🎉 |
Ok so I think a recap of the must have features is in order:
If no feature is missing, I think we can indeed complete the task. |
To conclude this issue, I created these two PRs: |
Task description 📝
We recently refactored the motor control supervisor (see #65). We now have to test the new architecture on the AMC-BLDC board.
For this we need:
Useful links and documents
Definition of Done ✅
Demo with setup running with the new firmware.
Originally opened by @fiorisi in different repo.
As suggested by @pattacini, it will be useful to create the AMCBLDC customizations in a separate path, so that the two versions can live side by side.
The text was updated successfully, but these errors were encountered: