Tuesday, April 27, 2010

Common Ground -> *Progress* -> Baseline -> Refine -> Extension

When we finally had things to update on, we never got the chance to write about it because we were working so much on our project to reach the baseline. Now that we reached it I am taking some time to write about what we have been doing since the common ground realization.


Servo Motor:
We wrote up the code for the HC12 to rotate servo motor based on x-axis accelerometer inputs (now that SPI is working). The servo motor was also controlled using PWM, and the duty cycle of the square wave generated using PWM determined the angle at which the servo would turn. The turning mechanism of the Mustang car consisted of a groove as shown. The servo motor's cross fits perfectly in the groove. All we had to do was map the full range of x-axis accelerometer values to the restricted range needed to turn the wheels. We eyeballed it to be 3.75% to 5.1% and got it right the first try.


Light System:
For this we took our first steps into a whole bunch of soldering. We bought some super bright blue LEDs for the headlights and then four red LEDs for the rearlights. The light system circuit consisted of the LEDs and a photoresistor voltage divider. We programmed the HC12 so that if the ambient light gets dim enough, the output of the voltage divider with the photoresistor would be a high enough input to the ADC pin. As a result of this, we output a high to PA0 and PA1, which are connected to the positive end of the headlight and rearlight LEDs. In addition, we programmed so that the rearlights would turn on anytime the car is driving in reverse.


H-Bridge:
To drive and control the DC motor we needed an H-bridge, however the dual channel H-bridge we had was definitely too big to fit under the car case. We went to the GM lab and obtained a L293D quadruple half-H drivers, which was just a tiny IC. By looking up the datasheet for the L293D and using our knowledge from the H-bridge we used before, we were able to successfully use the tiny L293D to control the DC motors to spin forward and reverse.


PCB Cookie:
To have a standalone RAC car, we need the HC12 independent of the project board. This also means that we won't get to use the complementary breadboard. Initially we found a mini breadboard where we wired up our circuits, but it was still a little thick and didn't look very clean. Our friend Bill found us a clean PCB to which we soldered the H-bridge circuit and common ground.


Ping Sensor Installation:
Finally, in anticipation for our add on to the baseline, we decided to mount the ping sensors to the car case in advance. Thanks to Kevin's tools and Evan's dremmel we were able to drill two holes where the ping sensor could poke through.

1 comment:

  1. hello sir, thank you for writing this article sir, i thought it was impossible to control servo motor using pwm, actually i am in the middle of building servo simple control, i have controlling servo using direct method, which using delay_us() function... but actually my goal is using PWM to control it,could you explain to me how to do that? i will be very grateful, (i'm using code vision evaluation version.... ). email me maesarandy@gmail.com
    thanks, best regard.

    ReplyDelete