EG First 2nd rev bot

Very new to this site. Been playing with this project on and off for 6 months. Completed once then went back to and it wasn't working. Tried to troubleshoot and burnt out the chip. Pulled out the whole circuit board. Then rewired the battery pack. At that point it is just the frame DC motors on front and back(front geared to turn right and left, back left as dc motor for fowards and back) . I pulled an H bridge chip from a motor drive expansion board and breadboarded it .

For the most part to DC motors are working fine. But in trying to add a servo and ping to the mix the coding is becoming a night mare. especially with the buggy Eclipse ide, and the hard to deal with Arduino IDE.

I really want to get it going and so I am posting my code as I have it.

 

My motor function class and Ping class seems like they may be able to tie together.

The servo code is what is giving me grinding gear problems. The servo problems is not for the wheels turning because the manufacturer rigged a gear set up for a DC motor for that. The problem is the servo the ping will sit on. I still have yet to figure out how to get them to work together. Seeing all these other bots it look so easy but I am still trying to figure out how to get the ping to decide the best direction to go. Along with getting the servo to act right.

The H bridge is;

 

This is my first bot car, I have been into Arduino litely but more heavily this year. I would like to get this one going and not put it up for later. Any help is very much welcomed.

 

 

 



 

 

Modified RC obstacle avoidance Car

  • Actuators / output devices: DC Motors, servo
  • Control method: autonomous
  • Operating system: Arduino C++
  • Sensors / input devices: ultrasonic, Ping))) Ultra Sound, L293D H-Bridge

This is a companion discussion topic for the original entry at https://community.robotshop.com/robots/show/eg-first-2nd-rev-bot

**Just adding some more information **

Hi again,

Below is the H Bridge and the wiring that I used. I know there is a lot of coding above I left the comments in as silly as they may seem to get any kind of feed back , again any help will be welcomed.

Pictures are not coming up it seems. So the H Bridge is the L293D chip.

|x

 

Today is a good day .... to learn something

Happy tinkering and Happy coding Ebonygeek45

Welcome

I started too hacking a RC car.
The servo may have problem because is under or over powered, check with a multimeter if is receiving enough Volts or Ampere(they typically work with 3-6v and 100-250mA).

Hi Silux, Thank you

 

Will check the volts with the multimeter, but a quick question is why would the servo run fine when the same servo code is ran through arduino IDE, But, when running in eclipse the same code make the grinding sound. Would the IDE’s give off different volts.

So, I measure 4.95 on my multimeter for both the Arduino IDE and the Eclipse IDE.

I guess that leads me to just try to work it out on the Arduino IDE.

Really ashame that Eclipse isn’t agreeing with my servo.

Today is a good day … to learn something Happy tinkering and Happy coding Ebonygeek45

Welcome.

Congrats on making the effort to use eclipse with the arduino, that is more than most would do. You mentioned that the gears seem to ‘grind’ when using eclipse - you aren’t using it in debug mode are you? Assuming you don’t have a broken servo, grinding sounds are often caused by timing issues, which debug mode could cause. Similarly, the ultrasonic sensor is very timing sensitive and if not carefull, these two devices could cause issues with one another.

If you are having problems with Eclipse, I would stop using it until you have fixed your other problems and then start using it again after that. You can’t be sure what the real problem is if you have more than one at once.

I had a quick look at your code - I can’t see the main function, what does it do? If you are inlcuding all the files you listed above, it looks like you might be reusing PIN 6 on the arduino (for both motor IN3 and the servo)? I also see that you have included other classes/files such as “NewPing.h”. If this redifines anything, then that could also cause problems.

Can you tell us what the chip is on the RC car that you soldered the wires too? Is the original microcrontroller still active (and could it be interefering)? Try removing all unused imports. What are each of the classes meant to do? The arduino servo library works reasonably well, I would not bother wrapping it in a class, just use it as it was provided. You might also find it easier if you write the ping code into a method rather than a whole class. You can always make it a class later.

P.S. I highly recommend not posting code in the description like that, it makes it very difficult to read. If you are unsure of where the problem is, try attaching the files or using a service like github.

looking into you advise later tonight thank you

 

I added an updated video on the modified car to show where I am at now.
“Modify RC Car Arduino Uno ReStart Part 1”.

Eclipse is my “go to” IDE but I guess it is Arduino IDE until things are figured out.  But Yes I was using the debug mode, I will try out of debug mode.

Again sorry about the code, I was doing test code for each device just to make sure it would work, so I may have used a pin twice since I was testing them individually. I will make sure to post neater code. Tomorrow. I did take your advice and put the code in an attachment for easier access. I would like to do Github but it is something I have not used up to this point, but will look into it.

The chip is the L293D. The original board was toast after a failed mistake. So started it from scratch with the L293D.

Thank you for the advise, wish I had time to work on it now but will not get back to it to later tonight.

Today is a good day … to learn something Happy tinkering and Happy coding Ebonygeek45

Thanks for the update. That

Thanks for the update. That last video explained things well. Let me know how it goes! :slight_smile:

Update on Bbot

 

I have actually start working on building the classes/libraries in eclipse and getting the code up to par. Then add my main which is the .ino file in Arduino IDE. So finding a way to do code using both to make it a bit less headache. The servo runs ok under Arduino ide.

Now I am just working on getting the code good. It is not as easy as I thought transitioning from console apps to real life actions. It is fullfilling though.

I am just trying to now figure out the ping and how you get the readings to work in a variable or een in an array. They come in pretty fast. How does it settle on the correct reading . Anyhow I am still working on it.

The code has been added and is egServoPingLibA.zip, It is set up as a library but  the main or .ino is in the example folder.

 

Today is a good day … to learn something Happy tinkering and Happy coding Ebonygeek45

Recursion

Here some issues I can see:

  • Your Servo6::ping() function doesn’t return a long, even though you say it does in the header. I suggest breaking that into multiple methods: one that returns just the raw ping value, one to convert to inches, and one to convert to centimetres.
  • Servo6::ping() calls itself, making it an infinitely recursive function that would never exit if it weren’t for the fact that arduino would run out of memory and crash.
  • The logic on line 75 of your arduino sketch will not work properly. Replace with '(leftDist<minSafeObstacleDist && rightDist<minSafeObstacleDist)'

I hope that helps.

Thank you much

 

I am going to hit my programming books again, and take this one slow. I did find a good eclipse Arduino IDE recently though. This is not quite the same as console programming and I am really rusty. I would have liked to completed this one before hitting the books but, I have some more projects waiting that might help me with this one in the future.   I will try to get back to it when I have a better handle on the coding.

 

 

Today is a good day … to learn something Happy tinkering and Happy coding Ebonygeek45