summaryrefslogtreecommitdiff
path: root/pcr-controller/protocol_uc.txt
blob: 63264544da0c0166e5ec7a6b739e9614a823651c (plain) (blame)
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
==== Command bytes ====
's'		Temperatursensor lesen -> parse_float(string("%3.2f")) + \r\n
't'		Same as above
'T'		Set PID target temperature.  <-TempValue
		(Only works if no temperature curve is set.)
'P'		Set PID value P  <-PIDValue
'I'		Set PID value I  <-PIDValue
'D'		Set PID value D  <-PIDValue
'p'		Print all PID values as JSON string
'i'		Same as above
'd'		Same as above
'A'		Switch on pump.
'a'		Switch pump off.
'@'		Switch pump on automatically if temp goes higher than 30°C or lower than 19°C
'B'		Set top heater PWM to value between 0 and 255 (in future pwm value may be fixed and 'B' may return to simple on switch)  <-IntValue
'b'		Switch top heater off.
'L'		Toggle LED (Debug)
'l'		Toggle LED by using queuing system (Debug)
'R'		Reset microcontroller
'r'		Same as above
'='		Set PID target temperature to current temperature.
'-'		Clear temperature curve.
'.'		Print out currently programmed temperature curve as JSON string.
'+'		Add a temperature curve point.  <-TempValue <-Duration
		Excpects 2 arguments: Targettemperature and duration for which that temperature is to be held after it has been reached.
'>'		Set the last added (with '+') temperature curve point to be the cycle start point.
        E.g. if >0 curve repetitions are set (with 'Z') the repetitions will start here, instead of at the first added curve point.
'<'		Set the last added (with '+') temperature curve point to be the cycle end point.
        E.g. this and any temperature points added after this marker will not be repeated, but programmed after the main loop
'Z'		Set number of cycle repetitions  <-IntValue
		E.g:	0 == default == no repetitions == 1 cycle
				1 == 1 repetitions == 2 cycles)
				....
'M'		Enable periodic status output as JSON string.
'm'		Disable periodic status output as JSON string.
'?'		Toggle Debug Output.
'#'     Disable PID (i.e. set PID target temperature to -2048.00)
		(Only works if no temperature curve is set. If needed use '-' first.)


==== Command arguments ====
If arguments are required they are to be given as numeric string.

Temperature is given in degrees celcsius multiplied by 16, thus allowing us to set decimal degrees by storing and transmitting integer values.
Negative temperatures are prepended by '-'.
E.g. a temperature of -20 °C would be input as -320.

PID parpameters are multiplied by 1024 (or whatever PID_SCALE is set to).
E.g. an I value of 0.5 would be input as 512.

Duration or time values are input as 100ms (1/10th second) integer values.
E.g. a duration of 2 seconds would be input as 20.

If multiple arguments are required, they are to be separated by the comma character ','.

<-IntValue	...means: string(uint16_t x)
<-TempValue ...means: string(int16_t(float temp * 16))
<-PIDValue  ...means: string(uint16_t x * 1024)
<-Duration  ...means: string(uint16_t s * 10)


==== Command responses ====
are formated as JSON values.
PID Values are output just like they are expected to be input.
Temperatures are output as formated float values in °C, expect when printing the current temperature curve when temperatures are printed as internal integer values (see TempValue)

A value of -2048.00 or -32768 generally means something is DISABLED or inapplicable in the current state.


==== Example uc Answers ====
Responses to "s":
{"cmd":"s","t":503, "currtemp":20.34, "targettemp":-2048.00, "curve":false, "curve_t_elapsed":0, "cycles_left":0}  //curve and pid disabled  (pid disabel when targettemp == -2048.00
{"cmd":"s","t":97000, "currtemp":40.34, "targettemp":70.00, "curve":true, "curve_t_elapsed":14, "cycles_left":11}
{"cmd":"s","t":97200, "currtemp":69.72, "targettemp":70.00, "curve":true, "curve_t_elapsed":214, "cycles_left":11}
{"cmd":"s","t":110123, "currtemp":30.14, "targettemp":30.00, "curve":true, "curve_t_elapsed":10, "cycles_left":9}
{"cmd":"s","t":9999999, "currtemp":5.02, "targettemp":5.00, "curve":true, "curve_t_elapsed":65535, "cycles_left":0}   //we know all is finished because targettemp is hold-temp

Response to "."
{"cmd":".","curve":[{"temp":1520,"duration":9000,"is_curr":1,"is_loop_start":0,"is_loop_end":0},{"temp":1040,"duration":10,"is_curr":0,"is_loop_start":1,"is_loop_end":0},{"temp":960,"duration":300,"is_curr":0,"is_loop_start":0,"is_loop_end":0},{"temp":1120,"duration":300,"is_curr":0,"is_loop_start":0,"is_loop_end":0},{"temp":1120,"duration":1000,"is_curr":0,"is_loop_start":0,"is_loop_end":1},0],"end_temp":80,"loop_repeats":30}

Response to other commands:
{"cmd":"s","cmd_ok":false,"error": "No DS1820 sensors on 1wire bus, thus no temperature"}
{"cmd":"s","cmd_ok":false,"error":"talking to DS18b20, no valid temperature!"}
{"cmd":"A","cmd_ok":true}
{"cmd":"a","cmd_ok":true}
{"cmd":"#","cmd_ok":true}


==== Example Program ====
s
-
=
@
b
+1536,300
>
+448,300
+1152,300
<
Z30
+64,9999
M

The sequence of above commands
- prints current temperature
- deletes any currenlty set temperature curve
- instructs the PID controller to hold the current temperature
- set the pump to auto
- switch off top heater
- programms the following temperature curve: [ 96°C (30s) ->  28°C (30s) -> 72°C (30s) ]
- sets the curve to repeat the items in >< brackets 30 times
- programms final holding temperature of 4°C (note that duration of last entry does not really matter since it will always be held indefinately).
- activates periodic status output.


(c) Bernhard Tittelbach, 2013