View previous topic :: View next topic |
Author |
Message |
Aayush13
Joined: 12 Aug 2016 Posts: 14
|
Communication between LabView and CCS. |
Posted: Fri Aug 12, 2016 9:42 am |
|
|
Hey guys, I am trying to get a floating point number from labview to calculate power. However, my program in labview only accepts chars and strings. Here is my code in CCS so far:
Code: |
void main()
{
float V, P;
while(TRUE)
{
delay_ms(1000);
V = 25;
char res[50];
float P = (V * V)/(getc());
ftoa(P, res, 1)
puts(res);
}
}
|
If I enter, for example, } for the resistor value I get the correct answer. But if I were to put 125 instead then I do not get the correct answer. Can anyone help me on this? Thanks! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Fri Aug 12, 2016 10:45 am |
|
|
Basic C. Get a textbook!...
You need to read a sequence of characters, decode these to a number, and then do the maths.
gets, rather than getc, and then look at atof and it's other derivatives. |
|
|
Aayush13
Joined: 12 Aug 2016 Posts: 14
|
|
Posted: Fri Aug 12, 2016 12:17 pm |
|
|
Ttelmah wrote: | Basic C. Get a textbook!...
You need to read a sequence of characters, decode these to a number, and then do the maths.
gets, rather than getc, and then look at atof and it's other derivatives. |
I am new to C which is why I have trouble figuring this out haha |
|
|
|