I’m frustrated

Battery charger detection problem_Make an Arduino-Controlled Robot

Hello,
I tried to run the code detection and battery charger encounter compilation errors. Am I doing it wrong or is that the web code contains errors? I have commented out without checking mode battery connector and not do it. Help please.
1 person has
this problem
+1
Reply
  • Hi David,

    Are you referring to the code from Appendix D, "Power Sources," in the book? If so, make sure to add a voltage divider to the power source, as shown in Figure D-1. If you don't add a voltage divider, the code won't work.

    Cheers,
    Eric
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly

  • Hello Eric.
    The voltage divider I have it positioned correctly. I have seen this with the tester reading and through the serial port, on-screen.
    The problem I have is about the connection jack detector. There code about that when you plug the jack stops the movement of the robot. I have a cable connection to digital pin 2 from the connector in the jack, but when I load the code in arduino not working properly. If I'm not mistaken, the wire that goes to pin 2 leaves the decision to no longer land in the jack, when you plug the charger?

    I hope you can help me. thanks
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly

  • Brian Jepson (Editor, Maker Media, Inc.) January 22, 2013 21:40
    Hi David,

    Where are you receiving these errors? Does it happen when you go to upload the code?

    Could you post the error message you're getting? Also, can you let me know which example program (directory/filename) so I know which one you're looking at?

    Also, which version of the Arduino IDE are you using?

    Thanks,

    Brian
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly

  • The area of the code that I have not clear if it is the catch. I'm using the Arduino UNO SMD edition.
    Can you show me how to connect the charger jack detector to digital pin 2? The book does not show any scheme how. When I load the program downloaded from the book page the robot does not move, so if the jack is connected or not connected. So I tried to modify the code but only get compilation errors. This issue does not end should be clear in any section, a cable only appears blue in some pictures, but nothing more.
    The lines of code are those relating to "/ / version for charger detection". <a
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly

  • Brian Jepson (Editor, Maker Media, Inc.) January 22, 2013 22:19
    Hi David,

    I'll ask the author to take a look and give us some advice.

    - Brian
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly

  • > Can you show me how to connect the charger jack detector to digital pin 2

    Hi David,

    The switch wiring shown in the chapter for building the platform (Chapter 3 for the 2WD, chapter 4 for 4WD) uses the power switch to control if the batteries are charging or the robot is running, so the code using pin 2 in appendix D is not required. However, if you do want to wire the circuit so the batteries will charge whenever the power supply is connected to the DC jack, you can do the following:

    The 22 ohm charging resistor lead going to the switch should be connected to the center terminal of the power switch (the same switch terminal as the red wire going to the positive side of the battery holder).

    There is a terminal on the DC jack that is open circuit when the power supply is plugged in - this terminal is connected to ground when the jack is disconnected. The terminal is shown unconnected in the diagrams in the book but can be wired to pin 2 so the Arduino code in Appendix D can sense when the charger is connected.

    In summary, for the Arduino code in Appendix D to detect if the charger is plugged in, connect the third (unused) terminal of the DC jack to Arduino digital pin 2.

    - Michael
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly

  • Hello Michael, is a pleasure to talk to you.

    In the picture show as I soldier the connections. I think everything is according to the steps that you have shown me. The blue wire is the one that goes to pin 2 of Arduino, the resistance goes, like the red wire from the battery, to the center of the switch.

    When I load the program in Appendix D in the Arduino, the robot does not move, whether it is the jack plugged in as if it is. The only difference is that I used resistance to the charger circuit is 20 ohms and 5W, instead of 22 ohms and 3W, but I think this does not affect the detection of the jack.

    Using the multimeter I have seen that indeed when the charger is not connected there is 0 volts between the battery ground and the blue wire, but when I plug the jack, the voltage on the blue wire is 2.2 volts over ground battery. Could this be causing the problem? Even so, should not move the robot when I'm not charging?

    I hope to complete the robot soon. Thanks for your time.

    A greeting.

  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated

  • The Voltage on pin 2 should be nearly 5 volts when the Arduino is powered and the charger is not plugged in. To find out why it is too low, you can do the following steps:

    Disconnect the blue wire from pin 2 and measure the voltage at the pin. If it is much lower than 5 volts then there is a problem with the internal pull-ups. Make sure you are running the unmodified MyRobotBatteryMonitor sketch from the download.

    If the reading is still too low, remove the Uno from the robot and try running the DigitalInoutPullup example sketch that is included with the Arduino distribution. The comments in that sketch explain how to connect a push button (or you can use a jumper wire instead of a button) to test that pull-ups are working on pin 2.

    If the voltage on pin 2 is close to 5 volts with the blue wire disconnected then the problem is probably related to the DC jack. With the blue wire disconnected from pin 2, batteries removed and nothing plugged into the jack, measure the resistance between the blue wire and ground - it should be an open circuit. Now with your power supply unplugged (so there is no voltage on the DC barrel connector) plug the connector into the DC jack and check for a closed circuit between the blue wire and ground. If the resistance is much higher than a few ohms, there is a problem with your jack or your wiring. But as far as I can see from the picture, if you used the jack from the kit, the jack looks to be wired correctly.

    Let me know how you get on.

    Michael
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated

  • Thank you very much for the information Michael. Indeed, the pull-up resistor on pin 2 is not working properly. While, for example, pin 3 provides 4.5 volts in pull-up mode, pin 2 only supplies 2.2 volts, so I conclude that the jack functions properly.

    In this case,do you recommend me using an external resistor, without connecting the pull-up? or conversely, can i make any changes in the code to solve the problem?

    A greeting.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly

  • Did you try it with the Uno disconnected from the shield? Perhaps there is a bad connection that is causing the problem. Although you can change to any unused pin (5 and 6 should be available on the 2WD) it would be good if you can find out and fix what is causing the problem with pin 2. I would hesitate to use an external resistor unless you can determine why the internal one is not working.

    As you probably know, you change the constant to set the digital pin for charge detect, in the example below, the charge detect signal should be connected to digital pin 5 (note this is not available on the 2WD robot):
    const int chargerDetectedPin = 5;
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly

  • Hello,

    First I tried the shield on, but the problem did not go away, so I removed completely the Arduino and did the test again. Again the output was 2.2 volts. I tried to pin 3 and the results were good, so something is wrong with the pull-up resistor on pin 2, but do not know what may be the cause, as I was working only with the board and a pair of wires

    I changed the sensor connector jack to digital pin 5 and I loaded the sketch again. Now, as I can see through the serial port, the robot recognizes when the charger is connected, but the robot is not moving, whether or not connected to the jack.

    The program I've re-downloaded from the web and I'm sure it has not been modified.

    greetings
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly

  • Have you tested the robot using the exercises earlier in the book? If the robot functions using the simpler sketches then you should uncomment the line with the roam function. Your loop code should look like this.

    void loop()
    {
    roam(); // remove the backslashes from the begining of this line !
    batteryCheck();
    }
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly

  • All sketches from previous chapters worked properly. Indeed, I uncommented roam() function and does not move the robot. Only turn the ping sensor to the top from left to right and it does nothing. It is strange, since "MyRobotWander" works perfectly.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly

  • add the following line to the setup function in the myRobotBatteryMonitor sketch following moveBegin();
    moveSetSpeed(MIN_SPEED + 10) ;
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly

  • I’m very happy
    Thanks Michael, the robot works perfectly with the changes that I've left for me comentado.Únicamente test the IR receiver with the TV remote, try it with the TSOP 34,156 at my disposal.

    Thanks again for your book and the good times I'm going through building it.

    A greeting.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly