Help with coding

  1. 2 weeks ago
    Edited 2 weeks ago by Masterchief24

    Our code is this, But for some reasons our code won't work 100% the arm movement and the drive will not work but the claw movement is the only thing that works, How can we fix this?
    armplusdrivecode.c

    #pragma config(Motor,  port1,           armR,          tmotorVex393_HBridge, openLoop)
    #pragma config(Motor,  port2,           right1,        tmotorVex393_MC29, openLoop)
    #pragma config(Motor,  port3,           right2,        tmotorVex393_MC29, openLoop)
    #pragma config(Motor,  port4,           right3,        tmotorVex393_MC29, openLoop)
    #pragma config(Motor,  port5,           left1,         tmotorVex393_MC29, openLoop)
    #pragma config(Motor,  port6,           left2,         tmotorVex393_MC29, openLoop)
    #pragma config(Motor,  port7,           left3,         tmotorVex393_MC29, openLoop)
    #pragma config(Motor,  port8,           clawR,         tmotorVex393_MC29, openLoop, reversed)
    #pragma config(Motor,  port9,           clawL,         tmotorVex393_MC29, openLoop)
    #pragma config(Motor,  port10,          armL,          tmotorVex393_HBridge, openLoop)
    //*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//
    
    task main()
    {
    	while(1==1)
    	{
    		//right side
    		motor[right1]=vexRT[Ch3]/-1;
    		motor[right2]=vexRT[Ch3]/-1;
    		motor[right3]=vexRT[Ch3]/-1;
    
    		//left side
    		motor[left1]=vexRT[Ch2]/1;
    		motor[left2]=vexRT[Ch2]/1;
    		motor[left3]=vexRT[Ch2]/1;
    
    		//arm up and down
    		if (vexRT[Btn6U] == 1)
    		{
    			startMotor(armL,127);
    			startMotor(armR,127);
    		}
    		else if (vexRT[Btn6D] == 1)
    		{
    			startMotor(armL,-127);
    			startMotor(armR,-127);
    		}
    		else
    		{
    		stopMotor(armL);
    		stopMotor(armR);
    		}
    
    	//claw up and down
    		if (vexRT[Btn5U] == 1)
    		{
    			startMotor(clawL,127);
    			startMotor(clawR,127);
    		}
    		else if (vexRT[Btn5D] == 1)
    		{
    			startMotor(clawL,-127);
    			startMotor(clawR,-127);
    		}
    		else
    		{
    			stopMotor(clawL);
    			stopMotor(clawR);
    		}
    	}
    }

    *Edit*
    The code doesn't work nothing is working.

    @Got a Screw Loose
    It's been solved
    we think the weight of our double reverse 4 bar is too heavy so we are adding extra motors to help lift it up.

  2. Maybe try putting the actions in different tasks? Also, I don't see the point in dividing your joystick values. Shouldn't be causing your problems, but it might be. If it's to reverse the polarity of the motors, I usually just switch around the 2 wire connections.

    I'm not a coding wizard, but Ibalways use seperate tasks to control each function on the robot. Could also be that you need to do a firmware download and then try again.

    Also, change the pragma comment from "'ROBOTC' CONFIGURATION WIZARD" to "'HARRY' CONFIGURATION WIZARD."
    I think the robot likes it. Or it's just me.

    Could someone confirm that's it's okay to have numbers in your motor names? Sonething tells me it's not, but I'm not sure. Might want to switch your motor names to "rightOne" instead of "Right1" and see if that works.

  3. James6555

    Nov 29 68357A

    It’s fine to have numbers in motor names (we do)

  4. callen

    Nov 29 Braintree, MA, USA

    Have you confirmed the port numbers are correct? Are you sure the arm motors should be spinning in the same direction instead of opposite like the drivetrain? Are you sure all the motors and motor controllers work? Have you tested each individually? If things are attached together and one motor trying to sit still while the other(s) are trying to move, or if they're attached and they're trying to go opposite, fighting each other in such ways could make nothing seems to work even if almost all of it is working.

  5. @callen
    All things have been tested. And i will see to the opposite value possibility.

  6. Andrew9635b

    Nov 29 Charlotte, NC 9635

    you don't need

    while(1==1)

    just

    while(1) 

    or

    while()

    will work. (For if() statements as well)

  7. I don't know but I could give what y 'all need in graphical.

  8. Edited 2 weeks ago by Masterchief24

    @Andrew9635b
    @callen
    @James6555
    @Got a Screw Loose
    The code currently does not work. Nothing of it is working anybody know how to fix it?

  9. Edited 2 weeks ago by Got a Screw Loose

    So the claw movement stopped working? Are some ports fried?

  10. callen

    Nov 30 Braintree, MA, USA

    I had the same thought as @Got a Screw Loose . If you haven't changed the code and the claw has stopped working, then there is something off elsewhere. Have you tried using an entirely different Cortex?

  11. Deleted 2 weeks ago by vexScout
  12. Edited 2 weeks ago by langchen
    1. lift your robot so that the wheels can spin freely. manually spin the wheels, all the wheels should move in one direction without much effort.
    2. unplug right 1-3 and left 2-3 with only left 1 plug in the cortex
    3. test from you joystick to see if the left 1 spins and at what direction. if do not spin, check your motor left 1 and motor controller.
    4. do the same thing (2-3) for the right 1-3 and left 2-3.
  13. Edited 2 weeks ago by Got a Screw Loose

    @langchen 1. lift your rob so that the wheels can spin freely.

    1. unplug right 1-3 and left 2-3 with only left 1 plug in the cortex
    2. test from you joystick to see if the left 1 spins and at what direction. if do not spin, check your motor left 1 and motor controller.
    3. do the same thing (2-3) for the right 1-3 and left 2-3.

    I got slightly confused by “rob,” but now I see that it means “robot.”
    In my team,” we have a “ROB,” which stands for Random Object Bucket. It’s an emergency cleanup protocol where we all parts laying on the table into a bucket. Usually it’s used when we lose track of time and have to leave very quickly. If we let it go for more than two times, it gets to be a pain to sort back out.

    Anyway, what’s being suggested is trying to find the root cause of the problem on the hardware. Just work through the issues until you find what doesn’t work specifically. It’s a common troubleshooting technique.

  14. @Got a Screw Loose fixed thanks

  15. @langchen @Got a Screw Loose fixed thanks

    Awesome! Any time!

  16. @Got a Screw Loose
    The cortex burned it self out ... We changed it to a different cortex and the program will still not work. We think the problem is with the coding because originally the arm worked but now nothing will work.

  17. If nothing is working, but it was, then it’s not in the code. Unless you changed it. Try to unplug a motor and plug in one that you know works. If it doesn’t run, then it’s something weird with the Cortex still. It might also be that your motors got shorted or something. Is there whining at all?

  18. @Got a Screw Loose
    No there isn't any wining and all the motors work have have been tested.

  19. Have the ports been tested with a Simple motor[motorname]=127; code?

  20. @Got a Screw Loose
    We figured out the problem our batteries were damaged and sending to much power to the cortex causing them to not work and then setting the cortex on fire. we have already lost two cortexes to this process

  21. Newer ›
 

or Sign Up to reply!