📄 parameters.c
字号:
/**********************************************************************
* *
* Software License Agreement *
* *
* The software supplied herewith by Microchip Technology *
* Incorporated (the "Company") for its dsPIC controller *
* is intended and supplied to you, the Company's customer, *
* for use solely and exclusively on Microchip dsPIC *
* products. The software is owned by the Company and/or its *
* supplier, and is protected under applicable copyright laws. All *
* rights are reserved. Any use in violation of the foregoing *
* restrictions may subject the user to criminal sanctions under *
* applicable laws, as well as to civil liability for the breach of *
* the terms and conditions of this license. *
* *
* THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO *
* WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, *
* BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND *
* FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE *
* COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, *
* INCIDENTAL OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. *
* *
**********************************************************************/
/**********************************************************************
* *
* Author: Smart Power Soutions, LLP *
* *
* Filename: parameters.c *
* Date: 12/10/03 *
* File Version: 3.01 *
* Project: 53 *
* Drawing: 2 *
* *
* Tools used: MPLAB C30 Compiler v 1.10.02 *
* *
* Linker File: p30f6010A2.gld *
* *
* *
***********************************************************************
* Code Description
*
* This file contains all the parameter data
* used by the user interface.
* Note that defs.h contains #define NO_PARAMETERS
* This must be changed if parameters are added or removed
*
* 'user_parameters[]' is the array of parameters stored in program
* Flash. It is aligned to a row boundary (32 instructions.
* The 'parameter_data[]' structure contains all the user interface
* information for each parameter. This includes the text message
* associated w/ the paramater that will be displayed on the LCD.
* The structure also contains the upper/lower limits of the parameter,
* and how fast the parameter value will change when the button is
* held for a period of time.
*
**********************************************************************/
#include "defs.h"
struct parameter_data
{
unsigned int min; /*minimum allowed value */
unsigned int max; /*maximum allowed value */
unsigned int med; /*the medium rate parameter increment*/
unsigned int fast; /*the fast rate parameter increment*/
char *line1_msg; /*line 1 parameter screen message */
char *units_msg; /*units message used for RHS line 2*/
};
const struct parameter_data parameter_data [] = {
/* Min, Max, Med delta, Fast delta, Line1 msg, Units msg */
{0,1,1,1, "DIRECTION DEMAND"," FWD/BKWD"},//0
{0,3,1,1, " CONTROL MODE "," "},//1
{0,32767,10,100, "Lock Pos.1 Time"," 10ms/bit"},//2
{0,32767,10,100, "Lock Pos.2 Time"," 10ms/bit"},//3
{0,100,5,10, "Lock Pos.1 Dem. "," % Demand"},//4
{0,100,5,10, "Lock Pos.2 Dem. "," % Demand"},//5
{1,9999,10,100, "Ramp Start Speed"," Revs/min"},//6
{1,9999,10,100, "Ramp End Speed"," Revs/min"},//7
{0,100,2,5, "Ramp Start Dem. "," % Demand"},//8
{0,100,2,5, "Ramp End Dem. "," % Demand"},//9
{1,32767,10,100, "Ramp Duration "," 10ms/bit"},//10
{1,32767,10,100, "Phase Adv. Start"," Revs/min"},//11
{1,32767,10,100, "Phase Adv. Slope"," see docs"},//12
{1,32767,10,100, "Stall Time Limit"," 10ms/bit"},//13
{1,32767,10,100, "Over Speed Limit"," Revs/min"},//14
{1,32767,10,100, "Over Volts Limit","0.1V/bit "},//15
{1,32767,10,100, "Over Current Lim","0.1A/bit "},//16
{0,32767,100,500, "Current P Gain "," "},//17
{0,32767,100,500, "Current I Gain "," "},//18
{0,32767,100,500, "Current D Gain "," "},//19
{0,9999,10,100, "Speed P Gain "," "},//20
{0,9999,10,100, "Speed I Gain "," "},//21
{0,32767,10,100, "Voltage Demand ","0.1V/bit "},//22
{0,32767,100,500, "Volts P Gain "," "},//23
{0,32767,100,500, "Volts I Gain "," "},//24
{2,48,2,4, "No. Motor Poles "," Even !"},//25
{1,3670,10,100, "Current Scale X "," "},//26
{1,6550,10,100, "Current Scale / "," "},//27
{1,3670,10,100, "Volts Scale X "," "},//28
{1,6550,10,100, "Volts Scale / "," "},//29
{1,100,5,20, "Tolerance Check "," % "},//30
{0,1,1,1, "Auto Re-acquire "," ON / OFF"},//31
{0,255,1,2, "Blanking Count "," "},//32
{0,255,1,2, "Zero X Level Thd"," "},//33
{1,1023,1,2, "Acquire Threshld"," ADC VAL "},//34
{0,255,1,2, "Acquire Level Td"," "},//35
{0,32767,10,100, "Rotation Timeout"," 10ms/bit"},//36
{1,100,2,10, "Pot / for Duty "," "},//37
{1,100,2,10, "Pot / for Currnt"," "},//38
{1,64,2,5, "Pot X for Speed "," "},//39
{0,1,1,1, "Starting Control"," 1=V, 0=I"},//40
{0,100,5,10, "Windmilling Dem."," % Demand"},//41
{1,32767,10,100, "Braking Ramp T "," 10ms/bit"},//42
{0,1,1,1, "Acquire Method "," see docs"},//43
{1,9999,10,100, "ZeroX Enable Spd"," Revs/min"},//44
};
// User parameters are stored in program Flash as EEPROM is not currently functional.
// New values are to be stored using special routines written in assembler for erase
// and write. Read will be done via PSV thus allowing C code to access the values directly.
// The values must therefore be stored on a Flash memory row boundary as can only
// erase 1 row (16 program locations) at a time. This is the purpose of the aligned attribute.
// Furthermore, can not use the normal const C declaration as otherwise have problems when
// using compiler optimization. Therefore use the section attribute to instruct the linker
// to place the "variable" into the const section whilst compiler still treats it as a
// variable which can change outside of it's control owing to volatile declaration
// The initialized values are the default values used when programming
// Note that even if all values in a block of 32 are not used, the array size must be declared
// in integar multiples of 32 as the erase can only be done on a single flash row of 32.
// If this is not done it is possible that linker may put other constants or even program code
// just after the array which are inadvertantly erased along with the parameters!
volatile unsigned int user_parameters[64] __attribute__((aligned(64),far,section(".const,r")))=
{ FORWARDS, // Direction Demand
CLOSED_VOLTS, // Speed Control Mode - See defs.h
50, // First Lock Position Time in units of medium event (10ms)
50, // Second Lock Position Time in units of medium event (10ms)
50, // % Demand Used For Lock Position 1
50, // % Demand Used For Lock Position 2
100, // Starting Speed for Ramp / RPM
2000, // Finish Speed for Ramp / RPM
52, // % Demand Used At Start of Ramp
68, // % Demand Used At End of Ramp
15, // Duration of starting ramp in units of medium event (10ms)
1500, // Phase Advance Start Speed in RPM
25, // Phase Advance Slope in 1/1000th elec. degree / RPM
100, // Stall Time Limit in units of medium event (10ms)
3500, // Over Speed Trip in RPM
500, // Over Voltage Trip in 1/10ths V
100, // Over Current Limit in 1/10ths A
900, // Current Loop P Gain
100, // Current Loop I Gain
0, // Current Loop D Gain
2500, // Speed Loop P Gain
40, // Speed Loop I Gain
490, // Voltage Demand for Brake Chopper in 1/10ths V
10000, // Voltage Loop P Gain
5000, // Voltage Loop I Gain
10, // Number of Motor Poles
100, // Current Scaling X - see below
539, // Current Scaling / - see below
100, // Voltage Scaling X - see below
1305, // Voltage Scaling / - see below
90, // % Tolerance used for Lost Check - see below
1, // Auto-reaquire if lost ON/OFF
1, // Blanking Length used for zero X in no of ADC samples
2, // No. of samples required > or < VDC/2 before zero X checked for
12, // ADC value used for rising edge detect for acquisition routine
6, // No of samples of VPH before rising edge detect done in acquisition
5, // Rotation Timeout in units of medium event (10ms)
1, // Divisor used to scale pot ADC reading to Duty Cycle
8, // Divisor used to scale pot ADC reading to I Dem in ADC
3, // X Used to Scale pot ADC reading to wdemand in rpm
1, // 1=Use Voltage Control for Starting, 0=Use Current Control
20, // % Demand Used For Windmilling Braking
1, // Duration of braking ramp in units of medium event (10ms)
0, // Use Method 1 (=0) or Method 2 (=1) for acquisition of position
200}; // Speed at Which ZeroX detection enabled when using method1 acqusition
// Current and Voltage Scaling X and / Parameters
// These are used to scale ADC readings into Amps or Volts as follows:
// If you get 12.87 A/V for ibus or 12.87 V/V for vdc then
// X = 100 and / = 1287 is one possible combination
// For LV Power Module Use The Following values:
// VX=100 V/=1305 i.e scaling is 13.05 V/V
// If LK11&12 Open IX=100 I/=539 i.e scaling is 5.39A/V
// If LK11&12 Closed IX=10 I/=119 i.e.scaling is 11.9A/V
// For HV Power Module Use The Following values:
// VX=10 V/910 i.e. scaling is 91.0 V/V
// If LK11&12 Open IX=100 I/=108 i.e scaling is 1.08A/V
// if LK11&12 Closed IX=100 I/=239 i.e scaling is 2.39A/V
// Tolerance for Lost Check Parameter
// Every 60 electrical degrees a new zero crossing event should
// be detected. In order to determine if the system is lost,
// a check is carried out comparing the time elapsed since the
// last zero crossing and the one before that.
// If the tolerance parameter is set to 25% then up to 25%
// variation between the two times is considered to be acceptable.
// If the system fails the check, then the system is lost.
// Some natural variation in the times is to be expected even at
// a constant speed due to timer and ADC resolution as well as
// motor asymmetry. Speed changes will also result in variation.
// It is suggested that the parameter is not set to less than 25%
// as otherwise the system may be determined to lost just due to
// normal variations.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -