- Clean existing wiring
- Pseudocode
- Improve hack solution
- Checkoff
- Determine proper gain equations and gain value ranges
- Test for car steering after leaving settling band
- Pseudocode
- Improve hack solution
- Checkoff
- Cleaning up start-stop condition while loops
- Modify Set_Motor_PWM
- Pseudocode
- Determine proper gain equations and gain value ranges
- Continue working on main logic
- Improve hack solution
- Checkoff
LITEC Lab 5
- Wire the accelerometer to the I2C bus (x arrow pointing to EVB ribbon); keep the existing ranger, compass, and keypad. Keep wires for RF transmission.
- Reinstall a buzzer in series with a resistor and run it through the buffer chip.
- Potentially add battery monitoring capabilities (OPTIONAL).
- An additional slide switch; the two slide switches will each individually control run/stop of the two control algorithms (Drive and Servo).
- Call the Accel_Init_C function from i2c.h file and write a Read_Accel function.
- Need to modify Set_Servo_PWM that is based off the accelerometer reading.
- Steering should be set such that the car will turn in the direction of the upward slope.
- Motor_PW is set using both side-to-side (+x to the left) and front-to-back (+y to the front) tilt.
- The accelerometer is noisy, so 4 to 8 readings of the accelerometer should be averaged.
- Initial parameters and output should still be displayed on both the LCD display and the SecureCRT terminal.
- Three different gains will be set by the user; each should be able to be set with both the keypad and keyboard.
- Potentially add battery monitoring software (OPTIONAL).
- Data should be printed as one combined printf() including time (possibly unnecessary?), x & y accelerations, Motor_PW and Servo_PW, current gains, and possibly battery voltage (OPTIONAL) IN THAT ORDER.
- Switching the drive motor to neutral should operate in such a way that "adjustments can be made with the program running" (ask staff).
- For the drive motor, front-to-back gain is set via pot and varies from 1 to 50 (pure integer is fine) which can be adjusted while the car is in motion. Side-to-side gain is set by key press on either the keypad or keyboard.
- It should not be difficult to incorporate software for starting parameters that prints the gain from the pot and asks if you wish to try a different gain (Matt's recommendation).
- Steering gain should be set by key press from keypad or keyboard.
- The main logic for setting Servo_PW and Motor_PW is listed below:
Servo_PW = SERVO_CENTER_PW - ks * xaccel
Motor_PW = MOTOR_NEUTRAL_PW + kdy * yaccel
Motor_PW += kdx * abs(xaccel)Where ks is the Servo gain, and kdy and kdx are the drive motor gains.
For an additional integral function for the Motor_PW:
drive_pw += kdx * abs(xaccel) + ki * error_sum
error_sum += yaccel + abs(xaccel)Where ki is the integral gain.
- Car will drive in the direction of maximum slope until it levels out at the top or bottom of the slope.
- The car must drive up the ramp in reverse! While driving in reverse, it must turn the buzzer on and off for .5 s and 1.0 s, respectively. When it reaches the top, the buzzer should turn off. (Ask staff if it needs to buzz while the motor or servo is in neutral.)
- Car strictly stops when it reaches level ground, and points and is parallel to the direction of maximum slope when it stops.
- While driving, the program should find the maximum slope of the ramp and display this value in degrees when it stops at level ground.
- The accelerometer updates every 20 ms. Avoid duplicate readings!
- Keypad should not be queried for a read faster than every few ms.
- It is necessary to try several gain values for optimal performance. Noise with the accelerometer is unpleasant and may cause jerky steering.
- Be sure to maintain cases that prevent PW's from going outside their ranges.
- I2C address of the accelerometer is 0x3A (ACCEL_ADDR). Point registers 0x28 and 0x29 contain the 12-bit x-axis acceleration and registers 0x2A and 0x2B the y-axis acceleration after 2 LS bits of 0x27 go high. Low byte is in lower register number. Discard low byte because of noise. Sign-extend the high byte for a 16-bit signed int; equivalent 12-bit value is in highest bits. Shift into 12 lowest bits.
- The drive motor displays asymmetrical strength in terms of forward vs. backward travel; it may be wise to have separate gains for both.
drive_pw += kdx * abs(gx) + ki * error_sum //ki is the integral gain
error_sum += gy + abs(gx)Above is one solution to this issue that uses an integral term which will increase drive motor PW over time until it is high enough to actually move the car.
- Accelerometer must be calculated for a flat zero point every time you run your program! It is suggested that 64 readings of both x and y acceleration be averaged and these averages used as offsets.
- Ask about the Update_Value function's purpose on the Lab 5 pdf. Is it something that would be called while the car is actually driving up the slope?
- The sample code of Lab 5 is encouraging declaring and setting of flags for reading the accelerometer and keypad in the PCA_ISR.
- See last two pages of the pdf for sample code.
- Refactor PCA_ISR logic for reading flags
- Refactor Car_Parameters into Starting_Parameters
- Recheck ADC function to ensure it is working properly
- HW 11
- Refactor Pause & Wait functions to not reset count variables
- Testing Read_Accel
- Create a function to handle buzzer requirement
- Wire buzzer
- Rewrite calibrate for better usability
- Test possibility of removing gain variable
- Refactor Print_Data
- Write Read_Accel
- Write Accel_Calibrate
- HW 11
- Testing Read_Accel
- Determine main loop logic
- Change flags to use __bit type
- Modified Set_Neutral
- HW 11
- Testing Read_Accel
- Determine if global keypad and keyboard are necessary
- Beginning implementation of main logic
- Determine best place for a routinely updating read_AD_input for gain
- Create xpercent and ypercent method of handling gains
- Rewrite calibrate for better usability