Skip to content

Commit

Permalink
Merge pull request #13 from adamb314/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
adamb314 authored Jul 24, 2023
2 parents 9984acb + 49f39f0 commit 0eb33ca
Show file tree
Hide file tree
Showing 112 changed files with 110,859 additions and 5,399 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
ArduinoSketch/enableAutoUpload
..*
*.sublime-workspace
*.sublime-project
ArduinoSketch/config/*
CadFiles/**/*.FCStd1
PcbDesignes/**/*-cache*
PcbDesignes/**/*.sch-bak
.thankyou
ArduinoSketch/last*.txt
ArduinoSketch/*ToLoad.txt
23 changes: 19 additions & 4 deletions ArduinoLibrary/ServoProjectController/ServoProjectController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,20 @@ void DCServoCommunicator::updateOffset()
}
}

void DCServoCommunicator::setControlSpeed(unsigned char controlSpeed)
void DCServoCommunicator::setControlSpeed(unsigned char controlSpeed, float inertiaMarg)
{
setControlSpeed(controlSpeed, controlSpeed * 4, controlSpeed * 32);
setControlSpeed(controlSpeed, controlSpeed * 4, controlSpeed * 32, inertiaMarg);
}

void DCServoCommunicator::setControlSpeed(unsigned char controlSpeed,
unsigned short int velControlSpeed, unsigned short int filterSpeed)
unsigned short int velControlSpeed, unsigned short int filterSpeed,
float inertiaMarg)
{
this->controlSpeed = controlSpeed;
this->velControlSpeed = velControlSpeed;
this->filterSpeed = filterSpeed;
inertiaMarg = stdmin::min(stdmin::max(inertiaMarg, 1.0), 1.0 + 255.0 / 128);
this->inertiaMarg = static_cast<unsigned char>(stdmin::round((inertiaMarg - 1.0) * 128.0));
}

void DCServoCommunicator::setBacklashControlSpeed(unsigned char backlashCompensationSpeed,
Expand Down Expand Up @@ -271,7 +274,18 @@ void DCServoCommunicator::setReference(const float& pos, const float& vel, const
newPositionReference = true;
newOpenLoopControlSignal = false;
refPos = (pos - offset) / scale * positionUpscaling;
refVel = vel / scale;

int sign = 0;
if (vel > 0.0f)
{
sign = 1;
}
else if (vel < 0.0f)
{
sign = -1;
}
refVel = stdmin::round(vel / scale);
refVel = stdmin::max(1, stdmin::abs(refVel)) * sign;

if (refVel > 4)
{
Expand Down Expand Up @@ -458,6 +472,7 @@ CommunicationError DCServoCommunicator::run()
bus->write(3, static_cast<char>(controlSpeed));
bus->write(4, static_cast<char>(stdmin::round(velControlSpeed / 4.0f)));
bus->write(5, static_cast<char>(stdmin::round(filterSpeed / 32.0f)));
bus->write(10, static_cast<char>(inertiaMarg));
bus->write(6, static_cast<char>(backlashCompensationSpeed));
bus->write(7, static_cast<char>(backlashCompensationSpeedVelDecrease));
bus->write(8, static_cast<char>(backlashSize));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class ContinuousValueUpCaster

class DCServoCommunicator
{
public:
public:
class OpticalEncoderChannelData
{
public:
Expand All @@ -265,9 +265,9 @@ class DCServoCommunicator

void setOffsetAndScaling(float scale, float offset, float startPosition = 0);

void setControlSpeed(unsigned char controlSpeed);
void setControlSpeed(unsigned char controlSpeed, float inertiaMarg = 1.0);
void setControlSpeed(unsigned char controlSpeed, unsigned short int velControlSpeed,
unsigned short int filterSpeed);
unsigned short int filterSpeed, float inertiaMarg = 1.0);

void setBacklashControlSpeed(unsigned char backlashCompensationSpeed,
float backlashCompensationCutOffSpeed, float backlashSize);
Expand Down Expand Up @@ -312,7 +312,7 @@ class DCServoCommunicator

CommunicationError run();

private:
private:
void updateOffset();

Communication* bus{nullptr};
Expand All @@ -329,6 +329,7 @@ class DCServoCommunicator
unsigned char controlSpeed{50};
unsigned short int velControlSpeed{50 * 4};
unsigned short int filterSpeed{50 * 32};
unsigned char inertiaMarg{0};
unsigned char backlashCompensationSpeed{10};
unsigned char backlashCompensationSpeedVelDecrease{0};
unsigned char backlashSize{0};
Expand Down
4 changes: 2 additions & 2 deletions ArduinoSketch/ArduinoSketch.ino
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "ArduinoC++BugFixes.h"
#include "ThreadHandler.h"
#include "src/ArduinoC++BugFixes.h"
#include "src/Hardware/ThreadHandler.h"

#include "config/config.h"

Expand Down
8 changes: 0 additions & 8 deletions ArduinoSketch/ArduinoSketch.sublime-project

This file was deleted.

119 changes: 0 additions & 119 deletions ArduinoSketch/CurrentControlLoop.h

This file was deleted.

Loading

0 comments on commit 0eb33ca

Please sign in to comment.