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 » December 7th, 2015, 7:42 pm

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: 1366
Joined: April 19th, 2015, 6:37 pm
Division: Grad
State: FL
Has thanked: 1 time
Been thanked: 26 times

Re: Using Arduino Programing

Post by windu34 » December 7th, 2015, 7:59 pm

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
Florida Science Olympiad Board of Directors
National Physical Sciences Rules Committee Member
kevin@floridascienceolympiad.org || 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 » December 8th, 2015, 3:39 pm

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: 1366
Joined: April 19th, 2015, 6:37 pm
Division: Grad
State: FL
Has thanked: 1 time
Been thanked: 26 times

Re: Using Arduino Programing

Post by windu34 » December 8th, 2015, 8:16 pm

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
Florida Science Olympiad Board of Directors
National Physical Sciences Rules Committee Member
kevin@floridascienceolympiad.org || 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 » December 10th, 2015, 4:55 am

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: 1366
Joined: April 19th, 2015, 6:37 pm
Division: Grad
State: FL
Has thanked: 1 time
Been thanked: 26 times

Re: Using Arduino Programing

Post by windu34 » December 10th, 2015, 9:18 am

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
Florida Science Olympiad Board of Directors
National Physical Sciences Rules Committee Member
kevin@floridascienceolympiad.org || 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 » December 16th, 2015, 5:42 pm

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: 1366
Joined: April 19th, 2015, 6:37 pm
Division: Grad
State: FL
Has thanked: 1 time
Been thanked: 26 times

Re: Using Arduino Programing

Post by windu34 » December 16th, 2015, 6:20 pm

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
Florida Science Olympiad Board of Directors
National Physical Sciences Rules Committee Member
kevin@floridascienceolympiad.org || windu34's Userpage

User avatar
bearasauras
Member
Member
Posts: 403
Joined: March 4th, 2003, 8:33 pm
State: CA
Has thanked: 46 times
Been thanked: 85 times
Contact:

Re: Using Arduino Programing

Post by bearasauras » December 31st, 2015, 7:56 am

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: 1366
Joined: April 19th, 2015, 6:37 pm
Division: Grad
State: FL
Has thanked: 1 time
Been thanked: 26 times

Re: Using Arduino Programing

Post by windu34 » December 31st, 2015, 8:28 am

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
Florida Science Olympiad Board of Directors
National Physical Sciences Rules Committee Member
kevin@floridascienceolympiad.org || windu34's Userpage

Locked

Return to “Electric Vehicle C”

Who is online

Users browsing this forum: No registered users and 2 guests