Electric Vehicle C

Locked
User avatar
windu34
Staff Emeritus
Staff Emeritus
Posts: 1382
Joined: April 19th, 2015, 6:37 pm
Division: Grad
State: FL
Has thanked: 2 times
Been thanked: 37 times

Re: Electric Vehicle C

Post by windu34 »

Miske wrote:Dazed and Confused, could use a clarification
In my circuit for running my electric vehicle I'm running six 1.5 voltage AA batteries (9 volts in total) in a battery holder. My only problem is that I'm unsure if it may be counted as a battery pack. The batteries are in series, and connected via the holder. Since they are individual cells I believe this is within the rules but I'm not sure whether an event supervisor will see this arrangement of individual cells in a battery holder or as a battery pack that exceeds the maximum voltage.

If anyone can provide any useful information to assist in clarification, it is of course appreciated.
No, this will not be counted as a battery pack (which are always enclosed in a seal and have proper labeling)
You may submit an official clarification if you'd like however
Boca Raton Community High School Alumni
University of Florida Science Olympiad Co-Founder
Florida Science Olympiad Board of Directors
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: Electric Vehicle C

Post by UQOnyx »

Good news, we finished our first build for the rover. It isn't too fast, but it has potential to be extremely accurate. The motors give a very impressive amount of torque. However, programming is difficult. If anyone is willing to help, I can PM them my full sketch. I'm running the Adafruit V2 motor controller. Basically, when controlling the motors, it has two parameters: speed (0-255), and direction (FORWARD, BACKWARD, RELEASE (stop send power to the motor). I combined this with a simple encoder function, but my problem right now is that for some reason, even when arduino gives the motors the RELEASE command, the motors don't stop power- they keep moving, albeit a bit slower. Along with this, currently the encoder function when paired with the motor drive function is behaving quite erratically. I'm going to try to isolate each problem and solve them individually. Also, I'm (very) open to suggestions if anyone has dealt with any similar problems.
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..
cifutielu
Member
Member
Posts: 63
Joined: March 2nd, 2013, 9:38 pm
Division: C
State: IL
Has thanked: 0
Been thanked: 0

Re: Electric Vehicle C

Post by cifutielu »

Are ultrasonic sensors allowed to determine the distance from the wall?
User avatar
windu34
Staff Emeritus
Staff Emeritus
Posts: 1382
Joined: April 19th, 2015, 6:37 pm
Division: Grad
State: FL
Has thanked: 2 times
Been thanked: 37 times

Re: Electric Vehicle C

Post by windu34 »

cifutielu wrote:Are ultrasonic sensors allowed to determine the distance from the wall?
There is no wall.....
Boca Raton Community High School Alumni
University of Florida Science Olympiad Co-Founder
Florida Science Olympiad Board of Directors
kevin@floridascienceolympiad.org || windu34's Userpage
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 »

windu34 wrote:
cifutielu wrote:Are ultrasonic sensors allowed to determine the distance from the wall?
There is no wall.....
At least not this year. Instead, you will be trying to stop at a predetermined line that is marked on the floor with tape. The event supervisors should tell you the distance, though.
Old fart who sort of did things sort of for some schools.
cifutielu
Member
Member
Posts: 63
Joined: March 2nd, 2013, 9:38 pm
Division: C
State: IL
Has thanked: 0
Been thanked: 0

Re: Electric Vehicle C

Post by cifutielu »

samlan16 wrote:
windu34 wrote:
cifutielu wrote:Are ultrasonic sensors allowed to determine the distance from the wall?
There is no wall.....
At least not this year. Instead, you will be trying to stop at a predetermined line that is marked on the floor with tape. The event supervisors should tell you the distance, though.
I completely forgot about that. So ultrasonic sensors are probably useless then
User avatar
windu34
Staff Emeritus
Staff Emeritus
Posts: 1382
Joined: April 19th, 2015, 6:37 pm
Division: Grad
State: FL
Has thanked: 2 times
Been thanked: 37 times

Re: Electric Vehicle C

Post by windu34 »

I completely forgot about that. So ultrasonic sensors are probably useless then
Yup
Boca Raton Community High School Alumni
University of Florida Science Olympiad Co-Founder
Florida Science Olympiad Board of Directors
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: Electric Vehicle C

Post by UQOnyx »

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.

I have a question unrelated to programming:
Firstly, my axles or wheels are not perfectly coordinated. I suspect my wheel hubs are the main culprit for the wobbling (which leads to the rover driving crooked), but I also think that the axles (these are assembled and manufactured- I didn't touch them) have a bit of play too. Is there any solution to making the vehicle wobble less or go straighter?
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: 1382
Joined: April 19th, 2015, 6:37 pm
Division: Grad
State: FL
Has thanked: 2 times
Been thanked: 37 times

Re: Electric Vehicle C

Post by windu34 »

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.

I have a question unrelated to programming:
Firstly, my axles or wheels are not perfectly coordinated. I suspect my wheel hubs are the main culprit for the wobbling (which leads to the rover driving crooked), but I also think that the axles (these are assembled and manufactured- I didn't touch them) have a bit of play too. Is there any solution to making the vehicle wobble less or go straighter?
can you give us a link or pic of your axles to wheels hub setup?
Boca Raton Community High School Alumni
University of Florida Science Olympiad Co-Founder
Florida Science Olympiad Board of Directors
kevin@floridascienceolympiad.org || windu34's Userpage
User avatar
FawnOnyx
Member
Member
Posts: 96
Joined: December 27th, 2011, 12:32 pm
Division: Grad
State: MN
Has thanked: 0
Been thanked: 0

Re: Electric Vehicle C

Post by FawnOnyx »

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.
Mounds View Science Olympiad Alumnus, 2011-2014
MIT Science Olympiad Volunteer
Locked

Return to “Electric Vehicle C”

Who is online

Users browsing this forum: No registered users and 0 guests