display value from another object
charleyshf
Posts: 165
Hello,
I've been working on an object that basically controls a motor controller, now what I have done so far is I am creating another object to get results from the motor controller object, I am not getting the results that I thought I would.
From the motor controller object:
The new object I am working on I am trying to get the above x result by doing the following:
Like I said above the result is not what I expected at all. I'd appreciate any help
thanks
I've been working on an object that basically controls a motor controller, now what I have done so far is I am creating another object to get results from the motor controller object, I am not getting the results that I thought I would.
From the motor controller object:
PUB GetBattery | i serial.RXflush serial.tx(128) serial.tx(24) repeat i from 0 to 2 x[i] := Serial.rx 'receive 3 characters x[3] := 0 'set last character to zero to mark end of string Return x
The new object I am working on I am trying to get the above x result by doing the following:
PST.Dec(MOTOR.GetBattery)
Like I said above the result is not what I expected at all. I'd appreciate any help
thanks
Comments
Then
Return X returns 0 or x[0]
Is x[0] that the index you expect?
x[0] is the index that I am trying to get, however the result is always 0, the result is always a different number(voltage monitor on the motor controller)
Why do you do this x[3] := 0?
What is in X[0] a number or a string?
the x[3] was because the motor controller is controlled by serial and in the beginning I was just using a single object to display the results of commands that I sent to the motor controller via PST(so the last byte had to be 0) now that I have motor controller as it's own object I am trying to get another object to display the value by using:
PST.Dec(MOTOR.GetBattery)
My old code for this method looked like this:
the x[0] I thought was the result of what serial.rx got for each byte
Sorry about that, I think I was trying to add the bytes together....
John Abshier