Only lowest Cortex motor port working.

I have a Cortex microcontroller that has passed the warranty period but remained unused until now.

My problem is that only the lowest motor port equipped with a good VEX motor receives any power & any higher port equipped with a good VEX motor receives nothing. I have tested this out with 2 known good motors & motor controllers in a variety of port configurations & the results are always as stated above. My battery is fully charged, there is no loads on the motors, my firmware is up to date, & I’m using a USB-USB connection with ROBOTC. Nothing else is plugged into the Cortex. Exchanging the 2 motors & motor controllers with each other always results in the lowest port motor operating while the other remains dead. I have searched the forum for answers but find nothing like this posted. Please help.

Grandpa3,

Just to confirm:
Ports 1-9>> have no output
Port 10>> OK

If that the case, I recommend you to re-download default code into the Cortex.
Also make sure you are using Motor Controllers in all the 3-wire motor ports.

-Eli

All ports are INDIVIDUALLY operable. Only occurs when I try a second or third motor. As I stated I have used motor controllers in all appropriate ports.

Not sure I understand the use of the term “default code”. I have downloaded the Master code & ROBOTC code again if that’s what you mean. Problem still persists.

Grandpa3,

The default code for ROBOTC is listed under sample programs as “ROBOTC VEX Cortex Default”
Please download the default code and let me know your results, see attachment for reference.

_Eli
Doc1.pdf (233 KB)

Eli

Thanks for your patience with me & your quick responses.

I’ve never used this program nor are there any remarks in it to give me a clue as to what it does. Thanks to you I did find it, did compile & download it, & ran it. Nothing happend. I only have 2 - 393 motors connected to ports 2 & 3 with motor contollers for each. I have nothing else plugged in except a charged battery & my USB-USB cable. Wasn’t sure what to expect but when nothing happend I compiled & downloaded my simple testing program

#pragma config(UART_Usage, UART2, uartNotUsed, baudRate4800, IOPins, None, None)
#pragma config(Motor, port2, test2, tmotorVex393, openLoop)
#pragma config(Motor, port3, test3, tmotorVex393, openLoop)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//

task main()
{
while(true)

motor[test3] = 60;
motor[test2] = 60;

}

When I run this now the higher port 3 motor runs but not the one on port 2. If I remark out the line motor[test3]…, recompile, download, & run the motor on port 2 works fine. Seems like loading the default code caused the problem to be reversed. I’m trying to give you as complete & accurate information as I have but my knowledge in this situation is limited. Thanks for your continued assistance.

Grandpa3

Grandpa3,

The default code will control all ten motor ports per the inputs on the Joystick.
Please re-download the default code and try steps 1, 2 & 3a of the following guide: http://content.vexrobotics.com/docs/VEXnet_Cortex_UserGuide_081811.pdf
Let me know your results.

-Eli

Eli

Okay, I followed your instructions & did the test in part 3a. Both motors operated per the joystick movement except they operated in the reverse directions from what the instructions indicated…CW when supposed to be CCW & CCW when supposed to be CW. In other words port 2 went CCW & port 5 went CW. It was interesting that when I pushed both joysticks 2 & 3 BOTH motors worked.

Trying my original simple 2 motor test program continuing to use ports 2 & 5 ends up with the same ORIGINAL problem where only motor 2 works OR motor 5 works when motor 2 is REM’d out.

So what does this tell us? I’m very confused!!!

Grandpa3,

Glad to hear you system works with the default code.
In order to switch the spin direction on your motors all you have to do is reverse the connections between the motor and the motor controller 29.
See attachment.

I will move your post into the ROBOTC forum as they will be able to analyse your code.

-Eli
Motor Controller Connection.jpg


task main()
{
while(true)

motor[test3] = 60;
motor[test2] = 60;

}

The problem with this code is that there are no opening or closing braces on the while loop. While loops, if statements, and for loops need opening and closing braces to ‘contain’ the code that should be run while the condition is true; otherwise, ROBOTC would have no way of knowing what could should be run in a loop or if statement, and which code shouldn’t. By default, using a while loop, if statement, or for loop without any braces will only contain the very next line of code it encounters; in this case, the test3 motor command. When you comment it out, it gets ignored by the program flow and the next valid line of code becomes the test2 motor command.

To fix this problem, simply encapsulate whatever code you want to be run by a loop inside of an opening and closing brace:


task main()
{
while(true)
{
motor[test3] = 60;
motor[test2] = 60;
}
}

John & Eli

For goodness sake I am so embarrassed for this simple mistake in programing that I thought sure to be a hardware malfunction.:o I truely appreciate your patience with me & thank you very very much. I did learn many things in this process & will strive to do a better analysis before I call out for help again.

Again, my thanks to you both.

Grandpa3