Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

interfacing PIC 16F877A with 93c06

Status
Not open for further replies.

john120

Banned
Full Member level 5
Joined
Aug 13, 2011
Messages
257
Helped
11
Reputation
22
Reaction score
10
Trophy points
1,298
Visit site
Activity points
0
Hello every body I have a very long program which is using many if........else ..........if statements,so it is not running when all conditions are loaded so I want to use external EEPROM 93C06 for increasing the memory for storing those codes can you plz help me to do so;it is my first time to refer to the external EEPROM.

I am using ccs c compiler

Thanks.
 

How can you fullfill your PIC memory with if/else statements only? The 877 has 8K memory.. to get it full you must have thousands of if/else statements. Also, maybe a swtich case is better suited for the job, and, if you post the code, someone might suggest a better solution than using if/else statemens (the most common is a loop comparing array elements).
 


How can you fullfill your PIC memory with if/else statements only? The 877 has 8K memory.. to get it full you must have thousands of if/else statements. Also, maybe a swtich case is better suited for the job, and, if you post the code, someone might suggest a better solution than using if/else statemens (the most common is a loop comparing array elements).

can you plz help me with the loop comparing array I tried to do it but it is not working,see what Was my previous codes with if....else.....if:

Code:
/*if((value>=1234900) && (value1<=1235900))
 {
jean=7.2;
}
else if((value>=1234100) && (value1<=1234800))
 {
jean=7.3;
}
else if((value>=1234000) && (value1<=1231900))
{
jean=7.4;
}
else if((value>=1231500) && (value1<=1231800))
{
jean=7.5;
}
else if((value>=1230090) && (value1<=1230300))

{
jean=7.6;
}
else if((value>=1228900) && (value1<=1230100)) 
{
jean=7.7;
}
else if((value>=122600) && (value1<=1228000))
{
jean=7.8;
}
else if((value>=1226200) && (value1<=1226400))
 {
jean=7.9;
}
else if((value>=1224800) && (value1<=1226120))
 {
jean=8.0;
}
else if((value>=1223001) && (value1<=1224500))
{
jean=8.1;
}
else if((value>=1222999) && (value1<=1223000))
 
{
jean=8.2;
}
else if((value>=1220999) && (value1<=1223000))
{
jean=8.3;
}
else if((value>=1220001) && (value1<=1221000))
{
jean=8.4;
}
else if((value>=1219999) && (value1<=1220000))
  {
jean=8.5;
}
else if((value>=1217995) && (value1<=1219999))
 {
jean=8.6;
}
else if((value>=1218000) && (value1<=1219996))
 {
jean=8.7;
}
else if((value>=1217939) && (value1<=1217999))
 {
jean=8.9;
}
else if((value>=1217000) && (value1<=1217938))
 {
jean=9.0;
}
else if((value>=1216000) && (value1<=1216999))
{
jean=9.1;
}
else if((value>=1215130) && (value1<=1215999))
{
jean=9.2;
}
else if((value>=1215000) && (value1<=1215129))
{
jean=9.3;
}
else if((value>=1212000) && (value1<=1214999))
{
jean=9.4;
}
else if((value>=1210000) && (value1<=1212000))
 {
jean=9.5;
}
else if((value>=1209900) && (value1<=1209999))
 {
jean=9.6;
}
else if((value>=1209500) && (value1<=1209899))
{
jean=9.7;
}
else if((value>=1209800) && (value1<=1209499))
{
jean=9.8;
}
else if((value>=1208500) && (value1<=1209799))
 {
jean=9.9;
}
else if((value>=1207000) && (value1<=1208499))
{
jean=10;
}
  else if((value>=1205000) && (value1<=1206999))
  
{
jean=10.1;
}
else if((value>=1202500) && (value1<=1204999))
 {
jean=10.2;
}
else if((value>=1201500) && (value1<=1202499))
{
jean=10.3;
}
else if((value>=1201000) && (value1<=1201499))
 {
jean=10.4;
}
else if((value>=1200000) && (value1<=1200999))
{
jean=10.5;
}
else if((value>=1199500) && (value1<=1199999))
{
jean=10.6;
}
else if((value>=1199000) && (value1<=1199499))
 {
jean=10.7;
}
else if((value>=1198500) && (value1<=1198999))
{
jean=10.8;
}
else if((value>=1197000) && (value1<=1198000))
{
jean=10.9;
}
else if((value>=1196900) && (value1<=1196899))
{
jean=10.9;
}
else if((value>=1196000) && (value1<=1196899))
{
jean=11.0;
}
else if((value>=1195500) && (value1<=1195999))

{
jean=11.1;
}
else if((value>=1195000) && (value1<=1195499))
{
jean=11.2;
}
else if((value>=1194500) && (value1<=1194999))
 {
jean=11.3;
}
else if((value>=1194000) && (value1<=1194499))
{
jean=11.4;
}
else if((value>=1193500) && (value1<=1193999))
{
jean=11.5;
}
else if((value>=1193000) && (value1<=1193499))
{
jean=11.6;
}
else if((value>=1190000) && (value1<=1192999))
{
jean=11.7;
}
else if((value>=1188500) && (value1<=1189999))
{
jean=11.8;
}
else if((value>=1187000) && (value1<=1188000))
{
jean=11.9;
}
else if((value>=1184100) && (value1<=1186999))
 {
jean=12.0;
}
else if((value>=1183240) && (value1<=1184099))
 {
jean=12.1;
}
else if((value>=1182230) && (value1<=1183239))
{
jean=12.2;
}
else if((value>=1181200) && (value1<=1182229))
{
jean=12.3;
}
else if((value>=1181000) && (value1<=1181199))
{
jean=12.4;
}
 else if((value>=1180000) && (value1<=1180999))
{
jean=12.5;
}
 else if((value>=1179000) && (value1<=1179999))
{
jean=12.6;
}
else if((value>=1173850) && (value1<=1174949))
 {
jean=12.7;
}
else if((value>=1173650) && (value1<=1173849))

{
jean=12.8;
}
else if((value>=1173500) && (value1<=1173649))
{
jean=12.9;
}
else if((value>=1172500) && (value1<=1173499))
{
jean=13.0;
}
else if((value>=1171500) && (value1<=1172499))
{
jean=13.1;
}
else if((value>=1170000) && (value1<=1171499))
{
jean=13.2;
}
else if((value>=1168500) && (value1<=1169999))
{
jean=13.3;
}
else if((value>=1167500) && (value1<=1168499))
{
jean=13.4;
}
else if((value>=1166000) && (value1<=1167499))
{
jean=13.5;
}
else if((value>=1164500) && (value1<=1165999))
{
jean=13.6;
}
else if((value>=1163000) && (value1<=1164499))
 {
jean=13.7;
}
else if((value>=1159999) && (value1<=1162999))
{
jean=13.8;
}
else if((value>=1158500) && (value1<=1159997))
{
jean=13.9;
}
else if((value>=1157500) && (value1<=1158499))
 {
jean=13.9;
}
else if((value>=1156500) && (value1<=1157499))
{
jean=14.0;
}
else if((value>=1155000) && (value1<=1156499))
{
jean=14.1;
}
else if((value>=1153500) && (value1<=1154999))
 {
jean=14.2;
}
else if((value>=1151500) && (value1<=1152500))
{
jean=14.3;
}
else if((value>=1150500) && (value1<=1151499))
{
jean=14.4;
}
else if((value>=1149880) && (value1<=1150499))
{
jean=14.5;
}
else if((value>=1144000) && (value1<=1149870))
{
jean=14.6;
}
else if((value>=1143000) && (value1<=1143999))
{
jean=14.7;
}
else if((value>=1141800) && (value1<=1142999))
{
jean=14.8;
}
else if((value>=1141500) && (value1<=1141799))
 
{
jean=14.9;
}
else if((value>=1142600) && (value1<=1143499))
 {
jean=15.0;
}
else if((value>=1141500) && (value1<=1142599))
{
jean=15.1;
}
else if((value>=1140400) && (value1<=1141499))
{
jean=15.2;
}
else if((value>=1139600) && (value1<=1140399))
{
jean=15.3;
}
else if((value>=1138560) && (value1<=1139599))
{
jean=15.4;
}
else if((value>=1137500) && (value1<=1138559))
{
jean=15.5;
}
else if((value>=1136500) && (value1<=1137499))
{
jean=15.6;
}
else if((value>=1135500) && (value1<=1136499))
{
jean=15.7;
}
else if((value>=1134500) && (value1<=1135499))
{
jean=15.8;
}
else if((value>=1133500) && (value1<=1134499))
{
jean=15.9;
}
else if((value>=1129999) && (value1<=1133499))
{
jean=16.0;
}
else if((value>=1128500) && (value1<=1129998))
{
jean=16.1;
}
else if((value>=1127500) && (value1<=1128499))
{
jean=16.2;
}
else if((value>=1127500) && (value1<=1127499))
{
jean=16.3;
}
else if((value>=1123500) && (value1<=1124998))
{
jean=16.4;
}
 if((value>=1122500) && (value1<=1123499))
{
jean=16.5;
}
else if((value>=1121500) && (value1<=1122499))
{
jean=16.6;
}
else if((value>=1119950) && (value1<=1121499))
{
jean=16.7;
}
else if((value>=1118500) && (value1<=1119949))
{
jean=16.8;
}
else if((value>=1117500) && (value1<=1118499))
{
jean=16.9;
}
else if((value>=1116500) && (value1<=1117499))
{
jean=17.0;
}
else if((value>=1115000) && (value1<=1116499))
{
jean=17.1;
}
else if((value>=1113500) && (value1<=1114999))
{
jean=17.2;
}
else if((value>=1112000) && (value1<=1113499))
{
jean=17.3;
}
else if((value>=1110500) && (value1<=1111999))
{
jean=17.4;
}
 if((value>=1108000) && (value1<=1109000))
{
jean=17.5;
}
else if((value>=1106500) && (value1<=1107999))
 {
jean=17.6;
}
else if((value>=1105200) && (value1<=1106499))
{
jean=17.7;
}
else if((value>=1103500) && (value1<=1105199))
{
jean=17.8;
}
else if((value>=1102500) && (value1<=1103499))
{
jean=17.9;
}
else if((value>=1101000) && (value1<=1102499))
{
jean=18.0;
}
if((value>=1099799) && (value1<=1100999))
{
jean=18.1;
}
else if((value>=1098500) && (value1<=1099798))
{
jean=18.2;
}
else if((value>=1097500) && (value1<=1098499))
{
jean=18.3;
}
else if((value>=1096400) && (value1<=1097499))
{
jean=18.4;
}
else if((value>=1095200) && (value1<=1096399))
{
jean=18.5;
}
else if((value>=1094000) && (value1<=1095199))
{
jean=18.6;
}
else if((value>=1092500) && (value1<=1093999))
{
jean=18.7;
}
else if((value>=1091500) && (value1<=1092499))
{
jean=18.8;
}
if((value>=1090000) && (value1<=1091499))
{
jean=18.9;
}
else if((value>=1088500) && (value1<=1089999))
{
jean=19.0;
}
else if((value>=1087500) && (value1<=1088499))
{
jean=19.1;
}
else if((value>=1086200) && (value1<=1087499))
{
jean=19.2;
}
 if((value>=1085000) && (value1<=1086199))
{
jean=19.2;
}
else if((value>=1082000) && (value1<=1084999))

{
jean=19.3;
}
else if((value>=1080000) && (value1<=1081999))
{
jean=19.4;
}
else if((value>=1078500) && (value1<=1079999))
{
jean=19.5;
}
else if((value>=1077500) && (value1<=1078499))
{
jean=19.6;
}
else if((value>=1076500) && (value1<=1077499))
{
jean=19.7;
}
else if((value>=1075900) && (value1<=1076499))
{
jean=19.8;
}
else if((value>=1075860) && (value1<=1075899))
{
jean=19.9;
}
else if((value>=1075830) && (value1<=1075859))
{
jean=20.0;
}
else if((value>=1074820) && (value1<=1075829))
{
jean=20.1;
}
else if((value>=1073500) && (value1<=1074819))
{
jean=20.2;
}
else if((value>=1072500) && (value1<=1073499))
{
jean=20.3;
}
else if((value>=1071200) && (value1<=1072499))
{
jean=20.4;
}
else if((value>=1070000) && (value1<=1071199))
{
jean=20.5;
}
else if((value>=1068500) && (value1<=1069999))
{
jean=20.6;
}
else  if((value>=1067200) && (value1<=1068499))
 {
jean=20.7;
}
else if((value>=1066100) && (value1<=1067199))
{
jean=20.8;
}
else if((value>=1065000) && (value1<=1066099))
{
jean=20.9;
}
else if((value>=1063200) && (value1<=1064999))
 {
jean=21.0;
}
else if((value>=1062400) && (value1<=1063199))
{
jean=21.1;
}
else if((value>=1061300) && (value1<=1062399))
{
jean=21.2;
}
else if((value>=1061000) && (value1<=1061299))
{
jean=21.3;
}
else if((value>=1060000) && (value1<=1060999))
{
jean=21.4;
}
else if((value>=1058000) && (value1<=1059999))
{
jean=21.5;
}
else if((value>=1056000) && (value1<=1057999))
{
jean=21.6;
}
else if((value>=1055000) && (value1<=1055999))
{
jean=21.7;
}
else if((value>=1054000) && (value1<=1054999))
{
jean=21.8;
}

else if((value>=1053000) && (value1<=1053999))
{
jean=21.9;
}
else if((value>=1051950) && (value1<=1052999))
{
jean=22.0;
}
else if((value>=1051500) && (value1<=1051949))
{
jean=22.1;
}
 if((value>=1050000) && (value1<=1051499))
{
jean=22.2;
}
//if((value1>=1048500) && (value1<=1049999))
//{
//jean=22.3;
//}
 else if((value1>=1047000) && (value1<=1048499))
{
jean=22.4;
}
 else if((value1>=1045500) && (value1<=1046999))
{
jean=22.5;
}
else if((value1>=1044000) && (value1<=1045499))
{
jean=22.6;
}
else if((value1>=1042500) && (value1<=1043999))
{
jean=22.7;
}
else if((value1>=1041200) && (value1<=1042499))
{
jean=22.8;
}
else if((value1>=1040000) && (value1<=1041199))
{
jean=22.9;
}
else if((value1>=1038500) && (value1<=1039999))
{
jean=23.0;
}
else if((value1>=1037000) && (value1<=1038499))
{
jean=23.1;
}
else if((value1>=1035500) && (value1<=1036999))
{
jean=23.2;
}
else if((value1>=1034000) && (value1<=1035499))
{
jean=23.3;
}
else if((value1>=1032000) && (value1<=1033000))
{
jean=23.4;
}
else if((value1>=1030000) && (value1<=1031999))
{
jean=23.5;
}
else if((value1>=1028999) && (value1<=1029999))
{
jean=23.6;
}
else if((value1>=1027500) && (value1<=1028998))
{
jean=23.7;
}
else if((value1>=1026500) && (value1<=1027499))
{
jean=23.8;
}
else if((value1>=1026000) && (value1<=1026499))
{
jean=23.9;
}
else if((value1>=1025000) && (value1<=1025999))
{
jean=24.0;
}
else if((value1>=1024000) && (value1<=1024999))
{
jean=24.1;
}
else if((value1>=1022500) && (value1<=1023999))
{
jean=24.2;
}
 else if((value1>=1021500) && (value1<=1022499))
{
jean=24.3;
}
 else if((value1>=1021000) && (value1<=1021499))
{
jean=24.4;
}
 else if((value1>=1020000) && (value1<=1020999))
{
jean=24.5;
}
 else if((value1>=1018500) && (value1<=1019999))
{
jean=24.6;
}
 else if((value1>=1018200) && (value1<=1018499))
{
jean=24.7;
}
  else if((value1>=1018000) && (value1<=1018199))
{
jean=24.8;
}
else if((value1>=1017500) && (value1<=1017999))
 {
jean=24.9;
}
else if((value1>=1017000) && (value1<=1017499))
{
jean=25.0;
}
else if((value1>=1016500) && (value1<=1016999))
{
jean=25.1;
}
else if((value1>=1016000) && (value1<=1016499))
{
jean=25.2;
}
else if((value1>=1015500) && (value1<=1015999))
 {
jean=25.3;
}
else if((value1>=1015500) && (value1<=1015999))
 {
jean=25.4;
}
 else if((value1>=1014500) && (value1<=1014999))
{
jean=25.5;
}
else if((value1>=1014000) && (value1<=1014499))
{
jean=25.6;
}
else if((value1>=1013500) && (value1<=1013999))
{
jean=25.7;
}

else if((value1>=1012500) && (value1<=1012999))
{
jean=25.9;
}
  else if((value1>=1012000) && (value1<=1012499))
{
jean=26.0;
}
 else if((value1>=1013000) && (value1<=1013499))
{
jean=25.8;
}
else
{
printf(lcd_putc,"\fLoad 165");
delay_ms(1500);
}*/
 
Last edited by a moderator:

You need to start with where the numbers come from in the first place (assuming they aren't random). Interpolation reduces table sizes. I recently did a 16 bit lookup table (65536 effective values) using two 64 variable tables and two stage interpolation which needed two case statements - one with 8 values, one with 16 (by splitting the numbers into parts). This was in a PIC12LF1822 and had room to spare.

Keith

- - - Updated - - -

Maybe search for information on look-up tables and interpolation.

http://en.wikipedia.org/wiki/Lookup_table
http://en.wikipedia.org/wiki/Interpolation
 

What math have you done to get those values for the variable "jean"? If you can reproduce the math in the PIC programming then you may not need all those if/else statements.
 

What math have you done to get those values for the variable "jean"? If you can reproduce the math in the PIC programming then you may not need all those if/else statements.
Those numbers come from the T1CKI of PIC16F877A they correspond to the frequency read and then I used to take decisions ,the problem I have is that whith those if...else.......if statement the CCS C compiler says that the program is out of the range.
Memory is full ;that is why I am asking my self how I can use the external EEPROM for executing those codes easily.

Thx
 

You need to define the relationship between the input and output numbers - the relationship must have come from somewhere. If it isn't linear then you need to decide between a look-up table with interpolation or curve fit an equation to the relationship - a quadratic equation is often enough.

Keith
 

You need to define the relationship between the input and output numbers - the relationship must have come from somewhere. If it isn't linear then you need to decide between a look-up table with interpolation or curve fit an equation to the relationship - a quadratic equation is often enough.

Keith

That is what is the problem for me,so help me with it.
A look up table can be done but how will I decide easily with if else if statements and reduce the program size??
 

You either need to go back to basics (i.e. where did the numbers come from) or simply put them in a spreadsheet and "look" at the relationship. Then look up on curve fitting https://en.wikipedia.org/wiki/Curve_fitting A simple quadratic equation is often good enough.
Keith.

not going in those mathematics which should be more difficult comparing to what I have now,can you plz show me how to find index of any number in array.

Thx
 

C arrays are explained fairly enough everywhere, here's an example:
https://www.cplusplus.com/doc/tutorial/arrays/

I understood that the frequency read from the T1CKI is dynamic. But what do you need that "jean" variable for? Do you use the "jean" variable to have some kind of error correction or what? Maybe some other simple math can be used to achieve the same result in less code without all those if/else statements. It's impossible you can't make a relationship between those numbers you check for and the "jean" variable scope. Please tell us what's the task for it, what you're trying to achieve and we'll help you finding a better solution.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top