M

Members
  • Content Count

    22
  • Joined

  • Last visited

About M

  • Rank
    Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. No apologies necessary. I am grateful for your assistance. By manipulating the servo I have managed to achieve it proceeding in a straight line. For my initial demo I made the robot follow a course which is sufficient for now. I will test the sensors more extensively at the end of the week. If you have any code or other ideas to test the sensors, please pass it on. Once again Thanks
  2. I changed the batteries to a fresh set and that seems to have the solved the servo problem. However right servo moving faster than left. Pls advise Thanks
  3. Could it be a faulty servo?
  4. #define pinServoLeft 21 #define pinServoRight 20 I have attached the servo to the other two pins. The result is the same, the right servo "hangs" and does not complete the circle even if the left one is disconnected. The left servo does not have the same problem and makes a full circle when the right servo is disconnected. (using my code above)
  5. I am at another roadblock. The servo on the right side is causing the board to shut down. I have tried using the Basic program with no success. I have modified it a bit to show you the problem. I have set it to go in a square with the following code: Forward(); delay(5000); TurnRight(); delay(1550); Forward(); delay(5000); TurnRight(); delay(1550); Forward(); delay(5000); TurnRight(); delay(1550); Forward(); delay(3000); StopRobot(); When attaching one servo the robot moves, when attaching two, it stalls. Please advise as I am at my wits end. I wanted to make a simpler demo by disregarding the sensors and just making the robot go around a square as the robot started to freeze up after I sent yesterdays videos through. I have attached a video to demonstrate the problem Thanks
  6. I have used a thinner line, the same thickness as the caulk line on my tile floor so that the 2 sensors remain accurate
  7. I have adjusted the sensitivity and this has made a difference to the 2 sensors in the middle. However the outer sensors do not respond. I think the PMODSL is faulty. To overcome this I have removed the 2 outer sensors and modified the code so the robot does not sense them. When testing the code the robot moves towards a black line, stops there and tries to follow the line. It follows the line very slowly with many stops in between. The robot also does not rotate both servos at the same speed. The right wheel moves faster than the left pulling the robot towards the right side. Any suggestions on making it faster in its response time when following the line and how to synchronise the wheels to rotate at the same speed thus making it go perfectly straight. Her are my modified sections of code: // pinMode(pinFarRight, INPUT); pinMode(pinMidRight, INPUT); pinMode(pinMidLeft, INPUT); //pinMode(pinFarLeft, INPUT); byte bMRS = digitalRead(pinMidRight)*(0x4); byte bMLS = digitalRead(pinMidLeft)*(0x2); I have left this unchanged if(bInstruction == 1 || bInstruction == 2 || bInstruction == 3 || bInstruction == 7){ TurnRight(); } else if(bInstruction == 8 || bInstruction == 4 || bInstruction == 12 || bInstruction == 14){ TurnLeft(); } else { Forward(); } Once again thank you for your patient responses.
  8. Or have I configured it incorrectly, Please advise. Thanks
  9. Two videos https://forum.digilentinc.com/gallery/category/2-support-galleries/
  10. I have attached videos of the robot. Please advise if it is faulty so I can return it to the supplier. Thanks
  11. Yes. I have connected the cables as you have mentioned and pressing the BTN2. I have verified this by running the basic program which allows the robot to respond to different buttons being depressed either moving it forwrd, backwards, left or right, However the line follower does not work. Could it be a faulty MX3CK board?
  12. Thank you for your time and patience. I have posted my images under the gallery. Hopefully you can diagnose the problem. https://forum.digilentinc.com/gallery/category/2-support-galleries/ This is the code I have been using. It is the reference version from the website: /************************************************************************/ /* */ /* SRK_Line */ /* */ /* */ /************************************************************************/ /* Author: Jordan Retz */ /* Copyright 2012, Digilent Inc. */ /************************************************************************/ /* Module Description: */ /* */ /* This module implements a simple demo application that shows how to */ /* program the RDK Line - Servo. */ /* */ /* Functionality: */ /* */ /* The application uses the PmodLS1, four IR proximity sensors, and two */ /* servo motors. Based on the outputs of the four sensors attached to */ /* the Pmod, the robot will alter it's direction to stay on a line. */ /* The robot will work best if the line is black electric tape on a */ /* white surface. */ /* */ /* The sensors are referred to as Far Right (FRS), Mid Right (MRS), Mid */ /* Left (MLS), and Far Left (FLS). These should be connected to S1, S2, */ /* S3, S4, respectively, on the PmodLS1. Left and right are determined */ /* looking down on robot with sensor, bracket forward. */ /* */ /* */ /* Instruction FRS MRS MLS FLS Function */ /* 0 0 0 0 0 Stop */ /* 1 0 0 0 1 Turn Right */ /* 2 0 0 1 0 Continue */ /* 3 0 0 1 1 Turn Right */ /* 4 0 1 0 0 Continue */ /* 5 0 1 0 1 Turn Right */ /* 6 0 1 1 0 Continue */ /* 7 0 1 1 1 Turn Right */ /* 8 1 0 0 0 Turn Left */ /* 9 1 0 0 1 Continue */ /* 10 1 0 1 0 Turn Left */ /* 11 1 0 1 1 Turn Right */ /* 12 1 1 0 0 Turn Left */ /* 13 1 1 0 1 Turn Left */ /* 14 1 1 1 0 Turn Left */ /* 15 1 1 1 1 Move Foward */ /* */ /* Pressing BTN2 on the PmodBTN will Start or Stop the robot. The */ /* PmodBTN must be connected to the top row of JD. The PmodCON3 must */ /* be connected to the bottom row of header JC. The PmodLS1 must be */ /* connected to the bottom row of JB. Only BTN2 is a valid input. */ /* */ /* Programming: */ /* */ /* Make sure that the MX3cK is plugged into the computer via USB cable, */ /* and that the board is powered. */ /* */ /* From the toolbar above, select "Tools->Board->MX3cK". From the Start */ /* menu, navitgate to "Start->Control Panel->Hardware and Sound->Device */ /* Manager". Select "Ports", and take note of what COM port (COMx) is */ /* labeled "USB Serial Port". If you are unsure, unplug the MX3cK from */ /* the computer and watch which COM port disappears, and then */ /* reappears, when you plug the MX3cK back into the computer. */ /* From the toolbar above, select "Tools->Serial Port" and then the COM */ /* port that you just found. Apply power to the MX3cK and click on the */ /* "Upload" button above. */ /* */ /************************************************************************/ /* Revision History: */ /* */ /* 6/21/2012 (JordanR): created */ /* 12/17/2012 (MichaelK): Name Change /* */ /************************************************************************/ /* ------------------------------------------------------------ */ /* Include File Definitions */ /* ------------------------------------------------------------ */ #include <plib.h> #include <Servo.h> /* ------------------------------------------------------------ */ /* Local Type Definitions */ /* ------------------------------------------------------------ */ /* These definitions are valid if the PmodCON3 is connected to the ** bottom row of header JC */ #define pinServoLeft 23 #define pinServoRight 22 /* These definitions are valid if the PmodBTN is connected to the ** top row of header JD */ #define pinBTN0 24 #define pinBTN1 25 #define pinBTN2 26 #define pinBTN3 27 /* These definitions are valid if the PmodLS1 is connected to the ** bottom row of header JB */ #define pinFarRight 12 #define pinMidRight 13 #define pinMidLeft 14 #define pinFarLeft 15 /* ------------------------------------------------------------ */ /* Global Variables */ /* ------------------------------------------------------------ */ /*Define Servos*/ Servo left; Servo right; byte bInstruction; byte bPrevInstruction; bool fRobotStartStop; /* ------------------------------------------------------------ */ /* Forward Declarations */ /* ------------------------------------------------------------ */ void CheckSensors(); void StopRobot(); void Forward(); void TurnRight(); void TurnLeft(); void RobotStartStop(); /* ------------------------------------------------------------ */ /* Procedure Definitions */ /* ------------------------------------------------------------ */ /*** void setup() ** ** Parameters: ** none ** ** Return Value: ** none ** ** Errors: ** none ** ** Description: ** Initialize the system. */ void setup() { /*Setup Input/Output on Pins */ pinMode(pinServoLeft, OUTPUT); pinMode(pinServoRight, OUTPUT); pinMode(pinBTN0, INPUT); pinMode(pinBTN1, INPUT); pinMode(pinBTN2, INPUT); pinMode(pinBTN3, INPUT); pinMode(pinFarRight, INPUT); pinMode(pinMidRight, INPUT); pinMode(pinMidLeft, INPUT); pinMode(pinFarLeft, INPUT); /*Set Robot default state to STOPPED */ fRobotStartStop = false; /*Attach External Interrupt EXT_INT3 */ attachInterrupt(EXT_INT3, ISRRobotStartStop, RISING); } /* ------------------------------------------------------------ */ /*** void loop(); ** ** Parameters: ** none ** ** Return Value: ** none ** ** Errors: ** none ** ** Description: ** Main application loop. */ void loop() { CheckSensors(); /* Robot Stop if all Sensors are off OR if fRobotStartStop == false */ if(bInstruction == 0 || fRobotStartStop == false) { StopRobot(); } /* Robot Start if at least one Sensor is on AND if fRobotStartStop == true */ else if(fRobotStartStop == true) { if(bInstruction == 3 || bInstruction == 7 || bInstruction == 11 || bInstruction == 1 || bInstruction == 5){ TurnRight(); } else if(bInstruction == 12 || bInstruction == 13 || bInstruction == 14 || bInstruction == 8 || bInstruction == 10) { TurnLeft(); } else { Forward(); } } } /* ------------------------------------------------------------ */ /*** byte CheckSensors(); ** ** Parameters: ** none ** ** Return Value: ** none ** ** Errors: ** none ** ** Description: ** Returns the state of the sensors. Must be connected to JA */ void CheckSensors() { byte bFRS = digitalRead(pinFarRight)*(0x8); byte bMRS = digitalRead(pinMidRight)*(0x4); byte bMLS = digitalRead(pinMidLeft)*(0x2); byte bFLS = digitalRead(pinFarLeft)*(0x1); bInstruction = (bFRS | bMRS | bMLS | bFLS); } /* ------------------------------------------------------------ */ /*** void StopRobot(); ** ** Parameters: ** none ** ** Return Value: ** none ** ** Errors: ** none ** ** Description: ** Stops robot by finding Servo position and reducing or increasing to 90. ** Then detaches pins. */ void StopRobot() { left.write(90); right.write(90); left.detach(); right.detach(); } /* ------------------------------------------------------------ */ /*** void Forward(); ** ** Parameters: ** none ** ** Return Value: ** none ** ** Errors: ** none ** ** Description: ** Moves robot forward */ void Forward() { left.attach(pinServoLeft); right.attach(pinServoRight); left.write(107); right.write(73); } /* ------------------------------------------------------------ */ /*** void turnRight(); ** ** Parameters: ** none ** ** Return Value: ** none ** ** Errors: ** none ** ** Description: ** Turns robot right */ void TurnRight() { left.attach(pinServoLeft); right.attach(pinServoRight); left.write(107); right.write(107); } /* ------------------------------------------------------------ */ /*** void turnLeft(); ** ** Parameters: ** none ** ** Return Value: ** none ** ** Errors: ** none ** ** Description: ** Turns robot left */ void TurnLeft() { left.attach(pinServoLeft); right.attach(pinServoRight); left.write(73); right.write(73); } /* ------------------------------------------------------------ */ /*** void ISRRobotStartStop(); ** ** Parameters: ** none ** ** Return Value: ** none ** ** Errors: ** none ** ** Description: ** External Interrupt Service Routine. When button is pressed, ** checks the state of the robot (moving/stopped) and toggles it. ** Robot will then move forward or stop accordingly. */ void ISRRobotStartStop() { /* This line of code toggles the value of fRobotStartStop */ fRobotStartStop = !fRobotStartStop; }