This repository has been archived on 2025-02-01. You can view files and clone it, but cannot push or open issues or pull requests.
reprapfirmware-dc42/src/Movement/DeltaProbe.h
David Crocker ad8aa69794 Reduced header file coupling
Restructured the header file inclusion so that the .cpp files are
dependent on fewer header files, resulting in less recompilation when
most header files are changed
2016-12-25 17:35:47 +00:00

46 lines
2.1 KiB
C++

/*
* DeltaProbe.h
*
* Created on: 20 Apr 2015
* Author: David
*/
#ifndef DELTAPROBE_H_
#define DELTAPROBE_H_
#include "RepRapFirmware.h"
// Class to hold the parameters for my new Z probing method
class DeltaProbe
{
enum class State { normal, stopping, stopped, overran };
// Fixed parameters
static const unsigned int MaxSteps = 30; // 15 corresponds to 0.375mm p-p movement @ 80 steps/mm
// Static parameters, set up before we start probing and unchanged during probing
unsigned int normalSteps; // the number of steps we use to achieve the requested amplitude
unsigned int halfCyclesPerIncrement; // how many half cycles between lowering the head by 1 step
unsigned int maxIncrements; // max number of steps we lower the head
uint32_t halfCycleTime; // how many interrupt clocks per quarter cycle
uint32_t normalStepTable[MaxSteps]; // table of step times for the first half cycle, in interrupt clocks from start
uint32_t incStepTable[MaxSteps + 1]; // table of step times for the first half cycle, when we are moving down a step
// Dynamic parameters, to track the progress of the probe
unsigned int stepsDone; // how many steps since the start of this quarter cycle
unsigned int halfCycleCount; // how many quarter cycles since we started or lowered the head
unsigned int numIncrements; // how many steps we have lowered the head since we started
bool incrementing; // true if we are lowering the head 2 step in this half cycle
State state; // what state the probe is in
public:
bool Init(float frequency, float amplitude, float rate, float height); // Get ready to probe
uint32_t Start(); // start the process, return the next step time
bool GetDirection() const; // get the direction for the current step
uint32_t CalcNextStepTime(); // calculate when the next step is due
void Trigger(); // cease probing
bool Finished() const { return state == State::stopped || state == State::overran; }
bool Overran() const { return state == State::overran; }
};
#endif /* DELTAPROBE_H_ */