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 support@ccsinfo.com

Best way to start

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



Joined: 31 Mar 2004
Posts: 3
Location: Narooma NSW Aus

View user's profile Send private message Visit poster's website

Best way to start
PostPosted: Wed Mar 31, 2004 7:25 pm     Reply with quote

Hi all.

I currently program in Pic Basic Pro for my pic development and am quite happy with it except for the fact I sometimes need Floating Point MAth. Hence I am looking for a new lanuage if possible.

I write for the windows platform in Delphi and have never used anything other than basic or PAscal/Delphi. In both these I am self taught from examples and books

So my question is: Does the use of C and more specificaly ccs C give me floating point math capabilities and if so, is it possible to learn C simply from books and examples? I have cast an eye over some quick and small code but haven't got into compiling stuff as yet..

Regards, Peter
Steve H
Guest







PostPosted: Wed Mar 31, 2004 7:52 pm     Reply with quote

What don't you like about the Floating point in the BASIC you are using?

If it doesn't have any floating point then the CCS compiler will be a step up but if you are expecting it to work like a PC with many bits of precision then you will not be happy as the floating point in CCS is only 4 to 5 bits accurate.

I would like to suggest fixed point math - You can search this board for some examples (and othet places). It has known accuracy - the math is simple and it is fast. I use (as do others here) fixed point for all my math with PIC's. After all we are dealing with a very small platform here and large amounts of floating point use huge amounts of resources.

Hope this helps...

Steve H.
beachy



Joined: 31 Mar 2004
Posts: 3
Location: Narooma NSW Aus

View user's profile Send private message Visit poster's website

PostPosted: Wed Mar 31, 2004 8:02 pm     Reply with quote

Hi.

Pic Basic Pro has no floating point math at all. Well actually with a bit of fidling you can but not standar.

As in 10 / 3 will retun 3 so I am looking for atleast 1 decimal place or a few more if possible...
Charlie U



Joined: 09 Sep 2003
Posts: 183
Location: Somewhere under water in the Great Lakes

View user's profile Send private message

PostPosted: Wed Mar 31, 2004 10:14 pm     Reply with quote

I can't say that there is a best way to get started, but there are several good books, and the CCS compiler includes many examples. Also, Peter Anderson has some examples available at:

http://www.phanderson.com/PIC/PICC/index.html

Also, review the posts on this forum. Many of the posters add links to their projects that you can review.

The basic C reference for most programmers is "The C Programming Language, 2nd Edition" written by Kernighan and Ritchie. As I recall, CCS has a book on this website also.
Jeprox
Guest







PostPosted: Thu Apr 01, 2004 4:59 am     Reply with quote

My personal opinion is that the "The C Programming Language, 2nd Edition" written by Kernighan and Ritchie is not my preferred "first" book to learn C. Learn by example is what I would suggest and use the "The C Programming Language, 2nd Edition" to complement your study.
Guest








PostPosted: Thu Apr 01, 2004 5:14 am     Reply with quote

i found the best way to use floating points with pics is to cast int's as floats
beachy



Joined: 31 Mar 2004
Posts: 3
Location: Narooma NSW Aus

View user's profile Send private message Visit poster's website

PostPosted: Thu Apr 01, 2004 5:41 am     Reply with quote

Thanks all so far for your thoughts. I am very interested in your input...

So far in regards to Pascal and Delphi, it has been learn by example and I have done this because I have had a need to achieve something. My mates used mostly Pascal co I got free tutoring... That helped.

Pic Basic is fine for most of what I need but I have always wanted to be able to program for my Linux box and now I see that C can be used to program PICs it seems like it may be the way to go.

So I am sort of after a concensious in regards to what to look for. There seems to be a lot of versions of C etc and I have no idea if one is better than another. The reason I found CCS is because of the links to PICs and the fact it has a support group...

I usually pick things up quickly but am looking for a book or articles that sort of explain things like

dothis()
{

}


Is dothis a function/procedure? What are the open and close brackets for and also what are the {} things for???

What I mean is the above is an example of my questions. They are real as I have no idea what the above means but I need to sart somewhere...
SteveS



Joined: 27 Oct 2003
Posts: 126

View user's profile Send private message

PostPosted: Thu Apr 01, 2004 7:40 am     Reply with quote

If you know Pascal/Delphi then moving to C is not too bad. The K&R book will get you thru, or look up stuff on the web. Probably the hardest transition (as I recall) was getting used to pointers, which C uses a fair amount of, though I don't use them too much in CCS. C is not as readable (IMHO!) as Pascal, and allows you to 'get way' with more things (like looser type casting, etc). You basically need to learn how to translate between the two to get going, they use the same basic programming styles, but syntax (symbol use) is very different - for instance '{' and '}' would translate into 'begin' and 'end' (more or less). Look at the examples, start coding, and look things up when it won't compile.

- SteveS
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