Page 13 of 23

Re: Electric Vehicle C

Posted: December 16th, 2015, 5:15 pm
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

Re: Electric Vehicle C

Posted: December 20th, 2015, 2:45 pm
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.

Re: Electric Vehicle C

Posted: December 26th, 2015, 3:50 pm
by cifutielu
Are ultrasonic sensors allowed to determine the distance from the wall?

Re: Electric Vehicle C

Posted: December 26th, 2015, 6:08 pm
by windu34
cifutielu wrote:Are ultrasonic sensors allowed to determine the distance from the wall?
There is no wall.....

Re: Electric Vehicle C

Posted: December 27th, 2015, 8:58 am
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.

Re: Electric Vehicle C

Posted: December 27th, 2015, 9:03 am
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

Re: Electric Vehicle C

Posted: December 27th, 2015, 10:01 am
by windu34
I completely forgot about that. So ultrasonic sensors are probably useless then
Yup

Re: Electric Vehicle C

Posted: December 27th, 2015, 2:29 pm
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?

Re: Electric Vehicle C

Posted: December 27th, 2015, 3:21 pm
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?

Re: Electric Vehicle C

Posted: December 28th, 2015, 2:22 am
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.