Delivery Version V1.01
- fixed 20A Sensor AC712 bidir - Pumped up to 9Nm with new Transformator
This commit is contained in:
@@ -1 +1 @@
|
||||
<AVRWorkspace><IOSettings><CurrentRegisters/></IOSettings><part name="AT90S8515"/><Files><File00000 Name="E:\AVR\screwer\screwer.c" Position="229 77 1095 775" LineCol="127 11" State="Maximized"/><File00001 Name="E:\AVR\screwer\floating_avg.h" Position="409 276 952 727" LineCol="24 25" State="Maximized"/></Files></AVRWorkspace>
|
||||
<AVRWorkspace><IOSettings><CurrentRegisters/></IOSettings><part name="AT90S8515"/><Files><File00000 Name="E:\AVR\screwer\screwer.c" Position="241 118 1212 766" LineCol="114 0"/></Files></AVRWorkspace>
|
||||
|
||||
59
screwer.c
59
screwer.c
@@ -24,7 +24,7 @@ nst, 07.11.2005
|
||||
#define LCD_EN PC6
|
||||
|
||||
//Devel
|
||||
#define TORQUE_DEBUG //To debug floating AVG
|
||||
//#define TORQUE_DEBUG //To debug floating AVG
|
||||
//#define ADC_DEBUG //To debug ADC channels
|
||||
|
||||
//Prototypes
|
||||
@@ -62,7 +62,7 @@ ISR (ADC_vect)
|
||||
{
|
||||
gu16AdcRes [ADC_CURRENT] = 512 - gu16AdcRes [ADC_CURRENT];
|
||||
}
|
||||
AddToFloatAvg (&gFilterCurrent, gu16AdcRes [ADC_CURRENT]);
|
||||
//AddToFloatAvg (&gFilterCurrent, gu16AdcRes [ADC_CURRENT]);
|
||||
}
|
||||
|
||||
u8ActChannel += 1;
|
||||
@@ -77,16 +77,16 @@ int main (void)
|
||||
//++++++++++++++++++++++++++++++++++++
|
||||
//declaration
|
||||
char sBuffer [20];
|
||||
char sState [3];
|
||||
char sState [7];
|
||||
unsigned char bStarted, bMotorLeft, bTorqueReached = 0;
|
||||
uint16_t u16Current, u16CurrentZero, u16CurrentReached, u16CurrentReachedRAW;
|
||||
uint16_t u16SetpointSpeed = 0, u16LCDTrigger = 1;
|
||||
double fTorque, fSetpointTorque, fReachedTorque, fReachedTorqueRAW;
|
||||
|
||||
const double fCurrentStep = 0.02466;
|
||||
const double fCurrentStep = 0.04932; //From Sensortype
|
||||
const double fTorqueConstant = 0.630; //Nm/A from Motortype
|
||||
const double fTorqueSetpointStep = 0.00615234; //From Sensortype 0.009885
|
||||
const double fSetpintTorqueMax = 6.0; //From Sensortype Nm
|
||||
const double fTorqueSetpointStep = 0.01230469; //From Sensortype 0.009885
|
||||
const double fSetpointTorqueMax = 9.0; //From Sensortype / PowwerSupply Nm
|
||||
double fCurrTorqueConst = fCurrentStep * fTorqueConstant;
|
||||
//Portsetup
|
||||
//LCD on Port C !!!
|
||||
@@ -115,7 +115,7 @@ int main (void)
|
||||
|
||||
// Disclaimer
|
||||
set_cursor (0, 1);
|
||||
lcd_string (" MS-7DA v1.00");
|
||||
lcd_string (" MS-7DA v1.01");
|
||||
set_cursor (0, 2);
|
||||
lcd_string (" Babacek Rest");
|
||||
for (u16LCDTrigger = 20000; u16LCDTrigger == 0; u16LCDTrigger--) _delay_ms (1);
|
||||
@@ -130,8 +130,8 @@ int main (void)
|
||||
|
||||
//Read Current Vallue fom IC
|
||||
//Floating Average
|
||||
u16Current = GetOutputValue (&gFilterCurrent);
|
||||
//uiCurrent = gu16AdcRes [ADC_CURRENT];
|
||||
//u16Current = GetOutputValue (&gFilterCurrent);
|
||||
u16Current = gu16AdcRes [ADC_CURRENT];
|
||||
|
||||
|
||||
|
||||
@@ -139,16 +139,25 @@ int main (void)
|
||||
if (gcStopped)
|
||||
{
|
||||
bMotorLeft = PIND & (1 << PD3);
|
||||
if (bMotorLeft)
|
||||
{
|
||||
strcpy (sState, "Li");
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy (sState, "Re");
|
||||
}
|
||||
//Motor stopped so recalibrate
|
||||
//FixMe bad idea u16CurrentZero = u16Current;
|
||||
//Get potis
|
||||
u16SetpointSpeed = gu16AdcRes [ADC_SETPOINT_SPEED];
|
||||
//u16SetpointSpeed = gu16AdcRes [ADC_SETPOINT_SPEED];
|
||||
u16SetpointSpeed = 1023;
|
||||
fSetpointTorque = (double) gu16AdcRes [ADC_SETPOINT_TORQUE] * fTorqueSetpointStep;
|
||||
//Minumum Torque
|
||||
if (fSetpointTorque < 0.5)
|
||||
fSetpointTorque = 0.5;
|
||||
if (fSetpointTorque > fSetpintTorqueMax)
|
||||
fSetpointTorque = fSetpintTorqueMax;
|
||||
if (fSetpointTorque > fSetpointTorqueMax)
|
||||
fSetpointTorque = fSetpointTorqueMax;
|
||||
|
||||
}
|
||||
else
|
||||
@@ -177,7 +186,6 @@ int main (void)
|
||||
|
||||
if (!bStarted)
|
||||
{
|
||||
strcpy (sState, "Li");
|
||||
bStarted = 1;
|
||||
}
|
||||
}
|
||||
@@ -192,7 +200,6 @@ int main (void)
|
||||
PORTD &= ~(1 << PD5);
|
||||
if (!bStarted)
|
||||
{
|
||||
strcpy (sState, "Re");
|
||||
bStarted = 1;
|
||||
}
|
||||
}
|
||||
@@ -202,13 +209,12 @@ int main (void)
|
||||
PORTD &= ~(1 << PD5);
|
||||
//smooth stop
|
||||
PORTD |= (1 << PD6) | (1 << PD7);
|
||||
gu16SpeedDelay = 0x1ff;
|
||||
gu16SpeedDelay = 0x02ff;
|
||||
bTorqueReached = 0;
|
||||
bStarted = 0;
|
||||
strcpy (sState, "St");
|
||||
}
|
||||
|
||||
if ((fTorque > fSetpointTorque) && !gu16SpeedDelay && !bTorqueReached)
|
||||
if ((((fTorque > fSetpointTorque) && !bMotorLeft) || (fTorque > fSetpointTorqueMax) )&& !gu16SpeedDelay && !bTorqueReached)
|
||||
{
|
||||
//Torque Stop after start ramp
|
||||
PORTD &= ~(1 << PD4);
|
||||
@@ -234,7 +240,7 @@ int main (void)
|
||||
#ifdef ADC_DEBUG
|
||||
set_cursor (0, 1);
|
||||
sprintf (sBuffer, "M%d v%d I%d" ,gu16AdcRes [ADC_SETPOINT_TORQUE], gu16AdcRes [ADC_SETPOINT_SPEED], gu16AdcRes [ADC_CURRENT]);
|
||||
lcd_string (sBuffer);
|
||||
lcd_string (sBuffer);
|
||||
#else
|
||||
if (gcStopped)
|
||||
{
|
||||
@@ -248,22 +254,25 @@ int main (void)
|
||||
#ifdef TORQUE_DEBUG
|
||||
sprintf (sBuffer, "%s I%dA M%04.2fN", sState, u16CurrentReachedRAW, fReachedTorqueRAW);
|
||||
#else
|
||||
sprintf (sBuffer, "M erreicht);
|
||||
sprintf (sBuffer, "M erreicht");
|
||||
#endif
|
||||
lcd_string (sBuffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
set_cursor (0, 2);
|
||||
if (bTorqueReached)
|
||||
{
|
||||
set_cursor (0, 2);
|
||||
sprintf (sBuffer, "%s M=%03.2fNm ", sState, fReachedTorque);
|
||||
sprintf (sBuffer, "%s I%dA M%04.2fN", sState, u16CurrentReached, fReachedTorque);
|
||||
//sprintf (sBuffer, "%s I%dA M%04.2fN", sState, u16CurrentReached, fReachedTorque);
|
||||
lcd_string (sBuffer);
|
||||
}
|
||||
if (gcStopped)
|
||||
{
|
||||
set_cursor (0, 2);
|
||||
sprintf (sBuffer, "%s ", sState);
|
||||
lcd_string (sBuffer);
|
||||
}
|
||||
else
|
||||
sprintf (sBuffer, "%s M=%04.2f I=%d ", sState, fTorque, u16Current);
|
||||
|
||||
lcd_string (sBuffer);
|
||||
u16LCDTrigger = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user