Page 16 of 18

Re: Electric Vehicle C

Posted: April 2nd, 2017, 7:54 am
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?

Re: Electric Vehicle C

Posted: April 2nd, 2017, 8:11 am
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

Re: Electric Vehicle C

Posted: April 2nd, 2017, 8:43 am
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?

Re: Electric Vehicle C

Posted: April 2nd, 2017, 9:52 am
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.

Re: Electric Vehicle C

Posted: April 2nd, 2017, 10:11 am
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;
}

Re: Electric Vehicle C

Posted: April 2nd, 2017, 12:08 pm
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

Re: Electric Vehicle C

Posted: May 2nd, 2017, 4:28 pm
by NilaiVemula
Does anyone have any effective methods of attaching a caliper to the side of your vehicle?

Re: Electric Vehicle C

Posted: May 2nd, 2017, 6:22 pm
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.

Re: Electric Vehicle C

Posted: May 3rd, 2017, 8:03 pm
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

Re: Electric Vehicle C

Posted: May 4th, 2017, 3:58 pm
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