Electric Vehicle C

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+ »

windu34 wrote:
Bazinga+ wrote:I was planning to test run the EV at nationals a day or two before the competition to calibrate it to that specific floor. I see people doing this at nationals every year when the gym where the event is to be run is open, and it goes smoothly. I am aware of the recent situation in Ohio, but I'm under the impression that they issued state specific rules which stated that people may not test cars at the competition. That being said, would testing EV in the gym long before impound be allowed, since it's definitely not an unfair competitive advantage since anyone can do it if the gym is open. I would submit an official clarification, but it does not seem like it should be under the control of science Olympiad, since the competitive tournament for EV technically doesn't start until impound (and the whole point of impound is that you can do whatever you want with the vehicle beforehand, but after it you may not touch it until the official run).
I have been wondering the same thing after the situation in Ohio. I plan to submit a FAQ as well as get in contact with the tournament officials and find out.
Let me know what you find out.
Innovation =/= success
User avatar
samlan16
Member
Member
Posts: 528
Joined: December 30th, 2013, 2:54 pm
Division: Grad
State: GA
Has thanked: 0
Been thanked: 5 times
Contact:

Re: Electric Vehicle C

Post by samlan16 »

Bazinga+ wrote:
windu34 wrote:
Bazinga+ wrote:I was planning to test run the EV at nationals a day or two before the competition to calibrate it to that specific floor. I see people doing this at nationals every year when the gym where the event is to be run is open, and it goes smoothly. I am aware of the recent situation in Ohio, but I'm under the impression that they issued state specific rules which stated that people may not test cars at the competition. That being said, would testing EV in the gym long before impound be allowed, since it's definitely not an unfair competitive advantage since anyone can do it if the gym is open. I would submit an official clarification, but it does not seem like it should be under the control of science Olympiad, since the competitive tournament for EV technically doesn't start until impound (and the whole point of impound is that you can do whatever you want with the vehicle beforehand, but after it you may not touch it until the official run).
I have been wondering the same thing after the situation in Ohio. I plan to submit a FAQ as well as get in contact with the tournament officials and find out.
Let me know what you find out.
From what has happened in Ohio, I would recommend calibrating your car with calculations. Tweak mu to fit the floor, and go by kinematics then dimensional analysis to get whatever numbers you may need.
Old fart who sort of did things sort of for some schools.
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+ »

samlan16 wrote:
Bazinga+ wrote:
windu34 wrote: I have been wondering the same thing after the situation in Ohio. I plan to submit a FAQ as well as get in contact with the tournament officials and find out.
Let me know what you find out.
From what has happened in Ohio, I would recommend calibrating your car with calculations. Tweak mu to fit the floor, and go by kinematics then dimensional analysis to get whatever numbers you may need.
Unfortunately the correlation is probably not linear (even though theoretically it should be, practically its much more complex), and it would be more trouble than its worth.
Innovation =/= success
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+ »

Bazinga+ wrote:I was planning to test run the EV at nationals a day or two before the competition to calibrate it to that specific floor. I see people doing this at nationals every year when the gym where the event is to be run is open, and it goes smoothly. I am aware of the recent situation in Ohio, but I'm under the impression that they issued state specific rules which stated that people may not test cars at the competition. That being said, would testing EV in the gym long before impound be allowed, since it's definitely not an unfair competitive advantage since anyone can do it if the gym is open. I would submit an official clarification, but it does not seem like it should be under the control of science Olympiad, since the competitive tournament for EV technically doesn't start until impound (and the whole point of impound is that you can do whatever you want with the vehicle beforehand, but after it you may not touch it until the official run).
Yep, it's allowed: http://www.scienceolympiad2016.org/comp ... ents-faqs/
Innovation =/= success
dcambrid
Member
Member
Posts: 46
Joined: April 19th, 2016, 12:16 pm
Division: Grad
State: MI
Has thanked: 0
Been thanked: 0

Re: Electric Vehicle C

Post by dcambrid »

UQOnyx wrote:
FawnOnyx wrote:
UQOnyx wrote:I figured out the root to all of my problems... and it kinda sucks until I can find or make better code. Basically my code was perfectly fine... However, my encoders aren't perfect. When the code sets a speed above a certain threshhold, I think that the encoders begin to freak out (probably because of their resolution) and cycle between random increments. So for now, in order to practice, all we have to do is set the speed of the motors to a lower setting.
In your encoder handling code, are you using interrupts to detect rising edges from the encoder pins? If not, I suspect the reason you can't accurately track high speeds is that your control loop doesn't run fast enough to catch all the rising edges. The control loop frequency should be the bottleneck far sooner than anything mechanical or electrical in the encoder because the control loop likely has hundreds of instructions (clock cycles) to go through each time, whereas most quadrature encoders' outputs are asynchronous and really fast.

For example, if one has a motor running at 6000 RPM or 100 rotations per second and the encoder has 100 pulses per rotation, there are 10,000 pulses per second (10kHz) that the microcontroller must detect perfectly. With a typical Arduino running at 16Mhz, this means that one can fit (very roughly) 1,600 processor instructions maximum per control loop before expecting losses. Keep in mind that 1 line of C++ can translate into many processor instructions after compilation. This post suggests that Arduino's digitalWrite and digitalRead take around 50 clock cycles each (the convenience of the functions comes with the cost of considerable overhead). Also, the period of the 10kHz encoder pulses is 1/10000=0.1 ms, so if you have any sort of delay() calls that stall the control loop on the order of milliseconds, you can abandon any hope of tracking the encoder accurately. (instead of delay, look at millis() or micros())

One can do the math in a more indirect way too: If you want the car to go 5 m/s but want your encoder configured to have 1mm resolution (1mm per pulse), then at max speed, the encoder will be sending 5/0.001=5000 pulses per second. This translates to 3,200 clock cycles max or a period of 0.2ms.

The best solution that should guarantee accuracy is to use interrupts to track the encoder pulses. The link has more detailed info, but basically an interrupt enables dedicated electronics to listen for a rising edge (or other types) on a certain pin and literally interrupt whatever the arduino was doing and enter a function of your choice before returning back to what it was doing. In the case of encoder reading, this function probably checks if it should increment or decrement an encoder position variable. The advantage is that interrupts trigger exactly when you want them to and get out of the way of your control loop otherwise.

Since interrupts rely on special electronics, only two of the pins on a typical Arduino are interrupt capable. Fortunately, quadrature encoders only have two wires to listen to, so it works out. I would also suggest looking at this encoder library which is optimized for interrupts, saves you some work writing the code, and would probably be more reliable anyway. I've used it before for a simple knob but I think it'd work well for this high speed stuff.

Sorry this went went so in-depth, and maybe you're already using interrupts. Nevertheless, I think it's interesting and I hope it's helpful to others.
Update: All code problems have been solved!

Thanks for the great reply. I, in fact, was already using an interrupt function :D , but I reached the same conclusion for the same reason as what you wrote. I initially tried using the quadrature encoders using a basic function running in the main void loop () function, but this was extremely limiting for my motors for a multitude of reasons. Basically it was just sloppy code. Then, I switched over to using the interrupt pins (thanks to google and arduino tutorials), and it solved most of my problems. However, like I said in my previous post, the motor speed was limited by the quadrature's readings... Very weird. After about a full hour of debugging and even consulting my dad (he's a technical software architect), I still couldn't isolate the cause to the symptoms.

Heres the AHA! moment. Today I met up with my partner, and I just explained and re-hashed everything again for his benefit. And then suddenly I realized... I'm trying to loosen a bottleneck! What bigger bottleneck is possible than a serial stream of packets of data going through a USB?? So, in a stroke of inspiration, I just erased all of the serial functions that output to the serial monitor... Lo and behold, it worked like a charm! I could set motors to go at max RPM, and the quadrature could keep track of the movements, which was evident by the motor's output- the motors stopped after a certain number of turns. Perfect!!!

So now, all that is left is calibration, testing, and buying a new set of wheel hubs. Thanks for the help folks!
Why didn't I find this thread a week ago! We had the exact same issue with our arduino based vehicle, it worked perfectly at low speeds, would stop within 5cm everytime, but as soon as we sped it up, the distance went haywire. We have serial prints all over that we used as we were debugging the code, we were printing the distance at every interrupt to check that it was incrementing correctly. We thought it was motor noise or some other EMI issue and put capacitors everywhere on the car. We finally had to go back to our wing nut brake vehicle for States last Saturday and ran 2.2 secs and 18 cm out to place 7th one out of the medals. I think I am going to throw up. Thanks for sharing though, we will get it right next year!
Locked

Return to “Electric Vehicle C”

Who is online

Users browsing this forum: No registered users and 1 guest