Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions documentation/design/wire-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,20 @@ received, as every configuration write is (e-foc `service-can.md` Part K).
|--------|-----------------|------|----------------------------|-----------|--------------|
| `0x64` | `telemetryRate` | Hz | 0 stops the stream, 1–1000 | no | within 1 ms |

**Contract 3.1 — position motion profile.** Version 3.1 adds four stored settings; nothing in 3.0 changes.
They are drive-wide limits like those of 2.9: they can be written in any state, are answered once stored, and a
write that cannot be stored is taken back. Position mode plans a trapezoidal path to each setpoint within them;
the profile is on only while `profileVelocity` and `profileAcceleration` are both above zero. A
`profileDeceleration` of 0 uses `profileAcceleration`. `profileJerk` is reserved for a later S-curve profile:
it is accepted, stored and read back, and the trapezoidal profile does not use it yet.

| ID | Parameter | Unit | Range | Automatic | Takes effect |
|--------|-----------------------|--------|-----------------------------------|-----------|-----------------------------|
| `0x65` | `profileVelocity` | rad/s | 0 – 5000, 0 profile off | no | at the next outer-loop tick |
| `0x66` | `profileAcceleration` | rad/s2 | 0 – 100000, 0 profile off | no | at the next outer-loop tick |
| `0x67` | `profileDeceleration` | rad/s2 | 0 – 100000, 0 the acceleration | no | at the next outer-loop tick |
| `0x68` | `profileJerk` | rad/s3 | 0 – 10000000, reserved, no effect | no | stored and read back only |

**Contract 2.1 — algorithms and parameters.** Version 2.1 adds four commands and two responses; nothing in
2.0 changes, so a 2.0 client keeps working against a 2.1 server and a 2.1 client can tell from the minor
version whether a server understands them.
Expand Down
4 changes: 4 additions & 0 deletions e-foc-protocol/contract/FocMotorMessages.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ namespace can
canBitrate = 0x62,
homingRequired = 0x63,
telemetryRate = 0x64,
profileVelocity = 0x65,
profileAcceleration = 0x66,
profileDeceleration = 0x67,
profileJerk = 0x68,
supervisionWindow = 0x70,
supervisionCurrentFraction = 0x71,
supervisionDemandedSpeed = 0x72,
Expand Down
8 changes: 6 additions & 2 deletions e-foc-protocol/contract/FocMotorWireContract.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
namespace can
{
static constexpr uint8_t focContractVersionMajor = 3;
static constexpr uint8_t focContractVersionMinor = 0;
static constexpr uint8_t focContractVersionMinor = 1;

constexpr bool IsCompatibleContract(uint8_t major, uint8_t minor)
{
Expand Down Expand Up @@ -263,7 +263,7 @@ namespace can

inline constexpr float focMaxReading{ std::numeric_limits<float>::max() };

inline constexpr std::array<ParameterDescriptor, 85> focParameters{ {
inline constexpr std::array<ParameterDescriptor, 89> focParameters{ {
{ FocParameter::currentBandwidth, "currentBandwidth", "rad/s", foc::CommandLimits::minBandwidth, foc::CommandLimits::maxCurrentBandwidth, false, true },
{ FocParameter::currentSwitchingGain, "currentSwitchingGain", "A", 0.0f, foc::CommandLimits::maxSwitchingGain, false, false },
{ FocParameter::currentBoundaryLayer, "currentBoundaryLayer", "A", foc::CommandLimits::minBoundaryLayer, foc::CommandLimits::maxBoundaryLayer, false, false },
Expand Down Expand Up @@ -304,6 +304,10 @@ namespace can
{ FocParameter::continuousCurrent, "continuousCurrent", "A", 0.0f, foc::CommandLimits::maxRatedCurrent, false, false },
{ FocParameter::peakCurrent, "peakCurrent", "A", 0.0f, foc::CommandLimits::maxRatedCurrent, false, false },
{ FocParameter::peakCurrentTime, "peakCurrentTime", "s", foc::CommandLimits::minPeakCurrentTime, foc::CommandLimits::maxPeakCurrentTime, false, false },
{ FocParameter::profileVelocity, "profileVelocity", "rad/s", 0.0f, foc::CommandLimits::maxOverspeedLimit, false, false },
{ FocParameter::profileAcceleration, "profileAcceleration", "rad/s2", 0.0f, foc::CommandLimits::maxSpeedRate, false, false },
{ FocParameter::profileDeceleration, "profileDeceleration", "rad/s2", 0.0f, foc::CommandLimits::maxSpeedRate, false, false },
{ FocParameter::profileJerk, "profileJerk", "rad/s3", 0.0f, foc::CommandLimits::maxProfileJerk, false, false },
{ FocParameter::positionWindow, "positionWindow", "rad", 0.0f, foc::CommandLimits::maxPositionWindow, false, false },
{ FocParameter::positionWindowTime, "positionWindowTime", "s", 0.0f, foc::CommandLimits::maxPositionWindowTime, false, false },
{ FocParameter::positionMinimum, "positionMinimum", "rad", -foc::CommandLimits::maxPositionLimit, foc::CommandLimits::maxPositionLimit, false, false },
Expand Down
4 changes: 2 additions & 2 deletions e-foc-protocol/contract/test/TestFocMotorWireContract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,10 +470,10 @@ TEST_F(FocMotorWireContractTest, a_select_control_mode_response_reaches_the_clie
DeliverToClient();
}

TEST_F(FocMotorWireContractTest, the_contract_is_version_3_0)
TEST_F(FocMotorWireContractTest, the_contract_is_version_3_1)
{
EXPECT_EQ(3, can::focContractVersionMajor);
EXPECT_EQ(0, can::focContractVersionMinor);
EXPECT_EQ(1, can::focContractVersionMinor);
}

TEST_F(FocMotorWireContractTest, a_ready_telemetry_status_frame_carries_state_five)
Expand Down
1 change: 1 addition & 0 deletions e-foc-protocol/foc/CommandLimits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ namespace foc
static constexpr float minFollowingErrorTime{ 0.001f };
static constexpr float maxFollowingErrorTime{ 10.0f };
static constexpr float maxSpeedRate{ 100000.0f };
static constexpr float maxProfileJerk{ 1.0e7f };
static constexpr float maxCommandTimeout{ 60.0f };
static constexpr float maxRatedCurrent{ 100.0f };
static constexpr float minPeakCurrentTime{ 0.1f };
Expand Down
1 change: 1 addition & 0 deletions e-foc-protocol/foc/Units.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace foc
using Radians = infra::Quantity<unit::Radians, float>;
using RadiansPerSecond = infra::Quantity<unit::Radians::Div<infra::Second>, float>;
using RadiansPerSecondSquared = infra::Quantity<unit::Radians::Div<infra::Second>::Div<infra::Second>, float>;
using RadiansPerSecondCubed = infra::Quantity<unit::Radians::Div<infra::Second>::Div<infra::Second>::Div<infra::Second>, float>;
using Nm = infra::Quantity<unit::NewtonMeter, float>;
using NewtonMeter = Nm;
using NewtonMeterSecondSquared = infra::Quantity<unit::NewtonMeter::Mul<infra::Second>::Mul<infra::Second>, float>;
Expand Down
Loading