Page 5 of 6

Re: NXT motor: use as an encoder with removed motor?

Posted: 07 Apr 2011, 08:35
by mattallen37
According to the RCX rotation sensor schematic, it should be very possible to make it work with the NXT motor port. However, you would need to do some hacking with some pretty tiny parts.

Another option that is related to this concept, is the idea of using a mechanical encoder (probably very low resolution).

Re: NXT motor: use as an encoder with removed motor?

Posted: 07 Apr 2011, 08:40
by mattallen37
Just so I understand properly, you have gotten the NXT to run the tetrix controller, but you are not able to read the encoder values back?

Re: NXT motor: use as an encoder with removed motor?

Posted: 07 Apr 2011, 09:04
by HaWe
you mean what I can do with the Tetrix controller?

with the Hitechnic Tetrix controller (attached to a NXT sensor port)
- I can start and stop 2 Tetrix motors in power percentage mode
- I can read a Tetrix encoder value when the motors are stopped and no I2C calls are done since a few seconds.
- I can not read Tetrix encoder values when the motors are running, in this case the system hangs completely after a few seconds (NXT blocks and has to be rebooted, batteries have to be removed intermediately )

Re: NXT motor: use as an encoder with removed motor?

Posted: 07 Apr 2011, 10:11
by mightor
doc-helmut wrote: - I can not read Tetrix encoder values when the motors are running, in this case the system hangs completely after a few seconds (NXT blocks and has to be rebooted, batteries have to be removed intermediately )
That sounds more like a software problem than a controller issue.

- Xander

Re: NXT motor: use as an encoder with removed motor?

Posted: 07 Apr 2011, 10:20
by mattallen37
I have to agree with Xander, it is almost definitely a timing issue. IIRC, the manual refers to a few second period that is a timeout. It is a safety feature that keeps the motors from running forever if the NXT stops sending commands (as if the NXT program stopped when the motors were running).

Did you try adding wait functions to the program? Are you waiting until the bus is free before attempting to read or write?

Re: NXT motor: use as an encoder with removed motor?

Posted: 07 Apr 2011, 12:47
by HaWe
I think it's a firmware issue because I have tried a lot of waits() up to 100ms and even more between each of the I2C commands - no way reading the encoders while the motors are commanded to run and stop intermediately. And of course (!!) I waited till i2cbus=ready or =no error before sending a new command!!
edit: to be more precisely: From the start the encoder values actually CAN be read while simultaneously commanding the motors, even rather quickly with only 5msec Wait() in between - but after 5-10 sec the whole program hangs up, freezes and must be rebootet. Or from time to time (randomly) the motors just keep on going although they should have stopped already long - or the are keeping idle although they already should have been running already long. And after a while the program freezes anyway. It has nothing to do at all with safety-timeouts: All is fine with the motors if I don't read their encoders intermediately/simoultaneously.

We've been discussing this issue already lots of times and no other commands than those (actually very simple and clear ones) that I already got are available. Nevertheless they apply 100% to the I2C commands table published by Hitechnic.
I sacrificed ths issue meanwhile and it's not the issue of this topic . (You're definetly not forbidden to read about it at the related threads and discuss it THERE - suggestions appreciated! The complete Tetrix test code is already published in the other threads!)

But getting a NXT encoder running without motor at the motor ports (either a NXT motor without motor, or a RCX rotation sensor) - or both a NXT motor and a Tetrix motor with an op amp altogether - is on-topic and I'll be glad to read some solutions HERE.

Thanks for contributing!
;)

Re: NXT motor: use as an encoder with removed motor?

Posted: 01 May 2011, 18:49
by cghaning
I have used an external encoder that works off the Lego Motor Port. Check out https://sites.google.com/site/encodernxt/ for a write up I did some time ago.

It is a regular encoder manufactured by CUI that just happens to match up almost perfectly with Lego technic beams and axles. The best part is it has much higher resolution (up to 4096 counts per rev) vs. the Lego 360 counts per rev. In fact (or someone correct me if I'm mistaken), any 5V TTL encoder would work connected on the Lego Motor Port.

As an aside -- The encoder counting is done via interrupt routines on the NXT brick, that is why it can handle higher resolution encoders -- but there is some physical limit (encoder counts per second) that will cause a loss of encoder counts AND / OR cause the program execution time to increase and I have no idea what that limit is!

-Charlie H.

Re: NXT motor: use as an encoder with removed motor?

Posted: 02 May 2011, 07:33
by philoo
cghaning wrote:It is a regular encoder manufactured by CUI that just happens to match up almost perfectly with Lego technic beams and axles.
A very interesting device you found, and not too expensive. One little down side is that it is 1mm too thick for LEGO...
In fact (or someone correct me if I'm mistaken), any 5V TTL encoder would work connected on the Lego Motor Port.
Any should work indeed.

Re: NXT motor: use as an encoder with removed motor?

Posted: 22 May 2011, 19:09
by mattallen37
Here are a couple pictures you may find useful:
NXT motor encoder with tetrix.JPG

Re: NXT motor: use as an encoder with removed motor?

Posted: 22 May 2011, 21:44
by HaWe
thank you, I know these pictures, and of course I would attach the Lego "motors" as encoders (without motors ) exactly this way. But with motors still in the housings the friction is too strong.