View unanswered posts | View active topics It is currently Mon Sep 21, 2020 12:30 am

Reply to topic  [ 3 posts ] 
Motorencoder Values on display 
Author Message

Joined: Mon Mar 10, 2008 5:03 pm
Posts: 5
Post 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.

Fri Mar 21, 2008 6:42 am
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
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);   

HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}

Fri Mar 21, 2008 7:00 am

Joined: Mon Mar 10, 2008 5:03 pm
Posts: 5
jo, danke nochma und für den rat aus der anderen nachricht

Fri Mar 21, 2008 9:54 am
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.