parent
314233b37f
commit
98ef2368a0
|
|
@ -142,7 +142,7 @@ void Panic(ErrorCode ec) {
|
||||||
|
|
||||||
void RuntimeHWChecks() {
|
void RuntimeHWChecks() {
|
||||||
mv::vcc.Step();
|
mv::vcc.Step();
|
||||||
if (mv::vcc.CurrentVCC() > config::VCCADCThreshold) {
|
if (mv::vcc.CurrentBandgapVoltage() > config::VCCADCThreshold) {
|
||||||
// stop all motors at once
|
// stop all motors at once
|
||||||
mm::motion.AbortPlannedMoves();
|
mm::motion.AbortPlannedMoves();
|
||||||
// kill all TMC
|
// kill all TMC
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,10 @@ namespace voltage {
|
||||||
/// - AVCC=5V, you get VAL=225.06
|
/// - AVCC=5V, you get VAL=225.06
|
||||||
/// - AVCC=4.1V, you get VAL=274.46
|
/// - AVCC=4.1V, you get VAL=274.46
|
||||||
/// - AVCC=4V, you get VAL=281.35
|
/// - AVCC=4V, you get VAL=281.35
|
||||||
/// - any lower and the board will probably die sooner than being able to report anything
|
///
|
||||||
|
/// Any lower and the board will probably die sooner than being able to report anything.
|
||||||
|
/// The TMC will die, but the atmega32u4 seems to be a bit more resilient.
|
||||||
|
/// It's still out of spec anyway since the atmega32u4 is rated for 16MHz only at >4.5V.
|
||||||
class VCC {
|
class VCC {
|
||||||
public:
|
public:
|
||||||
inline constexpr VCC()
|
inline constexpr VCC()
|
||||||
|
|
@ -23,9 +26,9 @@ public:
|
||||||
/// Reads the ADC, checks the value
|
/// Reads the ADC, checks the value
|
||||||
void Step();
|
void Step();
|
||||||
|
|
||||||
/// @returns the current VCC voltage level, platform dependent.
|
/// @returns the current bandgap voltage level, platform dependent.
|
||||||
/// @note see VCC measurement setup in config.h
|
/// @note see VCC measurement setup in config.h
|
||||||
uint16_t CurrentVCC() const { return vcc_val; }
|
uint16_t CurrentBandgapVoltage() const { return vcc_val; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint16_t vcc_val;
|
uint16_t vcc_val;
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,7 @@
|
||||||
| 0x1eh 30 | uint16 | Set/Get Pulley iRun current| 0-31 | 14h 20 | 20->350mA: see TMC2130 current conversion| Read / Write | M707 A0x1e | M708 A0x1e Xn
|
| 0x1eh 30 | uint16 | Set/Get Pulley iRun current| 0-31 | 14h 20 | 20->350mA: see TMC2130 current conversion| Read / Write | M707 A0x1e | M708 A0x1e Xn
|
||||||
| 0x1fh 31 | uint16 |Set/Get Selector iRun current| 0-31 | 1fh 31 | 31->530mA: see TMC2130 current conversion| Read / Write | M707 A0x1f | M708 A0x1f Xn
|
| 0x1fh 31 | uint16 |Set/Get Selector iRun current| 0-31 | 1fh 31 | 31->530mA: see TMC2130 current conversion| Read / Write | M707 A0x1f | M708 A0x1f Xn
|
||||||
| 0x20h 32 | uint16 | Set/Get Idler iRun current | 0-31 | 1fh 31 | 31->530mA: see TMC2130 current conversion| Read / Write | M707 A0x20 | M708 A0x20 Xn
|
| 0x20h 32 | uint16 | Set/Get Idler iRun current | 0-31 | 1fh 31 | 31->530mA: see TMC2130 current conversion| Read / Write | M707 A0x20 | M708 A0x20 Xn
|
||||||
| 0x21h 33 | uint16 | Current VCC voltage level | 225-281 | | 225->5V, 281->4V, higher values mean lower voltage and the board would probably die sooner than reporting anything | Read only | M707 A0x21 | N/A
|
| 0x21h 33 | uint16 | Current bandgap voltage level | 225-281 | | 225->5V, 281->4V, higher values mean lower voltage and the board would probably die sooner than reporting anything | Read only | M707 A0x21 | N/A
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct RegisterFlags {
|
struct RegisterFlags {
|
||||||
|
|
@ -398,7 +398,7 @@ static const RegisterRec registers[] /*PROGMEM*/ = {
|
||||||
1),
|
1),
|
||||||
// 0x21 Current VCC voltage level R
|
// 0x21 Current VCC voltage level R
|
||||||
RegisterRec(
|
RegisterRec(
|
||||||
[]() -> uint16_t { return mv::vcc.CurrentVCC(); },
|
[]() -> uint16_t { return mv::vcc.CurrentBandgapVoltage(); },
|
||||||
2),
|
2),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue