This repository has been archived by the owner on Dec 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 58
/
VoltTempMonitoring.pde
79 lines (69 loc) · 1.76 KB
/
VoltTempMonitoring.pde
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* Example of how to soft-monitor your lipos
*/
#include <ax12.h>
#include <BioloidController.h>
#include "nuke.h"
#define SERVO_COUNT 12
float volts;
int temps[SERVO_COUNT];
int servo; // which servo to measure
void setup(){
// setup IK
setupIK();
gaitSelect(RIPPLE);
// setup serial
Serial.begin(38400);
// wait, then check the voltage (LiPO safety)
delay (1000);
float volts = (ax12GetRegister (1, AX_PRESENT_VOLTAGE, 1)) / 10.0;
Serial.print ("System Voltage: ");
Serial.print (volts);
Serial.println (" volts.");
if(volts < 10.0)
while(1);
// stand up slowly
bioloid.poseSize = SERVO_COUNT;
bioloid.readPose();
doIK();
bioloid.interpolateSetup(1000);
while(bioloid.interpolating > 0){
bioloid.interpolateStep();
delay(3);
}
}
void loop(){
// Whatever code here to control the bot
// update IK if needed
if(bioloid.interpolating == 0){
// setup our next move
doIK();
bioloid.interpolateSetup(tranTime);
// get voltage, we use a small amount of filtering here
volts = (0.8*volts)+(0.2*((ax12GetRegister(1+servo,AX_PRESENT_VOLTAGE,1)/10.0)));
// and temperatures
temps[servo] = ax12GetRegister(1+servo,AX_PRESENT_TEMPERATURE,1);
servo++;
// finished looping? if so, output our data
if(servo == 12){
Serial.print("Volts:");
Serial.println(volts);
for(servo=0;servo<12;servo++){
Serial.print("S");
Serial.print(servo+1);
Serial.print(":");
Serial.println(temps[servo]);
}
servo = 0;
if(volts < 9.6){
// battery depleted, turn off servo torque.
int i;
for(i =1; i<=SERVO_COUNT;i++)
Relax(i);
while(1);
}
}
}
// update joints
bioloid.interpolateStep();
}