CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Communication between LabView and CCS.

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Aayush13



Joined: 12 Aug 2016
Posts: 14

View user's profile Send private message

Communication between LabView and CCS.
PostPosted: Fri Aug 12, 2016 9:42 am     Reply with quote

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: 19541

View user's profile Send private message

PostPosted: Fri Aug 12, 2016 10:45 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Aug 12, 2016 12:17 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group