Integer(Int) to Float number

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi There!

I'm using CY8CKIT-059 I'm codding this on PSOC Creator 4.2 So I need some help

My problem is;

I have 32bit anolog input from potantiometer. IT is around 0-65930 So I want to see this around 0-5,000V  

I made it 0-5000 mV  but I couldn't do 0-5,000V  

So how can I do it?

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

double Result;

Result = mV / 1000.0;   // Will convert to float

Happy coding

Bob

View solution in original post

0 Likes
6 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

double Result;

Result = mV / 1000.0;   // Will convert to float

Happy coding

Bob

0 Likes
Anonymous
Not applicable

Thanks you much

and now how can i print float or double numbers on LCD i cannot printing after point( . )

suach as my float or double is 5,342 i cannot printing ,342

0 Likes

Can you please post your complete project or a shortened version that shows the error so that we all can have a look at all of your settings. To do so, use

Creator->File->Create Workspace Bundle (minimal)

and attach the resulting file.

Bob

0 Likes
Anonymous
Not applicable

I'm sorry man i fixed it now you were right I just forget change the heap size now is working thanks for your helpfull

best regards.

0 Likes
DheerajK_81
Moderator
Moderator
Moderator
First comment on KBA First comment on blog 5 questions asked

The 32 bit analog input from your potentiometer can be mapped to the data range 0 - (2³²-1) which is essentially 4 bytes and unsigned int data type can easily accommodate this. However, if you want the data type to store decimal values, you can use the float data type which is also 4 bytes.

uint32 potentiometerInt; // Unsigned int

OR

float potentiometerFloat //float

If you want to convert from one data type to another you can just type cast it.

potentiometerFloat = (float) potentiometerInt

I didn't understand what you meant by 0-5000V, the voltage of the potentiometer can't be of such high value, are you talking about the count? What do you mean by i made it 0 - 5000mV, please clarify.

Regards,

Dheeraj

0 Likes
Anonymous
Not applicable

Thank you so much

0-5000mV means my converted output from potantiometer input when my potantiometer ohm is nearly 0 my output voltage from potantiometer

is 5v so 5000mV 

So i want to  print float number on LCD  i have got input from potantiometer and it is 32bit (int32) so data range

0 to (2^32-1) my problem is I cannot print after point(.) on LCD such as  my converted output is 5,238V but I cannot printing ,238

on LCD my problem is this I can printing 5238mV but cannot that one

0 Likes