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.

[PIC] Flowcode floating point problem

Status
Not open for further replies.

Shreedhar Bhat

Newbie level 6
Joined
Mar 17, 2014
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
68
I'm doing automatic power factor controller using flowcode (PIC 16f877A).
Displaying power factor is 0.9, 0.8 etc. I want to display two digits after decimal point like 0.92, 0.86..

Please help me.
Thank you.
 

I'm using flowcode v5.5.2.1..
I have .fcf file.. can't upload via this site.. it is not taking..
 

Zip the file using winzip or winrar and attach the file using Manage Attachments.
 

Zip the file using winzip or winrar and attach the file using Manage Attachments.

Milan Sir..
In this program i'm going to measure voltage (v) & power factor (PF).
I'm getting the proper voltage, but it is also in integer.
Mainly I need accurate power factor (PF) i.e. 2 digit after decimal point.

(Some calibrations needed for this program, initially i want solution for this.)
Please help me..
Thank you.
 

Attachments

  • pf volt org.zip
    3.4 KB · Views: 86

For ADC you have to use a ReadAsVoltage() and use a float type variable to store the ADC value. Your

Code C - [expand]
1
if(countdp)

conditions are outside the

Code C - [expand]
1
while(1)

loop and so it will never execute. Explain how your flowchart has to work? Why external interrupt is used?


http://www.matrixmultimedia.com/mmforums/viewtopic.php?f=5&t=4646

**broken link removed**

There is not Float To String macro in Flowcode. You have to write your own FloatToStr() macro which converts float value to string. Pass the string obtained to LCD Print macro. Only then you will get float alue printed on LCD. Print Number macro takes INT as argument so your float value get truncated.


Edit: I read the Flowcode Help file and it has FloatToString() and StringToFloat() functions. See attached file.

**broken link removed**
 

Attachments

  • adc floating point.rar
    4.6 KB · Views: 83
  • adc_lcd floating point.rar
    2.3 KB · Views: 85
  • adc fp.png
    adc fp.png
    220.9 KB · Views: 221
Last edited:
For ADC you have to use a ReadAsVoltage() and use a float type variable to store the ADC value. Your

Code C - [expand]
1
if(countdp)

conditions are outside the

Code C - [expand]
1
while(1)

loop and so it will never execute. Explain how your flowchart has to work? Why external interrupt is used?


**broken link removed**

There is not Float To String macro in Flowcode. You have to write your own FloatToStr() macro which converts float value to string. Pass the string obtained to LCD Print macro. Only then you will get float alue printed on LCD. Print Number macro takes INT as argument so your float value get truncated.



Sir.. Thank you very much for your reply..
I understood the working of ReadAsVoltage. Atcually i used to convert bytes later again converted into normal value. That one also working for only integer values.. Your suggestion is very good for accurate values..

Flowchart:
I used the external interrupt, because

In my project, Initially I find-out zero crossing of voltage(zero crossing detector), when voltage crosses zero timer start to count, it continues until current crosses zero(zcd), Timer stops to count and at the same time external interrupt will activate using zcd raising edge pulse. That external interrupt enters the loop to calculate power factor(PF) using time difference between voltage crossing zero & current crossing zero.

Later stage of the program i mentioned switching of relays for different capacitor switching as per power factor requirement. (PORT C is used).

I would like to maintain power factor(PF) above 0.91(0.92,0.93 etc) & to display same.

But display shows 0.8, 0.9,0.7 (only one digit after decimal point) as i told earlier.

Sir.. Just help me how to display two digit power factor(PF) after decimal point. (I'll do rest of the program, that depends on load, so..).

Please..

Thank you..





Edit: I read the Flowcode
 

See the attached file.

103336d1395174905-pf-volt-org-bckp.fcf-main.png


103337d1395175419-fc-pic.png
 

Attachments

  • pic16f877a adc flowcode.rar
    80.7 KB · Views: 92
  • pf volt org bckp.fcf - Main.png
    pf volt org bckp.fcf - Main.png
    98.3 KB · Views: 152
  • fc pic.png
    fc pic.png
    86 KB · Views: 202
Last edited:
Thank you very much sir.. No words to explain..

Sir here PF can also display in Decimal values as my wish na..?

Same procedure what you did for voltage..?
 
Last edited:

If you are using countdp variable for power factor then yes it is the same procedure as it is a float type.
 

If you are using countdp variable for power factor then yes it is the same procedure as it is a float type.

Yes Sir.. I'm using same..

Sir, Is it possible to reduce PF output to only 2 digits after decimal point.?
How..?
Please..
 

You have to add a C-Code element which contains the below code in between sVolt = FloatToString$ (fVolt) and LCDDisplay(0) Cursor(4, 1) Calculation elements.


Code C - [expand]
1
2
3
4
5
6
7
8
9
if((fVolt >= 0.0) && (fVolt < 10.0)) {
      sVolt[4] = 0
}
else if((fVolt >= 10.0) && (fVolt < 100.0)) {
      sVolt[5] = 0
}
else if((fVolt >= 100.0) && (fVolt < 1000.0)) {
      sVolt[6] = 0
}






Edit: Do as mentioned by ALERTLINKS. It is a simpler method.
 
Last edited:
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top