Hello, I’m Nick. Before I say my problems I will first explain the meaning of the project. Or you can just skip and go to Problems.
My mother language is Dutch so it’s possible that I write some faults.
Meanings of project:
We must build a bio-diesel mixing installation for our last year project and we are simulating the signals and rotating pumps with LED's so people can get a better view of the project and how the system works. The installation haves 3 output hoses for the mixed fuel and the ratio can be set with a BCD switch that is connected with the PLC that controls the pumps. A flow meter gives feedback to the PLC so he can control the pumps.
In the simulation:
The pump signal (0 to 10Volts) will go to the simulation board that returns a signal (of the flow control, 4-20mA) to the PLC, this signal will be lower than the input signal to simulate the resistance in the hoses depending on the selected hose. (When the Fault1 button is pressed down this will simulate an obstruction in the hose so the output signal will drop whit 90% of the input signal.)
Problems:
I'm having problems with programming the PIC. The biggest problem is using the AD-converter, the resolution of the converted has been set to an 8-bit resolution but I'm still getting a 2-bit resolution. How can I solve this problem?
Code of analog input on Master:
Code:Device 16F877A Config wdt_off, lvp_off, hs_osc, pwrte_on XTAL = 20 '##################################### '############# Settings ############## '##################################### 'analog settings Declare ADIN_RES 8 ' 8-bit result Declare ADIN_TAD FRC ' RC OSC Declare ADIN_STIME 50 Declare CCP1_PIN PORTC.2 Declare CCP2_PIN PORTC.1 ' 76543210 ADCON1 = %10001101 ' AN0, AN1, VRef-, VRef+, RA5, RE0, RE1 en RE2 TRISA = %00001111 ' 4 analog inputs and 2 outputs for controlLED PORTA = %00010000 ' controlLED red (when starting) TRISB = %00110100 ' RB5, RB4 en RB2 are simulation controls PORTB = %00000000 TRISC = %01001001 ' RC7(RX)o, RC6(TX)i, RC5(K1)o, RC4(K2)o, RC3i, RC2(conv 0-5V -> 4-20mA)o, RC1(conv 0-5V -> 4-20mA)o en RC0i PORTC = %00000000 TRISD = %00000000 ' outputs to counters PORTD = %10101010 ' makes all resets of counters high TRISE = %00000111 ' inputs for the choice between the tree hoses PORTE = %00000000 '##################################### '############## Aliases ############## '##################################### 'analog inputs Symbol AIDsl = PORTA.0 ' analog input \ Symbol AnDsl = 0 ' analog channel > of diesel Dim MBDsl As Byte ' analog value / Symbol AIBio = PORTA.1 ' analog input \ Symbol AnBio = 1 ' analog channel > of bio Dim MBBio As Byte ' analog value /![]()




Bookmarks