Source file: /~heha/enas/Kleingeräte/ika-rkt.zip/PMSM.h

#pragma once
#include <stdint.h>

//! Dead time (Timer/counter1 clock cycles).
#define DEAD_TIME		10

/*! \brief The number of elements in the sine modulation table per phase.
 *
 *  This is the number of elements in the sine modulation table used to
 *  represent the waveform for one phase. Note that this is not the same
 *  as the number of elements in the sineTable stored in flash.
 */
#define SINE_TABLE_LENGTH	192U


/*! Sine table size. Select what sine table size should be used.
 */
#define SINE_TABLE_SIZE_SMALL	1	// small (64 elements) sine table.
				// Otherwise large (3 * 192 elements) sine table.


/*! The number of commutation 'ticks' that must pass without any hall changes
 *  before the motor is considered to be stopped.
 *
 *  \todo Adjust the motor stopped limit.
 */
#define COMMUTATION_TICKS_STOPPED     6000


/*! This constant specifies the number of subsequent detections of correct
 *  direction of rotation needed before the firmware is considered synchronized
 *  with the motor. (SYNCHRONIZATION_COUNT + 1) hall sensor changes in the
 *  same direction are needed.
 */
#define SYNCHRONIZATION_COUNT       2

enum {
 MOTOR_STOPPED		= 1<<0,
 MOTOR_SYNCHRONIZED	= 1<<1,
 DIR_REVERSE		= 1<<2,		//! Reverse direction flag
 DIR_KNOWN		= 1<<3,		//! Known direction flag
 WANTDIR_REVERSE	= 1<<4,
 WF_SINUSOIDAL		= 1<<5,	//! Waveform status for sinusoidal driving.
 WF_BRAKING		= 2<<5,	//! Waveform status for braking.
 WF_BLOCK_COMMUTATION	= 3<<5,	//! Waveform status for block commutation.
};

//! The number to multiply speed input with to produce duty cycle compare value (0-255).
#define BLOCK_COMMUTATION_DUTY_MULTIPLIER	3


/*! Turn mode. If not set, TURN with disabled drivers
 *
 *  \todo Select turn mode.
 */
#define TURN_MODE_BRAKE			1

/*! The number of ticks between each iteration of the speed loop.
 *  \todo Adjust speed control loop time base.
 */
#define SPEED_CONTROLLER_TIME_BASE	150
Detected encoding: ASCII (7 bit)2