State Machine: Unterschied zwischen den Versionen
Stella (Diskussion | Beiträge) |
Br (Diskussion | Beiträge) K |
||
(Eine dazwischenliegende Version desselben Benutzers wird nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
+ | The control6/control6.src contains: | ||
<pre> | <pre> | ||
CONTROL_START | CONTROL_START | ||
Zeile 88: | Zeile 89: | ||
CONTROL_END | CONTROL_END | ||
</pre> | </pre> | ||
− | + | The pinning/named_pin/default file should be: | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | The | ||
<pre> | <pre> | ||
− | echo "c6 set state 1" | netcat -q1 | + | PC0 INPUT LOW Key_green |
+ | PC1 INPUT LOW Key_red | ||
+ | PC2 OUTPUT HIGH LED_green | ||
+ | PC3 OUTPUT HIGH LED_red | ||
+ | PC4 OUTPUT HIGH Pulserelais_on | ||
+ | PC5 OUTPUT HIGH Pulserelais_off | ||
+ | </pre> | ||
+ | and "Named pin configuration" must be switched on and use the file "default". | ||
+ | |||
+ | This is a state machine to control a pulse relais with two coils for a coffeemachine. I always had the problem that when I clean the machine in the evening, I have to wait about 10 minutes and then I can switch it off. | ||
+ | |||
+ | With ethersex it works like this: If you press the green button the machine is switched on and the green LED comes up. At the same time the server gets the message "On". If you press the red button it sends a message "Cleaning" to the server and starts to flash the green LED. After about 10 minutes the relais is switched off by the server. If you press the button again while the green led flashes it sends "Off" and switches the relais off. Then the red led comes on. The server can control the circuit by sending a message like this: | ||
+ | <pre> | ||
+ | echo "c6 set state 1" | netcat -q1 coffeemachine 2701 | ||
</pre> | </pre> | ||
To check the status it should send something like: | To check the status it should send something like: | ||
<pre> | <pre> | ||
− | echo "c6 get state" | netcat -q1 | + | echo "c6 get state" | netcat -q1 coffeemachine 2701 |
</pre> | </pre> | ||
− | Is the answer e.g. "state 100" the | + | Is the answer e.g. "state 100" the machine is off. |
The job is done without timers because there was no space left in the device. | The job is done without timers because there was no space left in the device. | ||
− | With TCP, control6, named pins and rfm12 it nearly takes 16K. | + | With TCP, control6, named pins and rfm12 it nearly takes 16K and fits in a Atmega168. |
[[Category:Control6 Examples]] | [[Category:Control6 Examples]] |
Aktuelle Version vom 6. Juni 2010, 15:26 Uhr
The control6/control6.src contains:
CONTROL_START ECMD_GLOBAL(state,255); ECMD_GLOBAL(c,0); PIN_INPUT(Key_green) PIN_INPUT(Key_red) PIN_OUTPUT(LED_green) PIN_OUTPUT(LED_red) PIN_OUTPUT(Pulserelais_on) PIN_OUTPUT(Pulserelais_off) THREAD(states) ON state==0 DO PIN_SET(LED_red); PIN_CLEAR(LED_green); PIN_SET(Pulserelais_off); ESEND(192.168.28.1, "Off\"); state=10; c=0; END ON state==10 DO c=c+1; ON c==20 DO c=0; PIN_CLEAR(Pulserelais_on); PIN_CLEAR(Pulserelais_off); state=100; END END ON state==1 DO PIN_SET(LED_green); PIN_CLEAR(LED_red); PIN_SET(Pulserelais_on); ESEND(192.168.28.1, "On\"); state=11; c=0; END ON state==11 DO c=c+1; ON c==20 DO c=0; PIN_CLEAR(Pulserelais_on); PIN_CLEAR(Pulserelais_off); state=101; END END ON state==2 DO PIN_CLEAR(LED_red); PIN_CLEAR(LED_green); ESEND(192.168.28.1, "Cleaning\"); state=20; END ON state==20 DO c=c+1; ON c==15 DO PIN_SET(LED_green); END ON c==30 DO PIN_CLEAR(LED_green); c=0; END END THREAD_END(states) ON PIN_FALLING(Key_green) DO state=1; END ON PIN_FALLING(Key_red) DO ON state==101 DO state=2; END ON state==20 DO state=0; END END ON STARTUP DO ESEND(192.168.28.1, "Start\"); state=0; THREAD_RESTART(states); END CONTROL_END
The pinning/named_pin/default file should be:
PC0 INPUT LOW Key_green PC1 INPUT LOW Key_red PC2 OUTPUT HIGH LED_green PC3 OUTPUT HIGH LED_red PC4 OUTPUT HIGH Pulserelais_on PC5 OUTPUT HIGH Pulserelais_off
and "Named pin configuration" must be switched on and use the file "default".
This is a state machine to control a pulse relais with two coils for a coffeemachine. I always had the problem that when I clean the machine in the evening, I have to wait about 10 minutes and then I can switch it off.
With ethersex it works like this: If you press the green button the machine is switched on and the green LED comes up. At the same time the server gets the message "On". If you press the red button it sends a message "Cleaning" to the server and starts to flash the green LED. After about 10 minutes the relais is switched off by the server. If you press the button again while the green led flashes it sends "Off" and switches the relais off. Then the red led comes on. The server can control the circuit by sending a message like this:
echo "c6 set state 1" | netcat -q1 coffeemachine 2701
To check the status it should send something like:
echo "c6 get state" | netcat -q1 coffeemachine 2701
Is the answer e.g. "state 100" the machine is off. The job is done without timers because there was no space left in the device. With TCP, control6, named pins and rfm12 it nearly takes 16K and fits in a Atmega168.