Nein read_adc() ist keine selbst geschriebene Funktion.
Jetzt habe ich einen Zahlenbereich von 0-1023, dass passt (10bit).
Aber ich habe noch immer das Problem, dass das Poti nicht linear ist
(ist aber nicht kaputt -> es muss ein Programmfehler bzw
Konfigurationsfehler sein).
Wie man beim Bild, das ich hinzugefügt habe sieht man wie sich das Poti
ungefähr verhält.
Hier ist der aktuelle Code.
1 | #include <33FJ256MC710A.h>
|
2 | #device ADC=10
|
3 | #include <stdio.h>
|
4 | #include <stdlib.h>
|
5 | #fuses XT,NOWDT
|
6 | #use delay(clock=8000000)
|
7 |
|
8 | void main()
|
9 | {
|
10 | int16 x;
|
11 |
|
12 | set_tris_e(0); //PORT E Ausgang
|
13 | set_tris_b(1); //PORT B Eingang
|
14 |
|
15 | setup_adc_ports(sAN8); //PIN32 wird ein analog PIN
|
16 | set_adc_channel(8); //muss mit dem PIN übereinstimmen
|
17 | setup_adc(ADC_CLOCK_INTERNAL); //Takt des ADC
|
18 |
|
19 | delay_ms(20);
|
20 |
|
21 | while(1)
|
22 | {
|
23 | delay_us(100);
|
24 | x=read_adc();
|
25 | }
|
26 | }
|
Ich hoffe jemand kann mir bei diesem Problem helfen. Falls noch etwas
unklar ist werde ich gerne noch weiter Details angeben.