Discussion in "Project Doubts" started by    onyot    Nov 23, 2010.
Mon Dec 13 2010, 12:51 pm
#91
Sir ExperimenterUK, I just wanna ask that, does atmel's 8051 can handle 35 codes (referring to what my example)?
And what do you mean by the note above, especially the second sentence?
Mon Dec 13 2010, 12:59 pm
#92
hi onyot.josephian

Sir ExperimenterUK, I just wanna ask that, does atmel's 8051 can handle 35 codes (referring to what my example)?


yes can handle 35 codes store code in rom then it can handle

Note:
stockLevels are only bytes, and atol() returns a "long" value.
The compiler may need to be told to convert a "long" to a "uchar".


he said that may be compiler give u error when u use atoi () function
because it returns long data type


[ Edited Tue Dec 14 2010, 09:46 am ]
Mon Dec 13 2010, 01:13 pm
#93
ah.... Thanks sir majoka.....
Mon Dec 13 2010, 01:34 pm
#94
welcome onyot.josephian
do concentrate on ur work and dnt worry about these hurdles it will come with respect to time ans will solved here
dnt worry
Mon Dec 13 2010, 02:14 pm
#95
nice majoka, i seen you for the second time using smiley.. lol.. aheheheeh..
Tue Dec 14 2010, 01:06 am
#96


Sir ExperimenterUK, I just wanna ask that, does atmel's 8051 can handle 35 codes (referring to what my example)?
And what do you mean by the note above, especially the second sentence?

onyot.josephian



Which 8051 device are you using ?
The original has limited rom and ram so may not be good enough for your task.

As majoka said atoi() and atol() return values larger that the 8 bit value I used to store the stock level.

We know this and are happy to just keep the 8 bit value,
but the compiler will usually warn of a problem.
To avoid the warning we tell the compiler what we want to do by using a "cast".
uchar result;   

result = atoi(keyBuffer);   //compiler not happy 
result =(uchar) atoi(keyBuffer);    //compiler  happy 


Obviously if your stock level is over 255 you need to use integers for storage.


//Create an array of stock codes in ROM/program memory.. 5 in this example.
//and an array of storage bytes in Ram.

long stockCodes[]={707021,345678,232345,334455,998877};
uchar stockLevels[]={0,0,0,0,0};


Micros treat rom/program storage differently to ram storage.
The compiler has to be told what is is is rom somehow.
I don't know yours well enough to give examples, so check it out for yourself
or your program will compile but not work.
 romel_emperado like this.
Thu Dec 16 2010, 05:30 am
#97
Sir ExperimenterUK
I am using at89c2051...
Do you have any suggestion what microcontroller should I use?
Does the program above, should be in void main () or not?
What about if I use AT89S52? is it okay?

And what do you mean by the char index=0?
should I make index=1 in the next line?

does uchar stockLevels[]=(0,0,0); mean that every 0 will represent the numbers in long stockCodes, am I right?


[ Edited Thu Dec 16 2010, 08:45 am ]
Thu Dec 16 2010, 09:43 am
#98
Hi onyot, if your code size is more that 2k then you must use higher flash memory storage like AT89s52/AT89s52..

does uchar stockLevels[]=(0,0,0); mean that every 0 will represent the numbers in long stockCodes, am I right?


yes, you store in the array every stockcodes you want..
in accessing the array, remember that you must always start to zero location of the array


[ Edited Thu Dec 16 2010, 09:46 am ]
Thu Dec 16 2010, 12:20 pm
#99
if u want to in between 20 pins controller and memory size is greater than 2 k then u can use at89c4051
it has 4k flash and 128 byte ram with 2 ports
 onyot.josephian like this.
Thu Dec 16 2010, 10:59 pm


Sir ExperimenterUK
I am using at89c2051...
Do you have any suggestion what microcontroller should I use?

onyot.josephian


Anything but an 89c2051

An AT89S52 looks like a good choice, lots of ram and program space.


And what do you mean by the char index=0?
should I make index=1 in the next line?

onyot.josephian


This is simply creating a variable called index with a starting value of 0.
You increment index as you compare the user input with stockCodes in a loop.


does uchar stockLevels[]=(0,0,0); mean that every 0 will represent the numbers in long stockCodes

onyot.josephian


There is one "stockLevels" for each "stockCodes",initially 0.


Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Lewisuhakeply
Thu Apr 18 2024, 06:00 pm
Darrellciz
Thu Apr 18 2024, 11:07 am
Charlessber
Thu Apr 18 2024, 09:29 am
BartonSem
Thu Apr 18 2024, 04:56 am
DonaldKnown
Thu Apr 18 2024, 12:24 am
utaletxcyw
Wed Apr 17 2024, 10:21 am
Anthonyvab
Wed Apr 17 2024, 08:48 am
RobertCix
Wed Apr 17 2024, 06:46 am