Skip to content

Commit

Permalink
add fixed point type to algo type struct #49
Browse files Browse the repository at this point in the history
  • Loading branch information
akindyakov committed May 17, 2014
1 parent b8c2447 commit 012215e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
7 changes: 4 additions & 3 deletions firmware/SatStepperBegin/algo_types.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
#include "utils/macros.h"
#include "state.h"
#include "algo_types.h"
#include "pwm_wrap_module.h"

static const int_fast8_t onePhaseAlgoA[ONE_PHASE_ALGO_STEPS] = {1, 0, -1, 0};
static const int_fast8_t onePhaseAlgoB[ONE_PHASE_ALGO_STEPS] = {0, 1, 0, -1};
static const float onePhasePwmCoeff[ONE_PHASE_ALGO_PWM_STEPS] = {1};
static const uint16_t onePhasePwmCoeff[ONE_PHASE_ALGO_PWM_STEPS] = {1 * PWM_COEFF_DEVIDER};

static const int_fast8_t twoPhaseAlgoA[TWO_PHASE_ALGO_STEPS] = {1, -1, -1, 1};
static const int_fast8_t twoPhaseAlgoB[TWO_PHASE_ALGO_STEPS] = {1, 1, -1, -1};
static const float twoPhasePwmCoeff[TWO_PHASE_ALGO_PWM_STEPS] = {1};
static const uint16_t twoPhasePwmCoeff[TWO_PHASE_ALGO_PWM_STEPS] = {1 * PWM_COEFF_DEVIDER};

static const int_fast8_t halfPhaseAlgoA[HALF_PHASE_ALGO_STEPS] = {1, 1, 0, -1, -1, -1, 0, 1};
static const int_fast8_t halfPhaseAlgoB[HALF_PHASE_ALGO_STEPS] = {0, 1, 1, 1, 0, -1, -1, -1};
static const float halfPhasePwmCoeff[HALF_PHASE_ALGO_PWM_STEPS]= {1, 0.707};
static const uint16_t halfPhasePwmCoeff[HALF_PHASE_ALGO_PWM_STEPS]= {1 * PWM_COEFF_DEVIDER, 0.707 * PWM_COEFF_DEVIDER};

AlgoParams onePhaseParameters = {
onePhaseAlgoA,
Expand Down
2 changes: 1 addition & 1 deletion firmware/SatStepperBegin/algo_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ typedef struct _AlgoParams {

const uint_fast8_t algoStepsNumber;

const float* pwmCoeff;
const uint16_t* pwmCoeff;
const uint_fast8_t algoPwmStepsNumber;

const uint_fast8_t engineStepMultiplier;
Expand Down
7 changes: 2 additions & 5 deletions firmware/SatStepperBegin/control_algo.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@
#define _CONTROL_ALGO_INCLUDED_

#include <stdint.h>
<<<<<<< HEAD
void stop();
=======

void setAlgoType(uint_fast8_t algoType);

>>>>>>> b68f208957db667fc155d4ba94757c241cd9bfb0

void stop();
void step(int_fast8_t dist);

void nextStep();
Expand Down
2 changes: 1 addition & 1 deletion firmware/SatStepperBegin/pwm_wrap_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void initPwm(uint16_t prescaler);
void setPwm(uint16_t pwmDutyCycle);

#define PWM_COEFF_RANK 10
#define PWM_COEFF_DEVIDER 1 << 10
#define PWM_COEFF_DEVIDER (1 << PWM_COEFF_RANK)
void setCoeff(uint16_t pwmCoeff);

void setADirection(int_fast8_t direct);
Expand Down

0 comments on commit 012215e

Please sign in to comment.