2 |
kaklik |
1 |
/* Program pro ovladani slunecniho robota */
|
|
|
2 |
/* (chodi se zapojenim Dark Walker rev.3 */
|
|
|
3 |
/* $Header: /programy/PIC_C/roboti/solarni/dalsi_verze/main.c 1 19.09.05 20:39 Jakub $ */
|
|
|
4 |
|
|
|
5 |
#include "D:\@Kaklik\programy\PIC_C\robot\solarni_robot\dalsi_verze\main.h"
|
|
|
6 |
|
|
|
7 |
#define LED PIN_B3 // LED
|
|
|
8 |
#define ON_TIME 75 // Cas sepnuti rele
|
|
|
9 |
#define meridlo PIN_B2 // Napetovy supervisor
|
|
|
10 |
#define RESET PIN_B0 // Pridrzeni RESETu
|
|
|
11 |
|
|
|
12 |
void rele1() // Sepnuti prvniho rele
|
|
|
13 |
{
|
|
|
14 |
output_low(PIN_A1);
|
|
|
15 |
output_low(PIN_B4);
|
|
|
16 |
delay_ms(ON_TIME);
|
|
|
17 |
output_high(PIN_A1);
|
|
|
18 |
output_high(PIN_B4);
|
|
|
19 |
}
|
|
|
20 |
|
|
|
21 |
void motor() // Sepnuti motoru
|
|
|
22 |
{
|
|
|
23 |
output_low(pin_A2);
|
|
|
24 |
output_low(pin_B1);
|
|
|
25 |
output_low(PIN_A4);
|
|
|
26 |
delay_ms(ON_TIME);
|
|
|
27 |
output_high(pin_A2);
|
|
|
28 |
output_high(pin_B1);
|
|
|
29 |
output_high(PIN_A4);
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
void main()
|
|
|
34 |
{
|
|
|
35 |
|
|
|
36 |
setup_counters(RTCC_INTERNAL,WDT_18MS);
|
|
|
37 |
|
|
|
38 |
output_high(RESET); // vypnuti resetu od supervizoru
|
|
|
39 |
|
|
|
40 |
port_b_pullups (true); // zapnuti pullapu ,aby se poznal sepnuty
|
|
|
41 |
// nebo rozepnuty kontakt
|
|
|
42 |
|
|
|
43 |
output_high(LED); //
|
|
|
44 |
delay_ms(ON_TIME); // bliknuti LED
|
|
|
45 |
output_low(LED); //
|
|
|
46 |
|
|
|
47 |
if (!input(pin_B5)) // zmereni spravneho sepnuti rele1 (spatne kdyz
|
|
|
48 |
{ // sepnuto)
|
|
|
49 |
port_b_pullups (false); // vypnuti pullapu
|
|
|
50 |
goto chyba; // kdyz je uz sepnuto nemusi se znova spinat
|
|
|
51 |
// ani cekat na nabiti kondenzatoru
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
port_b_pullups (false); // vypnuti pullapu za spravneho prubehu
|
|
|
55 |
rele1(); // sepnuti rele1
|
|
|
56 |
|
|
|
57 |
delay_ms(28000); // cekani na nabiti kondenzatoru (casovy limit
|
|
|
58 |
// pred rozjetim je 30 vterin 2 vteriny jsou
|
|
|
59 |
// rezerva na nabiti kondenzatoru pro PIC)
|
|
|
60 |
|
|
|
61 |
chyba:
|
|
|
62 |
motor(); // zapnuti motoru
|
|
|
63 |
output_low(RESET); // zapnuti resetu od supervisoru
|
|
|
64 |
}
|