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

Stepper project problems - CCS C PCM Compiler
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Raven



Joined: 08 Jan 2004
Posts: 3

View user's profile Send private message

Stepper project problems - CCS C PCM Compiler
PostPosted: Thu Jan 08, 2004 4:23 am     Reply with quote

Hi All

We are a group of mechanical engineer students who has some problems with a stepper motor project.

Our project is described here:
http://www.pfg.dk/pub/index.php/user/content/view/full/138?PHPSESSID=93146569ae1dc31efa9bfebe87763d55

The problem is with the controlling of the stepmotors. Since we are mechanical Engineer Students the world of electronic is tough. We have chosen a solution with an stepper controller which takes advantage of the PIC 16C73.
The controller is this one:
http://www.doc.ic.ac.uk/~ih/doc/stepper/smack-jnr/

The problem is that the source code is not compiled and the CCS C PCM compiler is pretty expensive for a one time use only for a student :-)
The sourcecode can be seen here:
http://www.doc.ic.ac.uk/~ih/doc/stepper/smack-jnr/smack_pic.c

Is there anybody out there who would help us and compile the program with CCS C PCM compiler?

We are using the Pic 16C73A, and we have the pic burner

Any help would really be greatly appriciatet!

Best Regard and thanks in advance
Kristoffer Raun

Stud. Polyt.
s011530@student.dtu.dk
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Thu Jan 08, 2004 7:47 am     Reply with quote

You should be able to use a 16F876 instead. There is a demo of the compiler that will allow to you compile the code and since the device is flash based you can reprogram it. The demo might only be for the 16F877 but it should still work in the 16F876.
dyeatman



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

View user's profile Send private message

Compile
PostPosted: Thu Jan 08, 2004 8:47 am     Reply with quote

I get a "Not Enough RAM for Variables" message when I try to compile this for you.

However, it compiles with no problems for the 16C76 here are the statistics (notice that Worst Case RAM is the problem, you only have 192, so you may be able to fix this with some reorganization):

ROM used: 2545 (31%)
2048 (25%) including unused fragments

2 Average locations per line
6 Average locations per statement

RAM used: 150 (41%) at main() level
205 (56%) worst case

Lines Stmts % Files
----- ----- --- -----
823 454 100 C:\My Download Files\smack_pic.c
215 0 0 C:\CCS_C\PICC\devices\16c76.h
----- -----
2076 908 Total

Page ROM % RAM Functions:
---- --- --- --- ----------
0 14 1 0 @GETCH_BIU_1
0 172 7 4 InitialiseMotors
0 42 2 3 rda_handler
0 28 1 1 tbe_handler
0 5 0 0 allowNewMessage
0 37 1 4 startMotor
0 194 8 6 timer1_handler
0 21 1 3 stopMotor
0 25 1 5 @MUL1616
0 630 25 6 UpdateMotorQ
0 103 4 6 CheckLimits
1 1203 47 0 main

Segment Used Free
--------- ---- ----
00000-00003 4 0
00004-00046 67 0
00047-007FF 1271 706
00800-00FFF 1203 845
01000-017FF 0 2048
01800-01FFF 0 2048
Raven



Joined: 08 Jan 2004
Posts: 3

View user's profile Send private message

Compile
PostPosted: Thu Jan 08, 2004 9:16 am     Reply with quote

Hi Dyeatman

You wrote you tried to compile it to 16C76- Is there any difference between this and Pic 16C73A when compiling.


Thanks for your help so far! :-)



Kristoffer Raun
dyeatman



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

View user's profile Send private message

Compiling Stepper project
PostPosted: Thu Jan 08, 2004 3:22 pm     Reply with quote

I did this purely because the 76 has more memory since the 73 compile came up short on memory and to see if there were any other compile time code problems, which there were not.

Code wise the program should compile fine on the 73 when you get the memory usage down a bit. Whether it runs correctly is another story....can't do much about that here since I don't have any of the hardware...
Raven



Joined: 08 Jan 2004
Posts: 3

View user's profile Send private message

Compile
PostPosted: Thu Jan 08, 2004 6:35 pm     Reply with quote

Hi Dyeatman

Thanks a lot for your good answer!

I'm a beginner into this PIC'ing, but i'm wondering if it's possible to compile it , even thought that there isn't enough space for the variables?


Anyway i will try to get the memory usage down and hopefully this will work.

How much does the compiled program use at the moment and how much do i have to cut it down?

Thanks in advance

Kristoffer Raun
dyeatman



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

View user's profile Send private message

Stepper Project
PostPosted: Thu Jan 08, 2004 9:46 pm     Reply with quote

According to the stats I provided in the earlier reply:

ROM used: 2545 (31%)
2048 (25%) including unused fragments

2 Average locations per line
6 Average locations per statement

RAM used: 150 (41%) at main() level
205 (56%) worst case

The problem is in the last line above (205 worst case) meaning that you require 205 RAM positions worst case but only 150 in the main program (you have 192 RAM to play with in the 73) sooooo you need to work on eliminating/combining/reusing variables as much as possible to get the worst case number down to below 192 (-13 decrease) which should be possible with a little analysis.

You have plenty of ROM left (73 has 4096) so RAM is your main issue at this point.

Good Luck!
dave
Raven



Joined: 08 Jan 2004
Posts: 3

View user's profile Send private message

Compiling
PostPosted: Fri Jan 09, 2004 4:07 am     Reply with quote

Hi Dave

Thanks a lot - I will give it a try to reuse some of the variables.
Tell me - what happens if i use this program and put it into the pic, and the used ram amount exceed 192?

Best Regards
Kristoffer
dyeatman



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

View user's profile Send private message

Compiling
PostPosted: Fri Jan 09, 2004 7:22 am     Reply with quote

Theoretically, the program should not exceed the worst case spec the compiler generates. Therefore the prgram should not compile if the compiler sees a possiblility of running out of RAM. However, that doesn't mean it can't happen(never say never!). If it does, a program crash will likely occur depending on circumstances or at best a program anomaly of some kind (??).

Dave
Raven



Joined: 08 Jan 2004
Posts: 3

View user's profile Send private message

Compiler
PostPosted: Fri Jan 09, 2004 9:13 am     Reply with quote

Hi Dyeatman

Thank again for your answer.
I have looked thru the code and have found a limit switch-function which we aren't going to use - i will delete this function from the code and hopefully this should give me the last 13.... :-)


Another question - I see in the code that the baudrate is fixed to 1200 baud.

#use rs232(baud=1200,xmit=PIN_c6, rcv=PIN_c7,errors)

Is it possible for the pic to use a higher baud rate with the 16C73A ?

#use rs232(baud=9600,xmit=PIN_c6, rcv=PIN_c7,errors)
What's the limit?

Best Regards

/Kristoffer


Last edited by Raven on Fri Jan 09, 2004 9:21 am; edited 1 time in total
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Jan 09, 2004 9:20 am     Reply with quote

With a 10MHz crystal you can do 57600 with a small % error. If 9600 is fast enough for you, that would be ideal.
Raven



Joined: 08 Jan 2004
Posts: 3

View user's profile Send private message

Compile
PostPosted: Fri Jan 09, 2004 11:16 am     Reply with quote

Hi


Thank you Mark for your answer - i have set it to 9600, this should be adequate.

I have removed a limit function to control some limitswitches that we dont need. This could give the needed space.

http://www.pfg.dk/smack_pic.c

Best Regards
Kristoffer


Last edited by Raven on Fri Jan 09, 2004 12:05 pm; edited 1 time in total
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Jan 09, 2004 12:44 pm     Reply with quote

This is what I get with an older version of the compiler

CCS PCM C Compiler, Version 3.089, 12084

Filename: test.LST

ROM used: 2457 (60%)
Largest free fragment is 851
RAM used: 141 (73%) at main() level
187 (97%) worst case
Stack: 4 worst case (2 in main + 2 for interrupts)

So yes, it compiled
dyeatman



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

View user's profile Send private message

Compiler
PostPosted: Fri Jan 09, 2004 2:44 pm     Reply with quote

I get the same statistics for 3.182 (as shown below) so you seem to have that much taken care of. It compiles fine for me as well...

Dave

=============
ROM used: 2140 (52%)
985 (24%) including unused fragments

2 Average locations per line
5 Average locations per statement

RAM used: 141 (73%) at main() level
187 (97%) worst case

Lines Stmts % Files
----- ----- --- -----
779 428 100 C:\My Download Files\smack_pic.c
215 0 0 C:\CCS_C\PICC\devices\16c73.h
----- -----
1988 856 Total

Page ROM % RAM Functions:
---- --- --- --- ----------
0 13 1 0 @GETCH_BIU_1
0 124 6 3 InitialiseMotors
0 30 1 2 rda_handler
0 24 1 1 tbe_handler
0 5 0 0 allowNewMessage
0 24 1 3 startMotor
0 160 7 5 timer1_handler
0 18 1 2 stopMotor
0 32 1 5 @MUL1616
0 559 26 5 UpdateMotorQ
1 1063 50 0 main
Guest








Re: Stepper project problems - CCS C PCM Compiler
PostPosted: Fri Jun 04, 2004 8:26 pm     Reply with quote

Raven wrote:
Hi All

We are a group of mechanical engineer students who has some problems with a stepper motor project.

Our project is described here:
http://www.pfg.dk/pub/index.php/user/content/view/full/138?PHPSESSID=93146569ae1dc31efa9bfebe87763d55

The problem is with the controlling of the stepmotors. Since we are mechanical Engineer Students the world of electronic is tough. We have chosen a solution with an stepper controller which takes advantage of the PIC 16C73.
The controller is this one:
http://www.doc.ic.ac.uk/~ih/doc/stepper/smack-jnr/

The problem is that the source code is not compiled and the CCS C PCM compiler is pretty expensive for a one time use only for a student :-)
The sourcecode can be seen here:
http://www.doc.ic.ac.uk/~ih/doc/stepper/smack-jnr/smack_pic.c

Is there anybody out there who would help us and compile the program with CCS C PCM compiler?

We are using the Pic 16C73A, and we have the pic burner

Any help would really be greatly appriciatet!

Best Regard and thanks in advance
Kristoffer Raun

Stud. Polyt.
s011530@student.dtu.dk
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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