洗浄ポンププログラムコード
/**
Generated Main Source File
Company:
Microchip Technology Inc.
File Name:
main.c
Summary:
This is the main file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUs
Description:
This header file provides implementations for driver APIs for all modules selected in the GUI.
Generation Information :
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
Device : PIC16F18857
Driver Version : 2.00
*/
#include "mcc_generated_files/mcc.h"
// RA2:red_sw
// RA3:black_sw
// RA4:white_sw
// RA5:spare_pump(pump1_RC5_Link)
// RC0:spare_pump(pump_sw1_RA5_Link)
// RC1:H2O_pump
// RC2:KCl_pump
// RC3:Output_pump
void KCA_input_1s();
void H2O_input_1s();
void liquid_output_1s();
void Washing();
void main(void)
{
// initialize the device
SYSTEM_Initialize();
//setup_start
PORTA= 0b00111100;//pump_stand-by_condition
PORTC= 0b00001111;//switch_initial state_condition
PORTB= 0b00010000;//busy_LED__condition
__delay_ms(1000);
PORTB= 0b00100000;//stand-by_LED__condition
//setup_end
while (1)
{
PORTB= 0b00100000;//stand-by_LED__condition
PORTC= 0b00001111;
__delay_us(100);
if(RA5==0){
PORTC= 0b00001110;
__delay_ms(1000);
PORTC= 0b00001111;
continue;// ????????
}
//Pure water is injected while the white switch is pressed.
// RA4:white_sw
if(RA4==0){
PORTB= 0b00010000;//busy_LED__condition
// PORTC= 0b00001101;
// __delay_ms(1000);
// PORTC= 0b00001111;
H2O_input_1s();
continue;
}
if(RA3==0){
PORTB= 0b00010000;//busy_LED__condition
// PORTC= 0b00001011;
// __delay_ms(1000);
// PORTC= 0b00001111;
Washing();
continue;
}
//While the red switch is pressed, the liquid will be drained.
//RA2:red_sw
if(RA2==0){
PORTB= 0b00010000;//busy_LED__condition
// PORTC= 0b00000111;
// __delay_ms(1000);
// PORTC= 0b00001111;
liquid_output_1s();
continue;
}
}
}
void Washing(){
int i;
i=1;
while (i < 6){
liquid_output_1s();
i++;
}
i=1;
while (i < 5){
H2O_input_1s();
i++;
}
i=1;
while (i < 5){
liquid_output_1s();
i++;
}
i=1;
while (i < 4){
KCA_input_1s();
i++;
}
i=1;
while (i < 5){
liquid_output_1s();
i++;
}
}
void KCA_input_1s(){
PORTC= 0b00001011;
__delay_ms(730);
PORTC= 0b00001111;
}
void H2O_input_1s(){
PORTC= 0b00001101;
__delay_ms(730);
PORTC= 0b00001111;
}
void liquid_output_1s(){
PORTC= 0b00000111;
__delay_ms(730);
PORTC= 0b00001111;
}
/**
End of File
*/
コメント
コメントを投稿