[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: 89

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: 89
  • adc_lcd floating point.rar
    2.3 KB · Views: 90
  • adc fp.png
    220.9 KB · Views: 228
Last edited:
 

See the attached file.



 

Attachments

  • pic16f877a adc flowcode.rar
    80.7 KB · Views: 96
  • pf volt org bckp.fcf - Main.png
    98.3 KB · Views: 155
  • fc pic.png
    86 KB · Views: 203
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

Cookies are required to use this site. You must accept them to continue using the site. Learn more…