Go to Post if you've got the guts you will get the job done. - JamesCH95 [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 13-02-2006, 11:22
Chris_Elston's Avatar
Chris_Elston Chris_Elston is offline
Controls Engineer
AKA: chakorules
FRC #1501 (Team THRUST)
Team Role: Engineer
 
Join Date: Feb 2004
Rookie Year: 2001
Location: Huntington, Indiana
Posts: 751
Chris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond repute
Pre-Load Arrays in EasyC, Possible?

Can anyone tell us if it is possible to pre-load your array with constant values in easyC? We want to create a lookup table and just need to create a single dimension array and load it with constants.

We have tried to define the constants as show in the screen shot. Look at "power[3]" It's a 1 x 4 array and when we set the value field to something like 0,0,0,0 we get an Error: 1 when we try and compile this.

If we leave it value field blank, such as the variable "sign[3]" then it will compile just fine.

We have tried formatting the value field:
0,0,0,0
{0,0,0,0}
(0,0,0,0)

The only thing that seems to work is leave it blank, then in code somewhere we have to do this:

power[0] = value0
power[1] = value1
power[2] = value2
power[3] = value3
(or write a loop to load up several constants...)

Is this the only way to pre-load the arrays in EasyC?
Attached Thumbnails
Click image for larger version

Name:	array.jpg
Views:	51
Size:	24.9 KB
ID:	3975  
__________________
Team T.H.R.U.S.T. 1501
Download all of our past robot's source code here:Repository

Favorite CD quote:
"That can't be their 'bot. not nearly enough (if any) rivets to be a 1501 machine." ~RogerR: Team #1369
  #2   Spotlight this post!  
Unread 13-02-2006, 11:55
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,860
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Pre-Load Arrays in EasyC, Possible?

I haven't focused any attention on EasyC, so take this with a grain of salt.

But from a C perspective...
power[3] in C has three locations available not four.
You may be confusing this with the index which starts with zero.

Initializing it with 3 values should work, i.e., {0,0,0}, or use power[4] instead.

In your example of setting the values at runtime you are actually overwriting the memory location past the end of the power array. The compiler doesn't check for this (there are other commercial tools that perform that function).
You can actually do something like "power[99] = 1;" and the program won't complain, but some other part of your code may mysteriously start acting erratically.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
  #3   Spotlight this post!  
Unread 13-02-2006, 11:58
Chris_Elston's Avatar
Chris_Elston Chris_Elston is offline
Controls Engineer
AKA: chakorules
FRC #1501 (Team THRUST)
Team Role: Engineer
 
Join Date: Feb 2004
Rookie Year: 2001
Location: Huntington, Indiana
Posts: 751
Chris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond repute
Re: Pre-Load Arrays in EasyC, Possible?

Yes, your right, hadn't had my mountain dew yet when I was trying to "make-up" a question to post.

Let me rephrase it:

We have tried formatting the value field:
0,0,0
{0,0,0}
(0,0,0)

The only thing that seems to work is leave it blank, then in code somewhere we have to do this:

power[0] = value0
power[1] = value1
power[2] = value2

***Thanks Mark***

Either way...stilll doesn't seem to work.....

Get an ERROR:1 when we compile it.


EDIT....well that was funny! It seems to work now.

Just now tried this format:
{0,0,0} with a power[3]

And it seems to work now. Geez..I need to go lay down....Maybe it's our programming computer at the robot field....works fine on my laptop.

BTY: As awesome as the HELP FILE is in EasyC, this is not documented how to do this in the help file. FYI....


-
__________________
Team T.H.R.U.S.T. 1501
Download all of our past robot's source code here:Repository

Favorite CD quote:
"That can't be their 'bot. not nearly enough (if any) rivets to be a 1501 machine." ~RogerR: Team #1369

Last edited by Chris_Elston : 13-02-2006 at 12:04.
  #4   Spotlight this post!  
Unread 13-02-2006, 12:04
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,860
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Pre-Load Arrays in EasyC, Possible?

Quote:
Originally Posted by chakorules
Geez..I need to go lay down....Maybe it's our programming computer at the robot field....works fine on my laptop.
Just double your intake of Mountain Dew. Time enough for sleep after ship.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
  #5   Spotlight this post!  
Unread 21-02-2006, 20:12
Mark_K Mark_K is offline
Registered User
FRC #1721 (Charette)
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2001
Location: Concord NH
Posts: 9
Mark_K will become famous soon enoughMark_K will become famous soon enough
Re: Pre-Load Arrays in EasyC, Possible?

I did notice that the {1,2,3,4} format does work but it generates an error (stack) if you have more than 100 or so. We were trying to generate a motor speed lookup table of 255 entries.
  #6   Spotlight this post!  
Unread 21-02-2006, 21:04
Chris_Elston's Avatar
Chris_Elston Chris_Elston is offline
Controls Engineer
AKA: chakorules
FRC #1501 (Team THRUST)
Team Role: Engineer
 
Join Date: Feb 2004
Rookie Year: 2001
Location: Huntington, Indiana
Posts: 751
Chris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond repute
Re: Pre-Load Arrays in EasyC, Possible?

Ours worked too until about {1,2,3,4, .... 51} At 51...we got an error. We needed about 70 slots to fine tune our lookup table as well. We ended up loading the array manually as described above.



-
__________________
Team T.H.R.U.S.T. 1501
Download all of our past robot's source code here:Repository

Favorite CD quote:
"That can't be their 'bot. not nearly enough (if any) rivets to be a 1501 machine." ~RogerR: Team #1369
  #7   Spotlight this post!  
Unread 22-02-2006, 10:25
Kingofl337's Avatar
Kingofl337 Kingofl337 is offline
You didn't see anything....
AKA: Adam
FRC #0501 (Power Knights)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 1998
Location: Manchester, NH
Posts: 861
Kingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond repute
Send a message via Yahoo to Kingofl337
Re: Pre-Load Arrays in EasyC, Possible?

The compiler only allows for 120 int slots total and allows for 254 char slots total. Not, 120/254 per array.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
EasyC Wish List dcbrown Programming 32 14-08-2006 09:24
Battery Life, 50A load discharge test method/results Dale(294engr] Electrical 5 22-01-2006 09:14
EasyC v2.0 is mandatory for FVC! skimoose FIRST Tech Challenge 7 14-01-2006 18:37
Kickoff easyC workshop integrated into EasyC help file Dan Larochelle Programming 0 11-01-2006 06:12


All times are GMT -5. The time now is 18:22.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi