Using Arduino Programing

TylerMiller
Member
Member
Posts: 4
Joined: November 15th, 2015, 8:51 pm
Division: C
State: KS
Has thanked: 0
Been thanked: 0
Contact:

Using Arduino Programing

Post by TylerMiller »

Are any of you using an Arduino to program your electric vechle if so how are you using it?
User avatar
windu34
Staff Emeritus
Staff Emeritus
Posts: 1384
Joined: April 19th, 2015, 6:37 pm
Division: Grad
State: FL
Has thanked: 2 times
Been thanked: 42 times

Re: Using Arduino Programing

Post by windu34 »

TylerMiller wrote:Are any of you using an Arduino to program your electric vechle if so how are you using it?
Regardless of whether you chose to use a regular brushed DC motor with a gearbox, cont. rot. servo, or brushless ESC combo, you ABSOLUTLY WILL be using a microcontroller of some sort. Arduino is the most popular brand in this area (Raspberry Pi doesn't suit this purpose quite as well)
Use it to control motor speed, duration, etc.
Boca Raton Community High School Alumni
University of Florida Science Olympiad Co-Founder
Florida Science Olympiad Board of Directors
[email protected] || windu34's Userpage
User avatar
UQOnyx
Exalted Member
Exalted Member
Posts: 274
Joined: November 28th, 2012, 2:23 pm
Division: C
State: NJ
Has thanked: 0
Been thanked: 0

Re: Using Arduino Programing

Post by UQOnyx »

Actually, there are ways other than Arduino to achieve the same effects for speed control, or stopping (Think mechanical braking methods), but microcontrollers are great for this. If you want to learn how to achieve high speed and accuracy properly, look into learning about PID, or Proportional-Integral-Derivative Control methods. Essentially, you can use code to account your car's speed and error (or how far you are from the finish line) and time to create a system for making your car go at perfect efficiency in speed and accuracy.

A quick-and-dirty method would be modelling the PID system, but instead of using code to make mathematical functions, you can use arbitrary numbers to model what PID essentially does. For example, I can code the vehicle for the following commands
-Set finish line at 10.5 meters.
-When button is pressed, make car go at full speed until 9 meters.
-Lower speed by 60% until 10 meters.
-Lower speed by 50% until 10.25 meters.
-Stop car at 10.5 meters
Noor-ul-Iman School

2012 Events:
Forestry
Storm The Castle


2013 Events:
Boomilever
Shock Value
Forestry


I know the voices aren't real, but they have some great ideas..
User avatar
windu34
Staff Emeritus
Staff Emeritus
Posts: 1384
Joined: April 19th, 2015, 6:37 pm
Division: Grad
State: FL
Has thanked: 2 times
Been thanked: 42 times

Re: Using Arduino Programing

Post by windu34 »

UQOnyx wrote:Actually, there are ways other than Arduino to achieve the same effects for speed control, or stopping (Think mechanical braking methods), but microcontrollers are great for this. If you want to learn how to achieve high speed and accuracy properly, look into learning about PID, or Proportional-Integral-Derivative Control methods. Essentially, you can use code to account your car's speed and error (or how far you are from the finish line) and time to create a system for making your car go at perfect efficiency in speed and accuracy.

A quick-and-dirty method would be modelling the PID system, but instead of using code to make mathematical functions, you can use arbitrary numbers to model what PID essentially does. For example, I can code the vehicle for the following commands
-Set finish line at 10.5 meters.
-When button is pressed, make car go at full speed until 9 meters.
-Lower speed by 60% until 10 meters.
-Lower speed by 50% until 10.25 meters.
-Stop car at 10.5 meters
Don't forget a means of actually measuring where the car is at (via rotary encoder)
PID while very effective, isn't necessarily the best way to go about this (especially if you are new to coding and Arduino)
PID is one of the more difficult concepts and a similar control can be achieved without the need of that kind of precise mathematics and coding
For example:
//Basic statement for running motor (not initialized)
// x is the variable to which you store your rotary encoder value
// y is the number of "cogs" to achieve desired distance
if(x < y){
digitalWrite(motorPinBackwards, LOW);
digitalWrite(motorPinForward, HIGH);
}
else if(x > y){
digitalWrite(motorPinBackwards, HIGH);
digitalWrite(motorPinForward, LOW);
}
else
digitalWrite(motorPinBackwards, LOW);
digitalWrite(motorPinForwards, LOW);



While inefficient, this sort of code is much easier for the novice/beginner programmer to utilize and will get you within 10cm of your target (exact distance dependent on your rotary encoder quality and how straight your vehicle went)
Boca Raton Community High School Alumni
University of Florida Science Olympiad Co-Founder
Florida Science Olympiad Board of Directors
[email protected] || windu34's Userpage
User avatar
theriddler
Member
Member
Posts: 56
Joined: October 5th, 2012, 12:22 pm
Division: C
State: NY
Has thanked: 0
Been thanked: 1 time

Re: Using Arduino Programing

Post by theriddler »

Have any of you guys come up with a way to determine if the vehicle is moving in a straight line, so you can account for the distance (using trigonometry) if it is moving at an angle?

On another note, has anybody encountered the problem of the Arduino not being able to power the motor?
"A man can fail many times but he isn't a failure until he begins to blame somebody else"-John Burroughs
User avatar
windu34
Staff Emeritus
Staff Emeritus
Posts: 1384
Joined: April 19th, 2015, 6:37 pm
Division: Grad
State: FL
Has thanked: 2 times
Been thanked: 42 times

Re: Using Arduino Programing

Post by windu34 »

theriddler wrote:Have any of you guys come up with a way to determine if the vehicle is moving in a straight line, so you can account for the distance (using trigonometry) if it is moving at an angle?

On another note, has anybody encountered the problem of the Arduino not being able to power the motor?
NEVER try to power a motor from your arduino directly. You must use a motor shield or buil circuit with the IC to drive it (h bridges and what not)
To determine curve, aim your vehicle slightly right ansd run it. If it crosses the center line, its curving left. Repeat for left side
Boca Raton Community High School Alumni
University of Florida Science Olympiad Co-Founder
Florida Science Olympiad Board of Directors
[email protected] || windu34's Userpage
harik2000
Member
Member
Posts: 28
Joined: September 22nd, 2015, 8:44 pm
Division: C
State: CA
Has thanked: 0
Been thanked: 0

Re: Using Arduino Programing

Post by harik2000 »

windu34 wrote:
theriddler wrote:Have any of you guys come up with a way to determine if the vehicle is moving in a straight line, so you can account for the distance (using trigonometry) if it is moving at an angle?

On another note, has anybody encountered the problem of the Arduino not being able to power the motor?
NEVER try to power a motor from your arduino directly. You must use a motor shield or buil circuit with the IC to drive it (h bridges and what not)
To determine curve, aim your vehicle slightly right ansd run it. If it crosses the center line, its curving left. Repeat for left side

I am a little confused on what you mean by the center line. I was under the impression that there would be no center line at the competitions. Thanks!
User avatar
windu34
Staff Emeritus
Staff Emeritus
Posts: 1384
Joined: April 19th, 2015, 6:37 pm
Division: Grad
State: FL
Has thanked: 2 times
Been thanked: 42 times

Re: Using Arduino Programing

Post by windu34 »

harik2000 wrote:
windu34 wrote:
theriddler wrote:Have any of you guys come up with a way to determine if the vehicle is moving in a straight line, so you can account for the distance (using trigonometry) if it is moving at an angle?

On another note, has anybody encountered the problem of the Arduino not being able to power the motor?
NEVER try to power a motor from your arduino directly. You must use a motor shield or buil circuit with the IC to drive it (h bridges and what not)
To determine curve, aim your vehicle slightly right ansd run it. If it crosses the center line, its curving left. Repeat for left side

I am a little confused on what you mean by the center line. I was under the impression that there would be no center line at the competitions. Thanks!
Correct, Use a line on the gym floor (for the purpose of the process to determine curving/straightness)
Boca Raton Community High School Alumni
University of Florida Science Olympiad Co-Founder
Florida Science Olympiad Board of Directors
[email protected] || windu34's Userpage
User avatar
bearasauras
Member
Member
Posts: 410
Joined: March 4th, 2003, 8:33 pm
State: CA
Has thanked: 53 times
Been thanked: 115 times
Contact:

Re: Using Arduino Programing

Post by bearasauras »

But what if the center of the lane isn't aligned with one of the lines on the floor?
User avatar
windu34
Staff Emeritus
Staff Emeritus
Posts: 1384
Joined: April 19th, 2015, 6:37 pm
Division: Grad
State: FL
Has thanked: 2 times
Been thanked: 42 times

Re: Using Arduino Programing

Post by windu34 »

bearasauras wrote:But what if the center of the lane isn't aligned with one of the lines on the floor?
The purpose of this exercise is only to determine if the vehicle is flawed. This is not something you should rely on using at competition because there is not guarantee of a centerline.
I use this method when making slight adjustments to the axles to ensure they are as straight as possible.
Boca Raton Community High School Alumni
University of Florida Science Olympiad Co-Founder
Florida Science Olympiad Board of Directors
[email protected] || windu34's Userpage
Locked

Return to “Electric Vehicle C”

Who is online

Users browsing this forum: No registered users and 3 guests