summaryrefslogtreecommitdiff
path: root/error_utils.c
diff options
context:
space:
mode:
authorMike <mjc@avtechpulse.com>2000-01-01 01:39:54 +0900
committerMike <mjc@avtechpulse.com>2000-01-01 01:39:54 +0900
commit908dbc71beebb1bb9ebcb3bb8945043b3ee5e800 (patch)
tree7907b7e2a2c5a00c4479d2fc117aa905dfef9b7f /error_utils.c
parente61288ff7f0a705ce9c7f60b33429f92f3bfb573 (diff)
added hvps_avg_curr_limit for AVR-8F-B
Diffstat (limited to 'error_utils.c')
-rw-r--r--error_utils.c93
1 files changed, 77 insertions, 16 deletions
diff --git a/error_utils.c b/error_utils.c
index cc056c8..54073d5 100644
--- a/error_utils.c
+++ b/error_utils.c
@@ -334,6 +334,10 @@ void get_error_text(gchar **response, int error_num)
format_error_text(response,-222,"PW exceeds RC limit.");
break;
+ case HVPS_Current_Too_High:
+ format_error_text(response,-222,"HVPS current too high.");
+ break;
+
case max_rise_time_error:
format_error_text(response,-222,"Rise time too high.");
break;
@@ -613,7 +617,7 @@ void get_error_text(gchar **response, int error_num)
break;
case zero_equiv_ampl_negative:
- format_error_text(response,-200,"Ampl zero equivalent can't be negative.");
+ format_error_text(response,-200,"This constant can't be negative.");
break;
default:
@@ -775,17 +779,16 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels])
report_error = zero_equiv_ampl_too_large;
}
- if (globals.Flash.ampl_zero_equiv[i] < 0.0) {
- report_error = zero_equiv_ampl_negative;
- }
-
if (fabs(globals.Flash.os_zero_equiv[i] > 2000.0)) {
report_error = zero_equiv_ampl_too_large;
}
- if (globals.Flash.os_zero_equiv[i] < 0.0) {
- report_error = zero_equiv_ampl_negative;
- }
+ if ( (globals.Flash.ampl_zero_equiv[i] < 0.0) ||
+ (globals.Flash.os_zero_equiv[i] < 0.0) ||
+ (globals.Flash.hvps_avg_curr_limit[i] < 0.0) ||
+ (globals.Flash.max_avg_power[i] < 0.0) ) {
+ report_error = zero_equiv_ampl_negative;
+ }
/* calculate maximum duty cycle based on amplitude and load, for later use */
@@ -925,6 +928,17 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels])
}
}
+ if ((globals.Flash.hvps_avg_curr_limit[i] > 0.0) && (fabs(ChannelStateToTest[i].amplitude) > 0.0) && (ChannelStateToTest[i].pw > 0.0)) {
+ temp=(100.0 / duty_scale) * globals.Flash.hvps_avg_curr_limit[i] * ChannelStateToTest[i].load_type /
+ (fabs(ChannelStateToTest[i].amplitude) * ChannelStateToTest[i].pw);
+ if (temp<globals.Constraints.err_max_freq[i]) {
+ globals.Constraints.err_max_freq[i]=temp;
+ if (ChannelStateToTest[i].frequency>(1.001*globals.Constraints.err_max_freq[i])) {
+ report_error=HVPS_Current_Too_High;
+ }
+ }
+ }
+
if (globals.Flash.max_avg_power[i] > 0.0) {
temp = (globals.Flash.max_avg_power[i] * ChannelStateToTest[i].load_type) / (ChannelStateToTest[i].amplitude * ChannelStateToTest[i].amplitude * ChannelStateToTest[i].pw);
if (temp < globals.Constraints.err_max_freq[i]) {
@@ -1036,6 +1050,18 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels])
}
}
+ if ((globals.Flash.hvps_avg_curr_limit[i] > 0.0) && (fabs(ChannelStateToTest[i].amplitude) > 0.0) && (ChannelStateToTest[i].frequency > 0.0)) {
+ temp=(100.0 / duty_scale) * globals.Flash.hvps_avg_curr_limit[i] * ChannelStateToTest[i].load_type /
+ (fabs(ChannelStateToTest[i].amplitude) * ChannelStateToTest[i].frequency);
+ if (temp<globals.Constraints.err_max_pw[i]) {
+ globals.Constraints.err_max_pw[i]=temp;
+ if (ChannelStateToTest[i].pw>(1.001*globals.Constraints.err_max_pw[i])) {
+ report_error=HVPS_Current_Too_High;
+ }
+ }
+ }
+
+
if (globals.Flash.max_avg_power[i] > 0.0) {
temp = globals.Flash.max_avg_power[i] * ChannelStateToTest[i].load_type / (ChannelStateToTest[i].amplitude * ChannelStateToTest[i].amplitude * ChannelStateToTest[i].frequency);
if (temp < globals.Constraints.err_max_pw[i]) {
@@ -1217,15 +1243,21 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels])
}
if (ChannelStateToTest[i].trigger_source==source_internal) {
- temp = sqrt(globals.Flash.max_avg_power[i] * ChannelStateToTest[i].load_type / (ChannelStateToTest[i].pw * ChannelStateToTest[i].frequency));
- if ((temp > 0.0) && (temp < globals.Constraints.err_max_ampl[i])) {
- globals.Constraints.err_max_ampl[i] = temp;
- if (-temp > globals.Constraints.err_min_ampl[i]) {
- globals.Constraints.err_min_ampl[i] = -temp;
+ if (globals.Flash.max_avg_power[i] > 0.0) {
+ temp = sqrt(globals.Flash.max_avg_power[i] * ChannelStateToTest[i].load_type / (ChannelStateToTest[i].pw * ChannelStateToTest[i].frequency));
+ // temp is positive at this point
+ if (temp < globals.Constraints.err_max_ampl[i]) {
+ globals.Constraints.err_max_ampl[i]=temp;
+ if (ChannelStateToTest[i].amplitude>(1.001*globals.Constraints.err_max_ampl[i])) {
+ report_error=average_power_limit;
+ }
}
-
- if ((1.001*globals.Constraints.err_max_ampl[i]) < fabs(ChannelStateToTest[i].amplitude)) {
- report_error=average_power_limit;
+ temp = temp * -1.0; // check negative possibility
+ if (temp > globals.Constraints.err_min_ampl[i]) {
+ globals.Constraints.err_min_ampl[i]=temp;
+ if (ChannelStateToTest[i].amplitude<(1.001*globals.Constraints.err_min_ampl[i])) {
+ report_error=average_power_limit;
+ }
}
}
}
@@ -1252,6 +1284,25 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels])
}
}
+ if ((globals.Flash.hvps_avg_curr_limit[i] > 0.0) && (fabs(ChannelStateToTest[i].frequency) > 0.0) && (ChannelStateToTest[i].pw > 0.0)) {
+ temp=(100.0 / duty_scale) * globals.Flash.hvps_avg_curr_limit[i] * ChannelStateToTest[i].load_type /
+ (ChannelStateToTest[i].frequency * ChannelStateToTest[i].pw);
+ // temp is positive at this point
+ if (temp < globals.Constraints.err_max_ampl[i]) {
+ globals.Constraints.err_max_ampl[i]=temp;
+ if (ChannelStateToTest[i].amplitude>(1.001*globals.Constraints.err_max_ampl[i])) {
+ report_error=HVPS_Current_Too_High;
+ }
+ }
+ temp = temp * -1.0; // check negative possibility
+ if (temp > globals.Constraints.err_min_ampl[i]) {
+ globals.Constraints.err_min_ampl[i]=temp;
+ if (ChannelStateToTest[i].amplitude<(1.001*globals.Constraints.err_min_ampl[i])) {
+ report_error=HVPS_Current_Too_High;
+ }
+ }
+ }
+
duty_cycle=ChannelStateToTest[i].pw*ChannelStateToTest[i].frequency*100; /* calculate duty cycle */
if (duty_cycle>(100.0*ampl_fixed_max_duty/duty_scale))
/* set at crossover voltage */
@@ -1530,6 +1581,16 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels])
}
}
+ if (globals.Flash.hvps_avg_curr_limit[i] > 0.0) {
+ temp= (duty_scale / 100.0) * fabs(ChannelStateToTest[i].amplitude) * ChannelStateToTest[i].pw * ChannelStateToTest[i].frequency / globals.Flash.hvps_avg_curr_limit[i];
+ if (temp > globals.Constraints.err_min_load_type[i]) {
+ globals.Constraints.err_min_load_type[i]=temp;
+ if (ChannelStateToTest[i].load_type<(0.999*globals.Constraints.err_min_load_type[i])) {
+ report_error=HVPS_Current_Too_High;
+ }
+ }
+ }
+
if (globals.Flash.max_peak_power[i] > 0.0) {
temp = ChannelStateToTest[i].amplitude * ChannelStateToTest[i].amplitude / globals.Flash.max_peak_power[i];
if (temp > globals.Constraints.err_min_load_type[i]) {