Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Count pulses and use of div32

Status
Not open for further replies.

nkwankwe

New Member
Good day,

I'm working on a project but I cant seem to get the programming right. I need help to do the following:
*the input is a square wave from a flow transducer at a rate of 65 pulses per litre(meaning 0.0154 litres per pulse)*
1. I need to count each pulse
2. from the pulse count, I have to determine the quantity(litres) of water flowing
3.Display the quantity on an LCD screen

*I'm using Pic Basic Pro to write the program codes.*
One of the problems that I have encountered is the "floating point" since the program uses integer values,so I need to apply Div32 to count at a resolution of 1 pulse, i.e. 0.0154 litre
 
Last edited:
Good day,

I'm working on a project but I cant seem to get the programming right. I need help to do the following:
*the input is a square wave from a flow transducer at a rate of 65 pulses per litre(meaning 0.0154 litres per pulse)*
1. I need to count each pulse
2. from the pulse count, I have to determine the quantity(litres) of water flowing
3.Display the quantity on an LCD screen

*I'm using Pic Basic Pro to write the program codes.*
One of the problems that I have encountered is the "floating point" since the program uses integer values,so I need to apply Div32 to count at a resolution of 1 pulse, i.e. 0.0154 litre

hi,
A common used method is to multiply the value by 1000 or 10,000, so that when you divide the constant you will have a result greater than unity.
By knowing your scaling factors, 1000 or 10,000 you can then place the decimal point in the correct position in the quotient.

OK.?
 
Indeed you are right, but the first problem is i cant get the pulses..I tried using this codin but I got nothing:

TRISE=0

DEFINE LCD_DREG PORTD
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTD
DEFINE LCD_RSBIT 1
DEFINE LCD_EREG PORTD
DEFINE LCD_EBIT 2
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50


W1 var word
PAUSE 1000

MAIN:
COUNT PORTC.2, 100, W1
PORTE.0 = W1
LCDOUT 254,1
LCDOUT #W1
GOTO MAIN
END
 
hi,
When you say you get nothing, do you mean the LCD is blank.??

You cannot output the Wvar WORD on 1 pin... PORTE.0

EDIT:

AS you are using PORTC.2 as the count input, you should TRISC to make PORTC.2 an Input
 
Last edited:
hi,
When you say you get nothing, do you mean the LCD is blank.??

You cannot output the Wvar WORD on 1 pin... PORTE.0

EDIT:

AS you are using PORTC.2 as the count input, you should TRISC to make PORTC.2 an Input

The LCD only displays "0",I dont get anything else displayed
I get your point on PORTE.0
However,regarding PORTC.2,the command COUNT ,according to Pic Basic tutorial,automatically sets the pin as input..But I'll try it anyway.

I would also like to get a few coding from you guys and try them out
Thanks
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top