RC_car motors and Arduino

Discussion in 'The Projects Forum' started by seky, Sep 19, 2013.

  1. seky

    Thread Starter Member

    Sep 19, 2013
    31
    1
    Hi,
    For first I apologize for my broken English, but I hope, that you will know, what I am writing . I am a beginner in electronics and in the motors too, but I studied it and I will know, how it works. I am doing at my project in the school RC_car powered by WiFi and I ask you for help . The trouble, what I have is in the connection between Arduino and RC_motors. I have bought a new RC_car, but it was controlled by remote control, but I remove out China chip and only have cable from motors. I dont have any shield for control motors, I built one by myself. All is OK I can control car by arduino via w,a,s,d (it doesnt matter), but after 10 sec it will reset, I think I need there a capacitor or something else? Here you are my schematic (I hope, that you unriddle them ) http://prntscr.com/1s27ik

    Thanks for all type of answer Seky.
     
  2. edmundopt

    Member

    May 4, 2011
    60
    0
    are the relays fast enough for the servo control ?

    maybe a high value resistor, like 100k between the NPN transistors base and emiter will help you.
     
  3. seky

    Thread Starter Member

    Sep 19, 2013
    31
    1
    Hmm, I use DC motors and I power it from 6V battery and that curcuit, that I built a power from Arduino 5V, average current from motors is 2A, but total peak 4A, I can control this motors maybe for 10 sec I hear a noise sticking relays, maybe you are right I will test it, but dont need I some capacitors? Thx for reply
     
  4. edmundopt

    Member

    May 4, 2011
    60
    0
    so you are suplying the arduino from the 6v battery that also provides power to the dc motor?
    how did you step down the voltage from 6v to 5volts ?
     
  5. seky

    Thread Starter Member

    Sep 19, 2013
    31
    1
    No, at this moment I have arduino connected to USB port at PC, motors I powered from original 6V battery I think 6AA batteries in pack and curcuit is powered from 5V pin Arduino and 4 digital pins for control...
     
  6. edmundopt

    Member

    May 4, 2011
    60
    0
    ok, so for now you want isolation between the battery pack and the arduino..
    you do understand that it wont be much of a RC if the usb cable is connected.

    first of all, the forward and backward on the dc motor should be controled by a H-Bridge http://en.wikipedia.org/wiki/H_bridge , if you want acceleration, you must provide PWM to the H bridge, but that is if you go that way, you'll probably will..

    For NOW, if you want to continue with what you have so far, I recomend a diode protection, and that's were your problem must be :
    check http://www.robotroom.com/HBridge.html the D1, D2, D3 and D4 diodes will protect your relays, something like Sb120 will do
     
  7. seky

    Thread Starter Member

    Sep 19, 2013
    31
    1
    So ok, I will learn it and I hope I can build it :), when I want to go by alternative way, can I use this schematic? http://forum.allaboutcircuits.com/showthread.php?t=33992&highlight=L298 and build it on my own?....but I will continue in my schematic, but this is a second way...I will answer, when I build it, Thx for help, can I next write you a PM message? Seky
     
  8. edmundopt

    Member

    May 4, 2011
    60
    0
    fell free to PM me..

    to use a HBridge, first, you have a DC motor with 4amps peak, so do not use the L298, use a MOSFET based HBridge and the protection diodes, they will use your battery much better!

    this video http://www.youtube.com/watch?v=3tHIXPoKPNc can drive with a 5volts logic signal from you arduino a DC motor up to 15amps
     
  9. seky

    Thread Starter Member

    Sep 19, 2013
    31
    1
    So ok, but what is wrong in my schematic http://prntscr.com/1s27ik , because I have protected my relays with diodes but not with 1N5817 Schottky diodes have I replace it?..or it is wrong and I must take it to another location? or what?...and I dont understand this line: you do understand that it wont be much of a RC if the usb cable is connected. So I must power arduino from battery not from USB port from PC?...
     
  10. edmundopt

    Member

    May 4, 2011
    60
    0
    Radio controled cars as the name mentions are radio controled, not USB cable controled.

    Please mention the following values:
    resistance for each relay, are they 5volts ?
    resistor values for the NPN transistors

    Update the schematic with the diodes and requested values.
     
  11. seky

    Thread Starter Member

    Sep 19, 2013
    31
    1
    Yes you are right, but for testing I use Arduino connect to USB and THEN I will power it from batteries and control via WiFi, but this is another chapter

    Resistors: FORWARD,BACKWARD 12k
    LEFT,RIGHT 15k
    Relays: 5V 164 Ohm
    Diodes: 1n4148
     
  12. strantor

    AAC Fanatic!

    Oct 3, 2010
    4,302
    1,988
    I think that's your problem right there. I would be very surprised if you could get ordinary AA batteries to deliver 4A. At 2A continuous, they are going to bleed dry alarmingly fast. I'd bet that your relay chatter is due to low voltage from dead or dying, extremely over-taxed batteries.
     
  13. seky

    Thread Starter Member

    Sep 19, 2013
    31
    1
    Hmm, I dont think so, because I checked it repeatly 6V and 700mAh, in normal state, that means Rc_car goes only for ground hill or something A is about 0.1-1A this 4A is when I stop wheel and turn left or right. But dude, I dont think, that batteries can be dead, maybe yes, but this batteries are from factory, that means, that I bought this car from shop and only remove RC chip (possible that can be stabilizators?), but when I put voltage down about 4V wheels go slowly. When I start Arduino I can control car that means forwards, etc. but after 10 seconds do that arduino reset, but next I can control repeatly,but after that repeat...
     
  14. seky

    Thread Starter Member

    Sep 19, 2013
    31
    1
    and relays are powered from arduino 5V, maybe this is reason? or what?
     
  15. strantor

    AAC Fanatic!

    Oct 3, 2010
    4,302
    1,988
    Sorry I misunderstood; so the arduino itself is resetting.
    I've been reading about arduino resets, and I'm noticing a trend that these are normally caused by noisy power. The 5V pin on arduino isn't good for more than 500mA (possibly limited to 100mA by usb port) so you really aren't pulling too much current from the pin (30mA per relay) but I would still try powering those relays from somewhere else and see if that helps. I think the switching of relays could be causing interference.
     
  16. seky

    Thread Starter Member

    Sep 19, 2013
    31
    1
    Hm, I tried this powered from external supply 5V and still nothing, I mean a same situation, that it is powered from Arduino (but this is a good note, when I will change something I will power it from external), but maybe I dont have a good schematic design..or I know...anyone help?
     
  17. strantor

    AAC Fanatic!

    Oct 3, 2010
    4,302
    1,988
    I don't see anything wrong with your schematic. Even if I missed something; there shouldn't be anything that would cause the arduino to reset.

    If it were me, I start isolating things. I would pull the arduino out of the circuit; maybe put LEDs only (with resistors, of course) on the outputs and see if the arduino resets. I read also that bad code can cause resets.

    If the arduino runs just fine without the circuit connected, then start re-incorporating the circuit one section at a time until the problem comes back, then you know what to investigate.
     
  18. seky

    Thread Starter Member

    Sep 19, 2013
    31
    1
    Hmm, but when I put LEDs all is ok...I will update here a code...
     
  19. seky

    Thread Starter Member

    Sep 19, 2013
    31
    1
    Code ( (Unknown Language)):
    1.  
    2. #include <SPI.h>
    3. #include <Ethernet.h>
    4.  
    5. int x=0,y=0;
    6.  
    7. byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; //nastavý MAC
    8. IPAddress ip(192,168,10,18); //nastavý IP
    9. IPAddress gateway(192,168,10,17); //nastavý GATEWAY
    10. IPAddress subnet(255,255,255,252); //nastavý SUBNET
    11.  
    12. EthernetServer server(2000); //nastavý PORT
    13. boolean alreadyConnected = false; // whether or not the client was connected previously
    14.  
    15. void setup()
    16.  {
    17.   Ethernet.begin(mac, ip, gateway, subnet); //inicializuje ETHERNET-ové zariadenie
    18.   server.begin();   //začne počúvať clientov
    19.   Serial.begin(9600);  // otvorí seriovú komunikáciu a čaká kým sa port otvorí
    20.   Serial.print("Chat server address:");
    21.   Serial.println(Ethernet.localIP());
    22.  
    23.   //nastavý použivané porty do vypnutého stavu
    24.   pinMode(45,OUTPUT);
    25.   digitalWrite(45,0);
    26.  
    27.   pinMode(44,OUTPUT);
    28.   digitalWrite(44,0);
    29.  
    30.   pinMode(43,OUTPUT);
    31.   digitalWrite(43,0);
    32.  
    33.   pinMode(42,OUTPUT);
    34.   digitalWrite(42,0);
    35.  
    36.   pinMode(41,OUTPUT);
    37.   digitalWrite(41,0);
    38.  
    39.   pinMode(40,OUTPUT);
    40.   digitalWrite(40,0);
    41.  }
    42.  
    43. void loop()
    44.  {
    45.   EthernetClient client = server.available(); //čaka na nového clienta
    46.   // keď klient pošle prvé BYTY ,napíše Ahoj:
    47.   if (client)
    48.    {
    49.     if (!alreadyConnected)
    50.      {
    51.       // clead out the input buffer:
    52.       client.flush();    
    53.       alreadyConnected = true;
    54.      }
    55.  
    56.     if (client.available() > 0)
    57.      {
    58.       char data = client.read(); //čita BYTY prichádzajúce od klient
    59.       if(data=='f')
    60.        {  
    61.          digitalWrite(45,1);
    62.        }
    63.        
    64.        if(data=='j')
    65.        {  
    66.          digitalWrite(45,0);
    67.        }
    68.        
    69.        if(data=='b')
    70.        {
    71.          digitalWrite(44,1);
    72.        }
    73.        
    74.         if(data=='k')
    75.        {
    76.          digitalWrite(44,0);
    77.        }
    78.        
    79.        if(data=='r')
    80.        {
    81.          digitalWrite(42,1);
    82.        }
    83.        
    84.        if(data=='n')
    85.        {
    86.          digitalWrite(42,0);
    87.        }
    88.        
    89.        if(data=='l')
    90.        {
    91.          digitalWrite(43,1);
    92.        }
    93.        
    94.        if(data=='m')
    95.        {
    96.          digitalWrite(43,0);
    97.        }
    98.        
    99.        if(data=='s')
    100.        { x=!x;
    101.          digitalWrite(41,x);
    102.        }
    103.        
    104.        if(data=='y')
    105.        { y=!y;
    106.          digitalWrite(40,y);
    107.        }
    108.       //server.write(data);  // echo the bytes back to the client
    109.       Serial.write(data); // echo the bytes to the server as well:
    110.      }
    111.    }
    112. }
    113.  


    I use ethernet shield and send data (letters) from PC via ethernet cable....
     
    Last edited by a moderator: Sep 19, 2013
  20. edmundopt

    Member

    May 4, 2011
    60
    0
    well, maybe three steps
    (1) run the code without anything connected, and test if all ok
    (2) run the code with the transistors PNP, resistors, relays, but nothing connected to the RC car(no motor, servo.. etc)
    (3) everything connect

    please reply at wich step the arduino resets!
     
Loading...