void intkheat_control(struct ecudata_t *d) { if (!d->param.tmp_use) { IOCFG_INIT(IOP_INTK_HEAT, 0); return; } switch(ih.state) { case 0: //turn on heating and start timer IOCFG_SET(IOP_INTK_HEAT, (d->sens.temperat < TEMPERATURE_MAGNITUDE(HEATING_T_OFF))); // control heating ih.strt_t1 = s_timer_gtc(); ih.state = 1; break; case 1: //wait 10 minutes and turn off heating or it will be turned off immediatelly if crankshaft begin to revolve if (((s_timer_gtc() - ih.strt_t1) >= HEATING_TIME) || ckps_is_cog_changed()) { IOCFG_SET(IOP_INTK_HEAT, 0); // turn off heating ih.state = 2; } break; case 2: //control heating if engine is running, otherwise turn it off if (d->st_block) { //engine is running IOCFG_SET(IOP_INTK_HEAT, (d->sens.temperat < TEMPERATURE_MAGNITUDE(HEATING_T_OFF))); // control heating } else IOCFG_SET(IOP_INTK_HEAT, 0); break; } }
void pwrrelay_control(struct ecudata_t* d) { //if this feature is disabled, then do nothing if (!IOCFG_CHECK(IOP_PWRRELAY)) return; //apply power management logic if (pwrs.pwrdown) { //ignition is off //We will wait while temperature is high only if temperature sensor is enabled //and control of electric cooling fan is used. uint8_t temperature_ok = 1; if (d->param.tmp_use && IOCFG_CHECK(IOP_ECF)) { #ifdef COOLINGFAN_PWM if (d->param.vent_pwm) //PWM is available and enabled temperature_ok = (d->sens.temperat <= (d->param.vent_on - TEMPERATURE_MAGNITUDE(2.0))); else //PWM is available, but disabled temperature_ok = (d->sens.temperat <= (d->param.vent_off)); #else //PWM is not available temperature_ok = (d->sens.temperat <= (d->param.vent_off)); #endif //set timeout if (0==pwrs.state) { pwrs.state = 1; s_timer16_set(powerdown_timeout_counter, 6000); //60 sec. } } if ((temperature_ok && eeprom_is_idle() #ifdef SM_CONTROL && choke_is_ready() #endif ) || s_timer16_is_action(powerdown_timeout_counter)) IOCFG_SET(IOP_PWRRELAY, 0); //turn off relay } else pwrs.state = 0; //if IGN input is not available, then we will check board voltage pwrs.pwrdown = IOCFG_CHECK(IOP_IGN) ? (!IOCFG_GET(IOP_IGN)) : (d->sens.voltage < VOLTAGE_MAGNITUDE(4.5)); }
void stpmot_dir(uint8_t dir) { //Speaking about L297, CW/~CCW input synchronized internally therefore //direction can be changed at any time IOCFG_SET(IOP_SM_DIR, dir); }