moad
Newbie level 5
- Joined
- Jan 30, 2015
- Messages
- 9
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 113
hello,
for the past week iv just started my first ever project to make a c program on the software called mikroc where i would get pulses in from the flow meter and calculate the flow rate of how much milliters flows every second which then outputs to the lcd, however, when i connected it to portd of the pic16f877a RD0, it gave random values everytime that go up and down on the lcd. please if any one knows how to make this work and whats my mistake i would really appreciate it. and sorry i am a beginner to this...
pic16f877a datasheet: https://ww1.microchip.com/downloads/en/DeviceDoc/39582b.pdf
water flow meter datasheet: https://www.hobbytronics.co.uk/datasheets/sensors/YF-S201.pdf
PROGRAM:
for the past week iv just started my first ever project to make a c program on the software called mikroc where i would get pulses in from the flow meter and calculate the flow rate of how much milliters flows every second which then outputs to the lcd, however, when i connected it to portd of the pic16f877a RD0, it gave random values everytime that go up and down on the lcd. please if any one knows how to make this work and whats my mistake i would really appreciate it. and sorry i am a beginner to this...
pic16f877a datasheet: https://ww1.microchip.com/downloads/en/DeviceDoc/39582b.pdf
water flow meter datasheet: https://www.hobbytronics.co.uk/datasheets/sensors/YF-S201.pdf
PROGRAM:
Code C - [expand] 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 void main() { volatile unsigned int value; char str [20]; double calc; lcd_init(); //initiallise lcd ADC_Init(); // and to read in values TRISD.f0=1; //setting the signal input PORTD.F0=0; while (1) { if (PORTD.F0= 1) //if water flows through the meter { value = ADC_read(PORTD.F0); //read from RD0 and assign to value read delay_ms(100); //delay so i could see value on screen calc = (value * 60 / 7.5); //calculation to show flow per minute byteToStr(calc,str); lcd_out (1,1, str); //output to screen value++; } } }
Last edited by a moderator: