Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

wind speed measurement

Status
Not open for further replies.

boiler95

Member level 1
Joined
Jan 7, 2011
Messages
38
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,731
I've been working on measuring wind speed. I'm using PIC16F72 (easily available) . My circuit uses a encoder wheel and photo diode to sendout pulses. program uses ccp and timer module to measure the period of the pulses.

I actually need to convert the timer count to rpm. For this I need to do math ( division ) . Can someone let me know if this is possible ?
 
Last edited:

Of course it's possible. Do you have a more specific question?
 

If you are doing Assembly language, check out PicList for math routines (http://www.piclist.com/techref/piclist/index.htm). I have found most of the material there to be quite reliable. You will presumably need to send the results to a display. Chose a simple serial LCD display. The serial routines on PIcList work well.

John
 

Thank you. I thought we could just divide variables using the division operator.
Eg .
If there is a variable
Count res 0x02h

Is this valid ?
Count = count * 0.5 ;
Can the compiler understand it ? Note that the program is in asm.
 

Hi,

Perhaps we can help better if you post your full code and circuit and the link to the original project.
 

A compiler will understand that notation for constants, but I don't think you can handle variables in the assembler like that.

In MPASM code, your statement could be translated into a simple rotate right, i.e., rrf, w or f ,depending where you want it to end up. I think with that chip, you will have to be sure carry doesn't rotate a bit back in at the msb.

John
 

Why do you want to use assembly programming for the calculation? Is it a requirement of your project or homework problem?
 

Thank you, I get it now. we need to do some binary arithmetic in order to get the desired result !

Why do you want to use assembly programming for the calculation? Is it a requirement of your project or homework problem?

no its not a requirement. I have the rpm "x" and i need to convert it into wind speed. For which i need to do some math. And i thought this is the only way out.
How people working on PIC micros generally do such arithmetic ? is there something i'm not aware ?
 

How people working on PIC micros generally do such arithmetic ? is there something i'm not aware ?
People are using high level programming languages like C and compilers with math libraries.
 
Thank you, I get it now. we need to do some binary arithmetic in order to get the desired result !



no its not a requirement. I have the rpm "x" and i need to convert it into wind speed. For which i need to do some math. And i thought this is the only way out.
How people working on PIC micros generally do such arithmetic ? is there something i'm not aware ?


Hi,

Probably the simplest way to convert your encoder reading is via a 'lookup table' though it depends on how many entries you need.
See example 1.9 here for an simple examplehttp://www.winpicprog.co.uk/pic_tutorial1.htm

As mentioned earlier the Piclist site is a good place for maths routine.

Perhaps if you show us your input value range and what formula you intend to convert it to wind speed, and what it is to be displayed on 7SEG/LCD/PC we can help more
 
  • Like
Reactions: boiler95

    V

    Points: 2
    Helpful Answer Positive Rating

    boiler95

    Points: 2
    Helpful Answer Positive Rating
Some minimal math plus a lookup table is probably the way to go.

Peter Anderson developed a double-table look-up method quite awhile ago that you might find useful for the chip you are using: https://www.phanderson.com/PIC/16C84/mult_string.html

If you decide to go that way, I can provide a couple of examples in assembly.

John
 
  • Like
Reactions: boiler95

    V

    Points: 2
    Helpful Answer Positive Rating

    boiler95

    Points: 2
    Helpful Answer Positive Rating

hello,

Some time to avoid use of float aritmetics wich use a lot of ram and time calculation
we can use long int and astuces to multiply by a known number..
example to mutiply an integer value by 6.5
multyply it by 260 and divide by 40
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top