Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] washing machine project with pic18f45k22

Status
Not open for further replies.

e-z-max

Newbie level 1
Joined
May 30, 2016
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
33
hello,
First of all I would like to say that my English is not so good ...so sorry :grin:
I would like to get help complete the writing of a washing machine according to the following requirements.

The washing machine works in two modes - normal engine operation (washing) and quick first engine operation (extortion) while the machine is working, the washing machine door must remain locked. In addition, there are several different modes characterized washing machine operation for some time. It is important to design a machine emergency stop button that allows opening the door a minute after the emergency lock.

The code I wrote is:

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/ *
RD0 - Power Button
RD1 - opens tap
RD2 - Flush Valve opens
PWM1 - turning right
PWM2- turning left
RB5 - Ainkodr
* /
int count = 0, sensor = 0;
 
void Interuppt () {
 
if (RB5_bit == 1)
{
**count ++;
*}
*RBIF_bit = 0;
}
 
void main () {
*ADC_Init ();
*UART1_Init (9600);
*Delay_ms (100);
*
*PWM1_Init (5000);
*PWM2_Init (5000);
*PWM1_Set_Duty (0);
*PWM2_Set_Duty (0);
*PWM1_Start ();
*PWM2_Start ();
*
*RBIE_bit = 1; // Allows interrupt change
*IOCB = 0b00100000; // Allows interrupt RB5
*GIE_bit; // Allows a general ruling
*LATA = 0x00;
*LATB = 0x00;
*LATC = 0x00;
*LATD = 0x00;
*TRISD = 0b00000001;
*TRISC = 0b10000000; // PWM, TX, RX
*TRISA = 0xFF; // Analog inputs
*TRISB = 0x00; // Set entrance RB5
*ANSELC = 0x00;
*ANSELD = 0x00;
*ANSELA = 0xFF;
*
*while (1) {
*UART1_Write_Text ( "Press the start button");
*while (RD0_bit = 0); // Waiting here until they click play button
*
**// Step one fills the container
**UART1_Write_Text ( "Filling tank ...");
*while (sensor <614) // As long as less than 60 percent continue to play
**{
***RD1_bit = 1; // Open the tap
***sensor = ADC_Read (0); // Read sensor
***}
***RD1_bit = 0; // Closing tap
***
***// Step two, 50 rounds left
***UART1_Write_Text ( "turns 50 rounds to the right");
***while (count <50) // As long as it's not for turning 50 rounds
*******PWM1_Set_Duty (127);
****PWM1_Set_Duty (0); // Turns off engine
****count = 0; // Reset counter
****
****// Third stage, 30 rounds left
****UART1_Write_Text ( "turns 30 rounds to the left");
****while (count <30) // As long as it's not for turning 30 rounds
*******PWM2_Set_Duty (127);
****PWM2_Set_Duty (0); // Turns off engine
****count = 0; // Reset counter
****
***// Step four, emptying the tank
***UART1_Write_Text ( "Empty tank");
***while (sensor> 0) // As long as there is water in the tank goes empty
***{
***RD2_bit = 1; // Flush Valve opens
***sensor = ADC_Read (0); // Read sensor
***}
***// At this point there is no need to close properly Flush Valve for further squeeze
***
**// Step Five extortion
**UART1_Write_Text ( "Dryering");
***PWM1_Set_Duty (255);
***delay_ms (7000); // Because of that (according to W. If)! Is a substance, this does not affect him
***PWM1_Set_Duty (0); // Turns off engine
***RD2_bit = 0; // Flush Valve Closing
***
****UART1_Write_Text ( "Washing finished !!");
 
}}



in what line I need to put the emergency stop button that allows opening the door a minute after the emergency lock as soon as There is a problem?
Thanks for the help.
 
Last edited by a moderator:

Your code seems as not implementing a state machine.
In addition, you are placing a long delay of 7seconds at the main loop.
Sorry to say that, but you'll need to rewrite it, prefereably using 'switch...case' statements.

PS.:
The addition of "*" characters before each line turns the code unreadable.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top