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

Need help to understand this...

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







Need help to understand this...
PostPosted: Sat Jan 09, 2010 10:35 pm     Reply with quote

Code:

void init_Gyro1DKalman(struct Gyro1DKalman *filterdata, float Q_angle, float Q_gyro, float R_angle)
{
   filterdata->Q_angle = Q_angle;
   filterdata->Q_gyro  = Q_gyro;
   filterdata->R_angle = R_angle;
}


Hye I got this code from blog, its for kalman filter, it were much longer but I cut it.
My question is what is the function of:
Quote:
struct Gyro1DKalman *filterdata

and
Quote:
filterdata->Q_angle = Q_angle;

the ....->.... have any meaning?
dyeatman



Joined: 06 Sep 2003
Posts: 1933
Location: Norman, OK

View user's profile Send private message

PostPosted: Sat Jan 09, 2010 10:54 pm     Reply with quote

Structs and pointers to structs are explained here:
http://www.iu.hio.no/~mark/CTutorial/CTutorial.html#Pointers%20to%20Structures
_________________
Google and Forum Search are some of your best tools!!!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Jan 09, 2010 10:55 pm     Reply with quote

This is not a C learning forum. You're expected to learn the C language
outside of this forum. A good way to do this is to read online tutorials.
Here are a few web pages on Pointers and Structures:
http://www.cs.cf.ac.uk/Dave/C/node10.html#SECTION001070000000000000000
http://www.taranets.com/cgi/ts/1.37/ts.ws.pl?w=329;b=282
http://home.netcom.com/~tjensen/ptr/ch5x.htm
http://publications.gbdirect.co.uk/c_book/chapter6/structures.html
kalman
Guest







PostPosted: Sun Jan 10, 2010 3:17 am     Reply with quote

sorry, thanks....
kalman
Guest







PostPosted: Sun Jan 10, 2010 3:26 am     Reply with quote

Guys, is there any other tutorial page?
A complete tutorial on c...

One more thing, when I compile a code consist of math.h file the compiler give error:
cannot change device type this far into the code
and it open the pic.h file. I need to do inverse sine of some math equation.
dyeatman



Joined: 06 Sep 2003
Posts: 1933
Location: Norman, OK

View user's profile Send private message

PostPosted: Sun Jan 10, 2010 9:44 am     Reply with quote

That error actually is particular to the CCS compiler.
The #include line with your PIC .h file MUST be the first one in the code.

Code:
#include <18F458.H>
#fuses XT, NOPROTECT, NOBROWNOUT, NOWDT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, errors)

If you include a custom .h file the #include line for the PIC must be the first
line of that file.

Here are examples of the two formats:

http://www.ccsinfo.com/forum/viewtopic.php?t=21575
http://www.ccsinfo.com/forum/viewtopic.php?t=26835


If you can't figure it out, post the first 20 or so lines of your code (be sure
to use the CODE button) so we can see what you have.
_________________
Google and Forum Search are some of your best tools!!!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jan 10, 2010 3:25 pm     Reply with quote

Quote:
Guys, is there any other tutorial page?
A complete tutorial on c...

Here is a tutorial for CCS. It's not perfect. His sample programs are
a little too short. He leaves off the #fuses statement. He doesn't put a
while(1); statement at the end of main(), to prevent the PIC from going
to sleep if the program falls off the end of main(). But it's mostly OK.
http://www.swarthmore.edu/NatSci/echeeve1/Ref/C%20for%20PIC/C_Intro.html

This tutorial is for the Hi-Tech compiler. CCS uses different default
sizes for the datatypes than Hi-Tech does, so it's not completely
applicable. But it's still OK. (In the CCS PCB, PCM, and PCH compilers,
an 'int' is an unsigned 8-bit integer).
http://phy.ntnu.edu.tw/~cchen/ctutor.pdf

You can find more tutorials. Google for: CCS compiler tutorial
dbotkin



Joined: 08 Sep 2003
Posts: 197
Location: Omaha NE USA

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Sun Jan 10, 2010 10:49 pm     Reply with quote

And then there is always The C Programming Language, by Kernighan & Ritchie. A little dry perhaps, and not really a tutorial. Still, as a reference it's invaluable. I did most of my C learning from it.
kalman
Guest







PostPosted: Tue Jan 12, 2010 4:41 am     Reply with quote

Can I pass input value from adc to struct?
To store the value and then call it back.
Anywhere I can learn this?
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