Esempio n. 1
0
//==================================================================================
//==================================================================================
//==================================================================================
void read_Kn(void)
{
	static uint16_t	tmp_reg=0;
	uint16_t Reg2=0;
		
	if(!PORT_ReadInputDataBit(MDR_PORTD,PORT_Pin_0))
		Reg2|=(1<<0);
	
	if(!PORT_ReadInputDataBit(MDR_PORTD,PORT_Pin_1))
		Reg2|=(1<<1);
	
	if(!PORT_ReadInputDataBit(MDR_PORTD,PORT_Pin_2))
		Reg2|=(1<<2);
	
	if(!PORT_ReadInputDataBit(MDR_PORTD,PORT_Pin_3))
		Reg2|=(1<<3);
	
	if(!PORT_ReadInputDataBit(MDR_PORTD,PORT_Pin_4))
		Reg2|=(1<<4);
	
	if(!PORT_ReadInputDataBit(MDR_PORTD,PORT_Pin_5))
		Reg2|=(1<<5);
	
	if(!PORT_ReadInputDataBit(MDR_PORTD,PORT_Pin_6))
		Reg2|=(1<<6);
	
	if(!PORT_ReadInputDataBit(MDR_PORTD,PORT_Pin_7))
		Reg2|=(1<<7);
	
	if(!PORT_ReadInputDataBit(MDR_PORTB,PORT_Pin_5))
		Reg2|=(uint16_t)(1<<8);
	
	if(!PORT_ReadInputDataBit(MDR_PORTE,PORT_Pin_6))
		Reg2|=(uint16_t)(1<<9);
	
	if(tmp_reg==Reg2)
	{
		PKDU.StatusKN=tmp_reg;
	}
	else
		tmp_reg=Reg2;
}
Esempio n. 2
0
void computeContent(void)
{
	if(cntTimeCode == (STORE_SIZE - 1)){
		cntTimeCode = 0;
		
		if(refreshRawData){
			for(i = 0; i < STORE_SIZE; ++i){
				rawStoreTimeCode[i] = storeTimeCode[i];
			}
			refreshRawData=0;
		}
		
		/*Par.timeCodA = my_filter(storeTimeCode, STORE_SIZE, 10);*/
		
		timeCode = my_filter(storeTimeCode, STORE_SIZE, 10);
		
		deadTime = (double) Par.deadTime / 100000000; //0.01 uS   2400 = 24 us
		
		timePropagation = (double)timeCode * IMPULSE_ZAP; 
		
		speedCurrent = Par.acusticBase / ((timePropagation - deadTime) * 1000) ;	// *1000 because BASE mm
		
		/*Par.speedCurrent = speedCurrent;*/
		speedResin = (double)Par.speedResin;
		if (speedCurrent < speedBase){
			resinContent = calc_sod(speedCurrent,speedBase,speedResin);
		}
		else{
			resinContent = 0;
		}
		if(beginInitialisation == true){
			speedBase = speedCurrent;
			/*Par.timeCod = Par.timeCodA;*/
			/*Par.speedDry = speedBase;*/
			save_parametrs(PARAMETRS_ADDR,Par.BUF);  	//Сохранение параметров
			beginInitialisation = 0;
		}

    if (PORT_ReadInputDataBit(MD2_PORT, MD2_PIN_F) == Bit_SET){
      if( resinContent != 0)
        Par.resinContent = resinContent;
    }
    else{
      Par.resinContent = resinContent;
    }
    dac_out = Par.resinContent * 37.52; //0x0EA8 = 100 % (3752)		
  }
}