blob: 90b2fb49c25f870f112656bed6e7b2c45f4118ea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
/*
* 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_ */
|