Skip to content

Commit

Permalink
Axis CPR reports 0 if no encoder available to prevent errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Ultrawipf committed Jun 9, 2024
1 parent 8f8e0da commit edfbe5a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Firmware/FFBoard/Src/Axis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -898,9 +898,12 @@ CommandStatus Axis::command(const ParsedCommand& cmd,std::vector<CommandReply>&
break;

case Axis_commands::cpr:
if (cmd.type == CMDtype::get && this->drv->getEncoder() != nullptr)
if (cmd.type == CMDtype::get)
{
uint32_t cpr = this->drv->getEncoder()->getCpr();
uint32_t cpr = 0;
if(this->drv->getEncoder() != nullptr){
cpr = this->drv->getEncoder()->getCpr();
}
//#ifdef TMC4671DRIVER // CPR should be consistent with position. Maybe change TMC to prescale to encoder count or correct readout in UI
// TMC4671 *tmcdrv = dynamic_cast<TMC4671 *>(this->drv.get()); // Special case for TMC. Get the actual encoder resolution
// if (tmcdrv && tmcdrv->hasIntegratedEncoder())
Expand Down

0 comments on commit edfbe5a

Please sign in to comment.