Author Topic: Making Arduino Robot  (Read 10152 times)

0 Members and 1 Guest are viewing this topic.

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13382
Re: Making Arduino Robot
« Reply #75 on: March 24, 2025, 02:58:34 pm »
The pins in the sketch must exactly match the way the H-bridge, sensors etc. are wired to the Arduino pins.   There are different ways of supplying eveything with the correct voltage range depending on the battery pack you use, so the sketch doesn't care about the possible variations in the power wiring.

If the sketch doesn't match the wiring you have to change the pin numbers in the sketch till it does, however not all pins are capable of all functions, so some stuff shouldn't be moved/changed.
« Last Edit: March 24, 2025, 07:54:07 pm by Ian.M »
 

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 5059
  • Country: nl
Re: Making Arduino Robot
« Reply #76 on: March 24, 2025, 06:06:20 pm »
Not Ian, but I will give it a try.

Your sensors are most likely 5V based, so you can't power them from a 6 cell battery pack. (6 * 1.5V = 9V) This means you have to power the sensors from either the Arduino 5V output or the motor driver 5V output. It is best to use the 5V from the Arduino UNO to power the sensors and the 5V from the motor driver board to power the servo.

In an Arduino sketch you assign the IO pins to functions. Say for the motor drive you connect the module inputs to pins D4 and D5 on the Arduino UNO, while in the code pins D0 and D1 are used your motor won't be controlled. So you have to make sure that you connect the modules to the correct IO pins as used in the software.

Edit: I did not see Ian's reply as it was on the next page. Now you have two answers.  :)

Offline Larsson55Topic starter

  • Regular Contributor
  • *
  • Posts: 245
  • Country: ca
Re: Making Arduino Robot
« Reply #77 on: March 24, 2025, 07:53:55 pm »
I used two 2mm bolts/nuts and the servo arm is now secured to the base tight. The only weak link now is the "self taping" screw which holds the servo arm to the motor's plastic shaft and there is nothing I can do there unless I get a motor with metal shaft.

My next step is to follow Dr. Edwards instructions starting on step 5  for the Firmware.

Next steps 6 & 7 are related to the sensor mount which are complete

Then is step 8 to connect the power & motor wires which for now I plan to use my 4 pack batteries. If I must use a 6 pack batteries I will do this step (and the ones below) on Wednesday

Finally is step 9 to connect all above to the sensor shield

I haven't noticed anywhere where/how to connect the speed sensors for the two big wheels

Please let me know if all above are correct or of any changes

Many thanks

pcprogrammer obviously I will let Ian handle your last post, thanks
Nicolas
 

Offline Larsson55Topic starter

  • Regular Contributor
  • *
  • Posts: 245
  • Country: ca
Re: Making Arduino Robot
« Reply #78 on: March 25, 2025, 08:39:20 pm »
Have a problem with uploading Robot-car.ino, If I go to libraries there are many, where do I put the robot-car.ino? Arduino says "Upload error"
Attached picture of what I have
Nicolas
 

Offline Larsson55Topic starter

  • Regular Contributor
  • *
  • Posts: 245
  • Country: ca
Re: Making Arduino Robot
« Reply #79 on: March 25, 2025, 08:54:20 pm »
Looks like my Arduino is stuck to what I was doing before when I had the Elegoo kit and when I open Arduino it still says Lesson 24 which was the last lesson I did with that kit. I don't know how to start Arduino without Elegoo
Nicolas
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13382
Re: Making Arduino Robot
« Reply #80 on: March 26, 2025, 12:11:55 am »
File => New, then  on the old 1.8x IDE, close the previous sketch window.
 

Offline Larsson55Topic starter

  • Regular Contributor
  • *
  • Posts: 245
  • Country: ca
Re: Making Arduino Robot
« Reply #81 on: March 26, 2025, 01:56:17 am »
Was able to get robot-car.ino and when ask to upload it says "compilation error: use of enum "Motor" without previous declaration

What is Arduino BT? before I had Arduino UNO
Nicolas
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13382
Re: Making Arduino Robot
« Reply #82 on: March 26, 2025, 03:48:07 am »
Was able to get robot-car.ino and when ask to upload it says "compilation error: use of enum "Motor" without previous declaration
That's strange. Prof. Edwards' robot-car.ino that I attached to reply #25, compiles here with no issues.  I'm using Arduino IDE v1.8.13.
What is Arduino BT? before I had Arduino UNO
Arduino BT is the wrong board (i.e. wrong model Arduino).  Do Tools => Board: "...."  => Arduino AVR Boards  => Arduino Uno (very near top of list).  If you compile for the wrong board it generally wont work (exception: some pairs of boards are interchangeable as only the form factor differs e.g Uno/Nano).
 

Offline Larsson55Topic starter

  • Regular Contributor
  • *
  • Posts: 245
  • Country: ca
Re: Making Arduino Robot
« Reply #83 on: March 26, 2025, 07:26:21 am »
I have Arduino 2.3.4 still says Arduino BT, somehow I think the lessons I did before screw up something in Arduino. I use the code you said on #25. Also do I need any extra libraries ?
Nicolas
 

Offline Larsson55Topic starter

  • Regular Contributor
  • *
  • Posts: 245
  • Country: ca
Re: Making Arduino Robot
« Reply #84 on: March 26, 2025, 08:19:32 am »
Re installed Arduino and now it says Arduino AVR and the robot-car.ino is in the sketch window. Then it says upload error exit status1. Output says: avrdude: ser-open(): "\\.\COM5. My Device mgr says COM5 works. Don't know what to do now.
Nicolas
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13382
Re: Making Arduino Robot
« Reply #85 on: March 26, 2025, 09:00:33 am »
The clone Arduino Uno that usually comes with those robot kits uses a CH340 USB serial interface IC.  If your computer doesn't have the right drivers, the port may be non-functional.  Try updating the drivers for that device - see: https://learn.sparkfun.com/tutorials/how-to-install-ch340-drivers
 

Offline Larsson55Topic starter

  • Regular Contributor
  • *
  • Posts: 245
  • Country: ca
Re: Making Arduino Robot
« Reply #86 on: March 26, 2025, 09:35:14 am »
Thanks for the link Ian, I suspected something similar may happen so I connected the other Uno I had from before and that shows on Arduino as COM3. I did this from my home office without the robot-car connected cause the robot is in my workshop which I cant access right now. Later on today when I can access the robot I will post back.
Nicolas
 

Offline Larsson55Topic starter

  • Regular Contributor
  • *
  • Posts: 245
  • Country: ca
Re: Making Arduino Robot
« Reply #87 on: March 26, 2025, 12:18:26 pm »
BTW the link you sent me is for the motor controller?

Anyway I replaced the UNO with the one I had from Elegoo and now all was fine and the sensor moved. The wiring is now disconnected following the order you specified.

I got the 6 pack battery holder and ready now for the final step. Do I follow Pro. Edwards wiring to finish or wait for you? 
Nicolas
 

Offline Larsson55Topic starter

  • Regular Contributor
  • *
  • Posts: 245
  • Country: ca
Re: Making Arduino Robot
« Reply #88 on: March 26, 2025, 12:29:02 pm »
Forgot, where do I connect the two LM393 speed sensors for the 2 motor wheels? Pro. Edwards does not show any
Nicolas
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13382
Re: Making Arduino Robot
« Reply #89 on: March 26, 2025, 12:54:54 pm »
Connect the speed sensors later, after you have tested the car with the robot-car.ino sketch.  IIRC they conflict with Prof. Edwards' pin allocation, so you'll need to move some wires and edit the sketch.   They each need three wires, +5V, Gnd and DO back to the arduino sensor shield.  Don't connect sensor AO.  The DO pins need to go to Arduino INT0 (Digital pin 2) and INT1 (digital pin 3) as the Arduino needs a fast way to count the pulses.

For the power wiring for the six cell holder, the easiest way to do it is with a rightangle DC plug that fits the Arduino DC in jack.  Call the L298 blue three way screw terminal block T3, with pin 1 next to the mounting hole, (may be marked +12V on PCB underside).
Code: [Select]
POWER WIRING
============
6 cell Bat(+) --- Switch(1)
Switch(2) ---- L298 T3(1) ---- Arduino DC In center (or VIN)
6 cell Bat(-) ---- L298 T3(2) ---- Arduino DC In shell (or GND)
L298 T3(3) ---- Sensor shield VCC
Make sure the jumper next to the L298 three way screw terminal block is fitted and the one marked SEL next to the sensor shield two way screw terminal block is removed.   Don't connect anything to sensor shield screw terminal GND, it gets GND via the Arduino (you can use this as a test point for your DMM's black lead).

For the duPont wiring, and the L298 module to motor wiring, follow Prof. Edwards' tutorial.

Post photos of the assembled power wiring for us to check before fitting the batteries!

« Last Edit: March 26, 2025, 01:33:19 pm by Ian.M »
 

Offline Larsson55Topic starter

  • Regular Contributor
  • *
  • Posts: 245
  • Country: ca
Re: Making Arduino Robot
« Reply #90 on: March 26, 2025, 03:11:33 pm »
Thanks Ian, I will follow your instructions and perhaps as I go along I may have questions to assure I understand . Will definitely post pictures before inserting the batteries

What is duPont wiring?
Nicolas
 

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 5059
  • Country: nl
Re: Making Arduino Robot
« Reply #91 on: March 26, 2025, 03:18:03 pm »
What is duPont wiring?

duPont is a connector type. The small black end on the wires of the servo for instance is a three way duPont connector that fits on a 2.54mm male header.

You might also have gotten wires with these connectors on both sides. There are male and female types of these connectors. See the aliexpress link for pictures.

https://www.aliexpress.com/item/1005007072081464.html

Offline Larsson55Topic starter

  • Regular Contributor
  • *
  • Posts: 245
  • Country: ca
Re: Making Arduino Robot
« Reply #92 on: March 26, 2025, 03:45:28 pm »
Thanks pcprogrammer, now understand and its true I got a bunch of them which are very handy.
Nicolas
 

Offline Larsson55Topic starter

  • Regular Contributor
  • *
  • Posts: 245
  • Country: ca
Re: Making Arduino Robot
« Reply #93 on: March 26, 2025, 07:51:28 pm »
3 pictures where I mounted the batteries case for comments

BTW when the robot is ready and running it will not be connected to the PC. Out of curiosity where it saves the instructions to do what it does?
Nicolas
 

Offline Larsson55Topic starter

  • Regular Contributor
  • *
  • Posts: 245
  • Country: ca
Re: Making Arduino Robot
« Reply #94 on: March 27, 2025, 12:54:06 am »
Apologies Ian but I don't understand your wiring instruction, I can guess but guessing will only lead to mistakes.

What is IIRC ?

"They each need three wires, +5V. Gnd and DO.." Which ones are "they" ? And what is DO ?

"Call the L298 blue three way screw terminal block T3....." I don't understand this paragraph at all

If I may suggest, the UNO, Sensor Shield and L298H all have pins ID so perhaps you can say from UNO pin... to L298H pin..., something like that. Then there is no room for mistakes. An alternative perhaps is to refer to Pro. Edwards schematic and change the pins ID he is using?

Many thanks
Nicolas
 

Offline Andy Chee

  • Super Contributor
  • ***
  • Posts: 1512
  • Country: au
Re: Making Arduino Robot
« Reply #95 on: March 27, 2025, 04:16:27 am »
What is IIRC ?

Many thanks
IIRC is internet shorthand for, "If I Recall Correctly"

LOL is internet shorthand for, "Laughing Out Loud"

IMHO is internet shorthand for, "In My Humble Opinion"

https://www.ruf.rice.edu/~kemmer/Words04/usage/slang_internet.html
 

Offline Larsson55Topic starter

  • Regular Contributor
  • *
  • Posts: 245
  • Country: ca
Re: Making Arduino Robot
« Reply #96 on: March 27, 2025, 04:25:16 am »
Thanks Andy, I knew the rest but not IIRC
Nicolas
 

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 5059
  • Country: nl
Re: Making Arduino Robot
« Reply #97 on: March 27, 2025, 07:11:42 am »
3 pictures where I mounted the batteries case for comments

BTW when the robot is ready and running it will not be connected to the PC. Out of curiosity where it saves the instructions to do what it does?

The ATmega328 used on the Arduino UNO contains so called FLASH memory. This is electrically erasable read only memory and the code for driving the robot is stored in that. With the Arduino IDE download command the AVRDude program connects to the ATmega328 and tells it to load the code into the FLASH memory. This is so called non volatile memory, thus once loaded it stays in there almost for ever. Data retention times are mentioned in the datasheets.

Mechanically wise, considering the weight of the batteries and with it raising the center of gravity, you might want to consider making some brackets to place the battery plate flat above the motor driver board.

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 5059
  • Country: nl
Re: Making Arduino Robot
« Reply #98 on: March 27, 2025, 07:30:47 am »
"They each need three wires, +5V. Gnd and DO.." Which ones are "they" ? And what is DO ?

They are the two speed sensors. DO means digital out in this case.

The sensor, for what I found on the internet, has four connections.
VCC where the 5V needs to be connected.
GND where the ground needs to be connected.
DO which needs to be connected to a digital input of the Arduino UNO. D2 or D3 according to Ian.
AO the analog output pin which is not used.

To use these sensors the code needs to be changed and my advice is to leave this for later when the robot is actually working with the basic setup.

"Call the L298 blue three way screw terminal block T3....." I don't understand this paragraph at all

See the attached picture. The connector with the red ellipse around it, is the one Ian is referring to. This is where the supply from the battery pack needs to be connected.

Here is some information on this: https://components101.com/modules/l293n-motor-driver-module

The motors are connected to the two smaller 2 way screw terminal blocks on the sides of the board.

Offline Larsson55Topic starter

  • Regular Contributor
  • *
  • Posts: 245
  • Country: ca
Re: Making Arduino Robot
« Reply #99 on: March 27, 2025, 03:09:54 pm »
Thanks a lot for your time pcprogrammer,

It's true having the battery holder horizontally mounted will provide better stability but it was easier to do it vertically. I will take your suggestion and change it.

The wiring explanation is sufficient and much appreciated. My knowledge in electronics is less then zero and I prefer to understand what I'm doing to avoid mistakes.
Nicolas
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf