This Forum is Dedicated For all The Object Oriented PIC Lovers .......... The concept behind OOPic is straight forward. Use preprogrammed multitasking Objects from a library of highly optimized Objects to do all the work of interacting with the hardware. Then write small scripts in Basic, C, or Java syntax styles to control the Objects. During operation, the Objects run continuously and simultaneously in the background while the scripts run in the foreground telling the objects what to do.

Sunday, December 2, 2007

[oopic] Weird Program Behavior

Hello,

I have crafted a partial program here that is not working. The
program is getting messed up during calculateSteps method as the
number of steps is never printed to lcd after calling calculateSteps.
The weird thing is, I copied the calculateSteps method out of another
program that worked flawlessly. The only difference between the two
programs is the use of the LCD in this one. Why does the
calculateSteps method never work (by the way "distance" is a number
between 500 and 1000 inputed by user. I have confirmed that this is
indeed the input received.) Thanks in advance for any help. I am
using compiler 6.1.1 oopic-r c1.x+


oDIO1 IO1 = New oDIO1;
oDIO1 IO2 = New oDIO1;
oDIO1 IO3 = New oDIO1;

oWire IOWIRE = New oWire;
oWire startInputWIRE = New oWire;

oDIO1 startInput = New oDIO1;

oSerialX lcd = New oSerialX;

oWord cvStepSize = New oWord(9975);
oWord cvStepAdjuster = New oWord(5013);
oWord cvSteps = New oWord;

oWord distance = New oWord;

Void Main(Void){
Delay = 1000;
oBit adv = New oBit;

lcd.IOLineS = 16;
lcd.Baud = cv9600;
lcd.Operate = 1;
lcd.String = "?f";
lcd.String = "?3"
lcd.String = "Advanced Config"
lcd.String = "??"

IO1.IOLine = 5;
IO2.IOLine = 6;
IO3.IOLine = 7;

IO1.Direction = cvOutput;
IO2.Direction = cvInput;
IO3.Direction = cvInput;

Do {
If(IO3.State == cvTrue)
adv = 1;
} While (adv == 0 And IO2.State == cvFalse);
Do{
}While (IO2.State == cvTrue);
lcd.String = "?f"
lcd.String = "Enter Distance: "
lcd.String = ">";

oByte count = New oByte;
distance = 0;

For (Byte x = 100; x > 0; x = x/10) {
count = 0;
Do {
If (IO3.State == cvTrue) {
Do {
} While (IO3.State == cvTrue);
count++;
}
} While (IO2.State == cvFalse);
Do{
}While (IO2.State == cvTrue);
distance = distance + count * x;
}

lcd.String = "?f";
lcd.String = "Distance: ";
lcd.String = Str$(distance);

lcd.String = "Steps: "; // PRINTING DISTANCE HERE WORKS
calculateSteps; // I DO NOT KNOW WHAT HAPPENS HERE
lcd.String = Str$(cvSteps); // NOT PRINTING
}

Void calculateSteps(Void) {
oWord word1 = New oWord;
oWord word2 = New oWord;
word1 = (distance - 500) * 100; // PRINTING OUT word1 HERE RETURNS
0 FOR UNKNOWN REASON
word2 = (word1 Mod cvStepSize) / 10;
word1 = word1/cvStepSize; // NOT SURE IT EVER EVEN EXECUTES THIS
AREA OF CODE
cvSteps = word1 * 1000;
cvSteps = cvSteps + word2 + cvStepAdjuster;
}


Yahoo! Groups Links

<*> To visit your group on the web, go to:

http://groups.yahoo.com/group/oopic/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:

http://groups.yahoo.com/group/oopic/join

(Yahoo! ID required)

<*> To change settings via email:
mailto:oopic-digest@yahoogroups.com
mailto:oopic-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
oopic-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:

http://docs.yahoo.com/info/terms/

No comments: