Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for CalibratedSensor on Stepper Motors #18

Open
c031917 opened this issue Jan 16, 2023 · 0 comments
Open

Add support for CalibratedSensor on Stepper Motors #18

c031917 opened this issue Jan 16, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@c031917
Copy link

c031917 commented Jan 16, 2023

I'd like to use the calibratedSensor on a stepper motor with:

MagneticSensorSPI sensor = MagneticSensorSPI(PA8, 14, 0x3FFF); 
// instantiate the calibrated sensor object
CalibratedSensor sensor_calibrated = CalibratedSensor(sensor);
StepperMotor motor = StepperMotor(50);
motor.linkSensor(&sensor_calibrated);

Currently only BLDCmotor is implemented.

I am not sure if just duplicating the code in CalibratedSensor.cpp and replacing

void CalibratedSensor::calibrate(BLDCMotor& motor){

by

void CalibratedSensor::calibrate(StepperMotor& motor){

and changing CalibratedSensor.h (add last line)

to:

#ifndef __CALIBRATEDSENSOR_H__
#define __CALIBRATEDSENSOR_H__

#include "common/base_classes/Sensor.h"
#include "BLDCMotor.h"
#include "StepperMotor.h"
#include "common/base_classes/FOCMotor.h"

class CalibratedSensor: public Sensor{

public:
    // constructor of class with pointer to base class sensor and driver
    CalibratedSensor(Sensor& wrapped);
    ~CalibratedSensor();

    /*
    Override the update function
    */
    virtual void update() override;

    /**
    * Calibrate method computes the LUT for the correction
    */
    virtual void calibrate(BLDCMotor& motor);
    virtual void calibrate(StepperMotor& motor);

is enough. The calculations about the electrical angles are for a BLDC motor, these might not fit to a stepper motor which has 90 degrees between its poles instead of 120 degrees.

May be somebody can provide the right calculations?

@runger1101001 runger1101001 added the enhancement New feature or request label Sep 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants