fix calibration

This commit is contained in:
Dennis Gunia
2025-09-13 00:58:14 +02:00
parent 942deb2c9c
commit cd832083c4
3 changed files with 10 additions and 4 deletions

View File

@@ -173,7 +173,7 @@ int main()
{
initialSetup();
rs485_init();
mctrl_init();
mctrl_init(calib_offset);
while (1 == 1)
{

View File

@@ -46,9 +46,15 @@ uint16_t currentVoltage = 0; // current ADC reading
uint8_t currentFaultReadings = 0; // ticks with faulty readings (too many will
// trip pwrdwn and sts_flag_fuse)
int STEPS_OFFSET = 0;
// initialize motor controller
void mctrl_init()
void mctrl_init(int cal_offset)
{
if (cal_offset < 800){
STEPS_OFFSET = STEPS_OFFSET_DEF;
}else{
STEPS_OFFSET = cal_offset;
}
DDRC = 0x0F; // set all pins as outputs
PORTC = 0x00; // set all to LOW

View File

@@ -15,7 +15,7 @@
#define STEPS_PER_REV 2025 // steps per revolution
#define STEPS_PER_FLAP 45 // steps per flap
#define STEPS_ADJ 0 // added per flap to compensate for motor power down
#define STEPS_OFFSET 1400 // ansolute offset between home and first flap
#define STEPS_OFFSET_DEF 1400 // ansolute offset between home and first flap
#define AMOUNTFLAPS 45 // amount of flaps installed in system
#define STEPS_AFTERROT 255 // value to goto after current target flap is reached
#define ERROR_DATASETS 8 // length of error array
@@ -33,7 +33,7 @@
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
void mctrl_init();
void mctrl_init(int cal_offset);
void mctrl_step();
void mctrl_set(uint8_t flap, uint8_t fullRotation);