Electric Vehicle C

Justin Zhang
Member
Member
Posts: 4
Joined: September 9th, 2016, 3:35 pm
Division: C
State: MI
Has thanked: 0
Been thanked: 0

Re: Electric Vehicle C

Post by Justin Zhang »

I have tried a EV design using an Arduino and VEX Quadrature Encoder. The problem was the Arduino could not count the rotations of the encoder fast enough, so when reaching high speeds it skipped rotations and decreased the distance it ran. Different types of programs (on Arduino IDE of course) affected the accuracy, so it seems to depend on how fast the program is. I've considered interrupts, libraries, etc.
I understand that many people use Arduinos for their EV. How do you guys run them to the correct accuracy?

Secondly, my arduino mega reads encoders in degrees of 90 when I need accuracy up to 360.

Please share some sample code?
User avatar
windu34
Staff Emeritus
Staff Emeritus
Posts: 1383
Joined: April 19th, 2015, 6:37 pm
Division: Grad
State: FL
Has thanked: 2 times
Been thanked: 40 times

Re: Electric Vehicle C

Post by windu34 »

Justin Zhang wrote:I have tried a EV design using an Arduino and VEX Quadrature Encoder. The problem was the Arduino could not count the rotations of the encoder fast enough, so when reaching high speeds it skipped rotations and decreased the distance it ran. Different types of programs (on Arduino IDE of course) affected the accuracy, so it seems to depend on how fast the program is. I've considered interrupts, libraries, etc.
I understand that many people use Arduinos for their EV. How do you guys run them to the correct accuracy?

Secondly, my arduino mega reads encoders in degrees of 90 when I need accuracy up to 360.

Please share some sample code?
From the sound of it, you are not utilizing the complete effects of the quadrature reading capabilities. Make sure the code you are using is meant for quadrature readings. Additionally, you must use interrupts if you want to read any encoder with a resolution higher than 8 bits. Ensure you have no prints or reads to the serial monitor, which are often a reason to the Arduino not reading the encoder properly
Boca Raton Community High School Alumni
University of Florida Science Olympiad Co-Founder
Florida Science Olympiad Board of Directors
[email protected] || windu34's Userpage
cubes
Member
Member
Posts: 8
Joined: March 26th, 2017, 7:58 pm
Division: C
State: NC
Has thanked: 0
Been thanked: 0

Re: Electric Vehicle C

Post by cubes »

If I choose to do a fixed angle for the steering, would the EV travel in a circular path and does the radius stay constant regardless of velocity and acceleration?
thesenotes
Member
Member
Posts: 17
Joined: April 1st, 2017, 3:27 pm
Division: C
State: NY
Has thanked: 0
Been thanked: 0

Re: Electric Vehicle C

Post by thesenotes »

cubes wrote:If I choose to do a fixed angle for the steering, would the EV travel in a circular path and does the radius stay constant regardless of velocity and acceleration?
The radius will stay constant as long you aren't accelerating so fast that it causes slipping in the wheels and changes the direction of your EV. There is a limit to the maximum velocity your car can go around a curve until it begins to skid laterally, but I have had no problem achieving a 3 second time without that issue.
2016 SONT: 5th Place Scrambler
2017 MIT: 1st Place Electric Vehicle
2018 MIT: 1st Place Helicopter, 6th Place Mousetrap Vehicle
2018 UPenn: 2nd Place Mousetrap Vehicle, 2nd Place Mission Possible, 3rd Place Helicopter

[email protected]
thesenotes
Member
Member
Posts: 17
Joined: April 1st, 2017, 3:27 pm
Division: C
State: NY
Has thanked: 0
Been thanked: 0

Re: Electric Vehicle C

Post by thesenotes »

Justin Zhang wrote:I have tried a EV design using an Arduino and VEX Quadrature Encoder. The problem was the Arduino could not count the rotations of the encoder fast enough, so when reaching high speeds it skipped rotations and decreased the distance it ran. Different types of programs (on Arduino IDE of course) affected the accuracy, so it seems to depend on how fast the program is. I've considered interrupts, libraries, etc.
I understand that many people use Arduinos for their EV. How do you guys run them to the correct accuracy?

Secondly, my arduino mega reads encoders in degrees of 90 when I need accuracy up to 360.

Please share some sample code?
Here is some code. Each white wire on the VEX encoder should be connected to pins 2 and 3 on the Arduino (these are the interrupt pins) and the black and red wires should be connected to ground and a power supply of 5V, respectively:

// Red - 5V
// Black - GND
const int encoder_a = 2; // use one white wire here
const int encoder_b = 3; // use the other white wire here
long encoder = 0;

void setup() {
Serial.begin(9600);
pinMode(encoder_a, INPUT_PULLUP);
pinMode(encoder_b, INPUT_PULLUP);

attachInterrupt(0, encoderPinChangeA, CHANGE);
attachInterrupt(1, encoderPinChangeB, CHANGE);
}

void loop() {
Serial.println(encoder);
}

void encoderPinChangeA() {
encoder += digitalRead(encoder_a) == digitalRead(encoder_b) ? -1 : 1;
}

void encoderPinChangeB() {
encoder += digitalRead(encoder_a) != digitalRead(encoder_b) ? -1 : 1;
}
2016 SONT: 5th Place Scrambler
2017 MIT: 1st Place Electric Vehicle
2018 MIT: 1st Place Helicopter, 6th Place Mousetrap Vehicle
2018 UPenn: 2nd Place Mousetrap Vehicle, 2nd Place Mission Possible, 3rd Place Helicopter

[email protected]
User avatar
windu34
Staff Emeritus
Staff Emeritus
Posts: 1383
Joined: April 19th, 2015, 6:37 pm
Division: Grad
State: FL
Has thanked: 2 times
Been thanked: 40 times

Re: Electric Vehicle C

Post by windu34 »

thesenotes wrote:
Justin Zhang wrote:I have tried a EV design using an Arduino and VEX Quadrature Encoder. The problem was the Arduino could not count the rotations of the encoder fast enough, so when reaching high speeds it skipped rotations and decreased the distance it ran. Different types of programs (on Arduino IDE of course) affected the accuracy, so it seems to depend on how fast the program is. I've considered interrupts, libraries, etc.
I understand that many people use Arduinos for their EV. How do you guys run them to the correct accuracy?

Secondly, my arduino mega reads encoders in degrees of 90 when I need accuracy up to 360.

Please share some sample code?
Here is some code. Each white wire on the VEX encoder should be connected to pins 2 and 3 on the Arduino (these are the interrupt pins) and the black and red wires should be connected to ground and a power supply of 5V, respectively:

// Red - 5V
// Black - GND
const int encoder_a = 2; // use one white wire here
const int encoder_b = 3; // use the other white wire here
long encoder = 0;

void setup() {
Serial.begin(9600);
pinMode(encoder_a, INPUT_PULLUP);
pinMode(encoder_b, INPUT_PULLUP);

attachInterrupt(0, encoderPinChangeA, CHANGE);
attachInterrupt(1, encoderPinChangeB, CHANGE);
}

void loop() {
Serial.println(encoder);
}

void encoderPinChangeA() {
encoder += digitalRead(encoder_a) == digitalRead(encoder_b) ? -1 : 1;
}

void encoderPinChangeB() {
encoder += digitalRead(encoder_a) != digitalRead(encoder_b) ? -1 : 1;
}
If this still fails to track every encoder movement, consider using bitmath and direct port reads and writes to increase processing speed
Boca Raton Community High School Alumni
University of Florida Science Olympiad Co-Founder
Florida Science Olympiad Board of Directors
[email protected] || windu34's Userpage
NilaiVemula
Member
Member
Posts: 32
Joined: March 26th, 2017, 5:39 pm
Division: C
State: TN
Has thanked: 0
Been thanked: 0

Re: Electric Vehicle C

Post by NilaiVemula »

Does anyone have any effective methods of attaching a caliper to the side of your vehicle?
White Station High School
2018: (Invitationals/Regionals/State/Nationals)
Hovercraft: (3/1/-/-)
Thermodynamics: (3/1/-/-)
Mission Possible: (4/2/-/-)
Remote Sensing: (1/1/-/-)
Microbe Mission: (1/1/-/-)
Dynamic Planet: (1/1/-/-)
User avatar
Bazinga+
Exalted Member
Exalted Member
Posts: 383
Joined: March 8th, 2014, 7:10 am
Division: C
State: NY
Has thanked: 0
Been thanked: 0

Re: Electric Vehicle C

Post by Bazinga+ »

NilaiVemula wrote:Does anyone have any effective methods of attaching a caliper to the side of your vehicle?
I clipped mine by having 2 pieces of metal sticking up from the side of the vehicle and then clamping it by using 2 screws and bolts for each to tighten another piece of metal over the caliper. This way the caliper was squeezed between the screwed on piece of metal and the one attached to the side of the vehicle in two places (for stability). Additionally i put some thin soft rubber material between the caliper and the metal that clipped it which helped secure it well.
Innovation =/= success
User avatar
windu34
Staff Emeritus
Staff Emeritus
Posts: 1383
Joined: April 19th, 2015, 6:37 pm
Division: Grad
State: FL
Has thanked: 2 times
Been thanked: 40 times

Re: Electric Vehicle C

Post by windu34 »

Any suggestions for regulating my power supply to my brushless ESC? I tried using a buck converter rated for 8A (12A max) with the voltage set at 7V, but I think the sudden load fluctuation caused the converter to break because now I can no longer adjust the output voltage to any other quantity than the input voltage
Boca Raton Community High School Alumni
University of Florida Science Olympiad Co-Founder
Florida Science Olympiad Board of Directors
[email protected] || windu34's Userpage
NilaiVemula
Member
Member
Posts: 32
Joined: March 26th, 2017, 5:39 pm
Division: C
State: TN
Has thanked: 0
Been thanked: 0

Re: Electric Vehicle C

Post by NilaiVemula »

Bazinga+ wrote:
NilaiVemula wrote:Does anyone have any effective methods of attaching a caliper to the side of your vehicle?
I clipped mine by having 2 pieces of metal sticking up from the side of the vehicle and then clamping it by using 2 screws and bolts for each to tighten another piece of metal over the caliper. This way the caliper was squeezed between the screwed on piece of metal and the one attached to the side of the vehicle in two places (for stability). Additionally i put some thin soft rubber material between the caliper and the metal that clipped it which helped secure it well.
Thanks
White Station High School
2018: (Invitationals/Regionals/State/Nationals)
Hovercraft: (3/1/-/-)
Thermodynamics: (3/1/-/-)
Mission Possible: (4/2/-/-)
Remote Sensing: (1/1/-/-)
Microbe Mission: (1/1/-/-)
Dynamic Planet: (1/1/-/-)
Locked

Return to “Electric Vehicle C”

Who is online

Users browsing this forum: No registered users and 2 guests