source: firmware/FSC/src/output.c@ 10669

Last change on this file since 10669 was 10667, checked in by neise, 14 years ago
File size: 4.1 KB
Line 
1#include "output.h"
2#include "usart.h"
3#include "application.h"
4
5void print_status() {
6 usart_write_str((pU08)"adc status:\n");
7 for (U08 i=0; i< V_BITMAP + I_BITMAP + H_BITMAP;++i) {
8 usart_write_U08_bin(adc_enables[i]);
9 usart_write_char(' ');
10 }
11 usart_write_char('\n');
12 for (U08 i=0; i< V_BITMAP + I_BITMAP + H_BITMAP;++i){
13 usart_write_U08_bin(adc_channels_ready[i]);
14 usart_write_char(' ');
15 }
16 usart_write_char('\n');
17
18 usart_write_str((pU08)"ad7719 status:\n");
19 for (U08 i=0; i< CHANNEL_BITMAP;++i) {
20 usart_write_U08_bin(ad7719_enables[i]);
21 usart_write_char(' ');
22 }
23 usart_write_char('\n');
24 for (U08 i=0; i< CHANNEL_BITMAP;++i){
25 usart_write_U08_bin(ad7719_channels_ready[i]);
26 usart_write_char(' ');
27 }
28 usart_write_char('\n');
29
30 usart_write_str((pU08)"time:");
31 usart_write_float((float)local_ms/1000 , 1,7);
32 usart_write_str((pU08)" sec.\n");
33
34 usart_write_str((pU08)"adc measured all: ");
35 if (adc_measured_all)
36 usart_write_str((pU08)" true\n");
37 else
38 usart_write_str((pU08)"false\n");
39
40 usart_write_str((pU08)"ad7719 measured all: ");
41 if (ad7719_measured_all)
42 usart_write_str((pU08)" true\n");
43 else
44 usart_write_str((pU08)"false\n");
45
46 usart_write_str((pU08)"adc current channel:");
47 usart_write_U08(adc_current_channel,2);
48 usart_write_char('\n');
49
50 usart_write_str((pU08)"ad7719 current channel:");
51 usart_write_U08(ad7719_current_channel,2);
52 usart_write_char('\n');
53
54}
55void print_adc_nicely() {
56 usart_write_str((pU08)"\n printing voltages in mV:\n");
57 // output: U08 adc_values[V_CHANNELS + I_CHANNELS + H_CHANNELS];
58 for (U08 i=0; i< V_CHANNELS + I_CHANNELS + H_CHANNELS;++i) {
59 if (i%8 == 0) usart_write_char('\n');
60 adc_output(i, adc_values[i]);
61 usart_write_str((pU08)" ");
62 }
63 usart_write_char('\n');
64}
65
66
67void print_ad7719_nicely()
68{
69 float value;
70
71 usart_write_str((pU08)"\n printing measured resistance in kohms:\n");
72
73 for (U08 i=0; i< TEMP_CHANNELS;++i) {
74 if (i%8 == 0) usart_write_char('\n');
75
76 // print channel name:
77 usart_write_str((pU08)"R:"); //R for resistance
78 usart_write_char('A'+i/8); // Letters A,B,C,D,E,F,G,H
79 //usart_write_char(' ');
80 usart_write_U08(i%8+1,1); // Numbers 1...8
81 usart_write_char(':');
82
83 // check if this channel is enabled in the bitmap
84 if (ad7719_enables[i/8] & (1<<i%8))
85 {
86 value = (6.25 * 1.024 * ad7719_values[i]) / ((U32)1 << 25);
87 usart_write_float(value, 3,6);
88 //usart_write_U32(ad7719_values[i],8);
89 //usart_write_U32_hex(data); //data
90 usart_write_str((pU08)" ");
91 } else {
92 usart_write_str((pU08)" ");
93 }
94 //usart_write_char('\n');
95 }
96}
97
98void ad7719_output(U08 channel, U32 data) {
99float value = 0;
100 usart_write_str((pU08)"R:"); //R for resistance
101 usart_write_char('A'+channel/8); // Letters A,B,C,D,E,F,G,H
102 //usart_write_char(' ');
103 usart_write_U08(channel%8+1,1); // Numbers 1...8
104 usart_write_char(':');
105
106
107 value = (6.25 * data) / ((U32)1 << 25);
108 usart_write_float(value, 3,6);
109 //usart_write_U32_hex(data); //data
110
111
112}
113
114void adc_output(U08 channel, U08 data) {
115
116// if (channel < 40)
117// usart_write_str((pU08)"V:");
118// else if (channel < 80)
119// usart_write_str((pU08)"I:");
120// else if (channel < 84)
121// usart_write_str((pU08)"H:");
122
123 if (channel <80)
124 {
125 switch ((channel%40)/4) {
126 case 0:
127 case 1:
128 usart_write_char('A');
129 break;
130 case 2:
131 case 3:
132 usart_write_char('B');
133 break;
134 case 4:
135 case 5:
136 usart_write_char('C');
137 break;
138 case 6:
139 case 7:
140 usart_write_char('D');
141 break;
142 case 8:
143 usart_write_char('E');
144 break;
145 case 9:
146 usart_write_char('F');
147 break;
148 default:
149 usart_write_char('?');
150 break;
151 }
152 }
153 else // channel 80..83
154 {
155 usart_write_char('H');
156 }
157 //usart_write_char(' ');
158
159 if ( (channel%40)/4 == 9)
160 usart_write_U08((channel)%4+1,1); // Numbers 1...4
161 else
162 usart_write_U08((channel)%8+1,1); // Numbers 1...8
163
164
165 //usart_write_U08(channel,2); // Numbers 1...8
166 usart_write_char(':');
167 usart_write_U16((U16)data*16, 4); //data
168}
169
170
171void adc_output_all() {
172 print_adc_nicely();
173 print_ad7719_nicely();
174}
Note: See TracBrowser for help on using the repository browser.