Last change
on this file since 15715 was 10244, checked in by neise, 14 years ago |
debugged resistance calculation for AD7719
|
File size:
1.5 KB
|
Line | |
---|
1 | #include "muxer_fsc.h"
|
---|
2 |
|
---|
3 | // Sets voltage Muxer to current channel
|
---|
4 | // this is a Muxing, and therefor the adc might need some time to settle.
|
---|
5 | // Since there are:
|
---|
6 | // - 40 voltage monitor channels
|
---|
7 | // - 40 current monitor channels
|
---|
8 | // - 4 humidity monitor channels
|
---|
9 | // the muxer is set as follows.
|
---|
10 | // channel 00..39 --> looking at the voltage channels
|
---|
11 | // channel 40..79 --> looking at the current channels
|
---|
12 | // channel 80..83 --> looking at the humidities
|
---|
13 | void Set_V_Muxer (U08 channel){
|
---|
14 | U08 SB = 0;
|
---|
15 | // voltages
|
---|
16 | if (channel < 40) {
|
---|
17 | if (channel < 36)
|
---|
18 | SB = channel*2;
|
---|
19 | else
|
---|
20 | SB = (channel+1)*2;
|
---|
21 | }
|
---|
22 | // currents
|
---|
23 | else if (channel < 80) {
|
---|
24 | channel -= 40;
|
---|
25 | if (channel < 36)
|
---|
26 | SB = channel*2+1;
|
---|
27 | else
|
---|
28 | SB = (channel+1)*2+1;
|
---|
29 | }
|
---|
30 | // humidities
|
---|
31 | else if (channel < 84) {
|
---|
32 | channel -= 80;
|
---|
33 | switch (channel) {
|
---|
34 | case 0:
|
---|
35 | SB = 0x48; //0100.1000
|
---|
36 | break;
|
---|
37 | case 1:
|
---|
38 | SB = 0x49; //0100.1001
|
---|
39 | break;
|
---|
40 | case 2:
|
---|
41 | SB = 0x58; //0101.0010
|
---|
42 | break;
|
---|
43 | case 3:
|
---|
44 | SB = 0x58; //0101.0011
|
---|
45 | break;
|
---|
46 | } // end of switch-case
|
---|
47 | } // end of if (channel < some_number)
|
---|
48 |
|
---|
49 | PORTC = (PORTC & 0x80) | (0x7F & SB); // Here the muxer is switched.
|
---|
50 | }
|
---|
51 |
|
---|
52 | void Set_T_Muxer(U08 channel) {
|
---|
53 | U08 SA = 0x00;
|
---|
54 |
|
---|
55 | switch (channel/16) {
|
---|
56 | case 0:
|
---|
57 | SA |= 1<<4; // 0001.0000
|
---|
58 | break;
|
---|
59 | case 1:
|
---|
60 | break; // 0000.0000
|
---|
61 | case 2:
|
---|
62 | SA |= (1<<4)|(1<<5); // 0011.0000
|
---|
63 | break;
|
---|
64 | case 3:
|
---|
65 | SA |= 1<<5; // 0010.0000
|
---|
66 | break;
|
---|
67 | }
|
---|
68 |
|
---|
69 | SA = SA | (channel%16);
|
---|
70 |
|
---|
71 | PORTA = (PORTA & 0xC0) | (0x3F & SA); // Here the muxer is switched.
|
---|
72 | }
|
---|
73 |
|
---|
74 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.