NXT motor: use as an encoder with removed motor?

Discussion specific to the intelligent brick, sensors, motors, and more.
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

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

Post 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).
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

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

Post 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?
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

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

Post 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 )
mightor
Site Admin
Posts: 1079
Joined: 25 Sep 2010, 15:02
Location: Rotterdam, Netherlands
Contact:

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

Post 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
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

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

Post 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?
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

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

Post 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!
;)
cghaning
Posts: 9
Joined: 30 Sep 2010, 03:39

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

Post 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.
philoo
Posts: 76
Joined: 29 Sep 2010, 09:04
Location: Paris, France
Contact:

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

Post 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.
Philo
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

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

Post by mattallen37 »

Here are a couple pictures you may find useful:
NXT motor encoder with tetrix.JPG
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

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

Post 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.
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 0 guests