2

I'm helping some fellow Bay Area LEGO User Group builders who want to use an EV3 to power a 9V train. I'm using the NXT to 9V conversion cable (https://www.bricklink.com/v2/catalog/catalogitem.page?P=x1676) with the old 9V metal train track connectors (https://www.bricklink.com/v2/catalog/catalogitem.page?P=5306c01&C=0#T=C&C=0) and the Unregulated Motor (UM) block in EV3=G.

My first test was to have the train travel one second in one direction then one second in the opposite direction in an infinite loop. The results were fine with the train going in the direction that used a negative power in the UM block, but either no motion or shaky motion in the direction that used positive power values.

I tested the track with a multi-meter and verified that the power was only consistent and steady when using the negative power.

On this site I found an interesting answer describing what is probably happening: Using the unregulated motor block and conversion cable to light LEDs But that answer is only partly applicable -- I found that if I put a one second Wait block between power changes, then the power is consistent. But different!

So a power setting of +40% for one second moves the train one track segment, while a power setting of -40% for one second moves the train three track segments. It looks like I can generate a workable program, but I'm curious about why this behavior is happening, and if there will be other surprises.

1

The answer is basically the same as the LED question that you linked. On the EV3 output ports, pin 2 is internally connected to pin 6. So, when you tell a motor to go in reverse (negative power value), pin 2 is powered, which in turn raises the voltage on pin 6. Both pins 5 and 6 are used for automatically detecting when a motor is connected.

So, when you use a negative power setting, most of the time (but not 100% of the time), it it will trick the EV3 into thinking there is a motor connected and the motor will stay powered. However, when you use a positive power setting, pin 1 is powered instead of pin 2, so the EV3 thinks that there is no motor connected (because nothing happens to pin 5 or pin 6). So, in this case, the device connection manager in the EV3 software takes over and resets the motor port, which causes it to stop sending power to the motor.

I attached an oscilloscope to pins 1 and 2, to see what is going on.

oscilloscope showing EV3 output port pins 1 and 2

As you can see, the output is only turned on for 380ms, then it turns itself off. The motor was instructed to run indefinitely, but in reality, this is not what happens.

Since your test involved running the motor for 1s but it really only runs for 380ms, one would expect the car to run 38% of the distance as in the reverse case. You observation was 33% (one track length vs. 3), so that is quite close to what is expected.

As a workaround, you can Use the Unregulated motor block in a loop like this...

enter image description here

It is important to use two different "power" values. Each time you change the value, it turns on the output port again. If you use the same value, the software won't update the motor port and the device connection manager will take over and turn off the output.

  • Appreciate the thorough analysis and solution. I've forwarded this info to the MOC designers. You can see their work starting on page 34 of the 50th issue of BrickJournal. I've got the digital version; the hardcopy version hasn't arrived yet. Your help will be incorporated into whatever they've got planned for Bricks By the Bay 2018. I'll try to post a video after the convention in July 2018. Thank you! – Walt White Apr 12 '18 at 4:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.