Motorencoder Values on display
Page 1 of 1

Author:  JPWingman [ Fri Mar 21, 2008 6:42 am ]
Post subject:  Motorencoder Values on display

Hi there,

lately I have had some problems with the Values shown on my display of my NXT. I wrote a programm in which 2 motors should follow the first motor, which I turned myself during the program. The values from the motorEncoders should be shown on the display.

Now the problem is that at the beginning the values are all right, but when I turn the motor back from 100 to 90 degrees, the display at first shows 100 and then 900. I guess that 900 is supposed to mean 90, but why is the additional 0 stilll standing there.
I admitt that I am just getting started to use a display, so is there anybody, who could help?

this is the code that should show the Encodervalues on the display

string x = nMotorEncoder[motorA];
     string y = nMotorEncoder[motorB];
     string z = nMotorEncoder[motorC];

                nxtDisplayString(1, x , x);
      nxtDisplayString(2, y , y);
      nxtDisplayString(3, z , z);

post deciamal positions could be helpful, I guess.
The values are supposed to help me debugging an other problem.

Author:  Ford Prefect [ Fri Mar 21, 2008 7:00 am ]
Post subject: 

probier's doch mal so:
int x,y,z;
x = nMotorEncoder[motorA];
y = nMotorEncoder[motorB];
z = nMotorEncoder[motorC];

nxtDisplayTextLine(1, "x= %5d", x);
nxtDisplayTextLine(2, "y= %5d", y);
nxtDisplayTextLine(3, "z= %5d", z);

nxtDisplayString(nLineNumber, sFormatString, parm1, parm2);

wird am Schluss nicht mit Leerzeichen aufgefüllt, daher bleiben "alte" zeichen stehen.
nxtDisplayTextLine(nLineNumber, sFormatString, parm1, parm2);

wird die gesamte Zeile immer neu geschrieben und am Ende mit Leerzeichen aufgefüllt, dann sieht immer alles "sauber" aus.

weil das aber so unmöglich kompliziert und langwierig zu schreiben ist, definiere ich mir immer
#define println nxtDisplayTextLine

und schreib dann künftig nur noch
println(3, "z= %5d", z);   

Author:  JPWingman [ Fri Mar 21, 2008 9:54 am ]
Post subject: 

jo, danke nochma und für den rat aus der anderen nachricht

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group