This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
notes:c4eng:fall2023:projects:eapx [2023/11/09 04:09] – [part2] mwinter4 | notes:c4eng:fall2023:projects:eapx [2023/11/16 01:26] (current) – [part3] acuno | ||
---|---|---|---|
Line 18: | Line 18: | ||
{{: | {{: | ||
====part3==== | ====part3==== | ||
- | description | + | The stepper motor system works well. There are two buttons. When one of the buttons is pressed, the motor rotates clockwise. When the other button is pressed, the motor rotates counterclockwise. The amount that the motor rotates is set within the program. |
+ | {{: | ||
=====cgaffne1===== | =====cgaffne1===== | ||
====premise==== | ====premise==== | ||
Line 35: | Line 35: | ||
=====clamphi3===== | =====clamphi3===== | ||
====premise==== | ====premise==== | ||
- | Use joystick to change | + | I want to use joystick to change |
====part1==== | ====part1==== | ||
- | How to read and change value | + | I used the following code to read the x,y & z values of the joystick as it moves. |
+ | |||
+ | < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include " | ||
+ | #include < | ||
+ | ///////////////////////////////////////////////////////////////////// | ||
+ | |||
+ | #define Z_Pin 1 //define pin for axis Z | ||
+ | ADCDevice *adc; // Define an ADC Device class object | ||
+ | |||
+ | ///////////////////////////////////////////////////////////////////// | ||
+ | |||
+ | int main(void){ | ||
+ | adc = new ADCDevice(); | ||
+ | printf(" | ||
+ | |||
+ | if(adc-> | ||
+ | delete adc; // Free previously pointed memory | ||
+ | adc = new PCF8591(); // If detected, create an instance of PCF8591. | ||
+ | } | ||
+ | |||
+ | else if(adc-> | ||
+ | | ||
+ | adc = new ADS7830(); // If detected, create an instance of ADS7830. | ||
+ | } | ||
+ | |||
+ | else{ | ||
+ | printf(" | ||
+ | " | ||
+ | " | ||
+ | |||
+ | | ||
+ | } | ||
+ | |||
+ | wiringPiSetup(); | ||
+ | pinMode(Z_Pin, | ||
+ | pullUpDnControl(Z_Pin, | ||
+ | while(1){ | ||
+ | int val_Z = digitalRead(Z_Pin); | ||
+ | int val_Y = adc-> | ||
+ | int val_X = adc-> | ||
+ | printf(" | ||
+ | delay(100); | ||
+ | } | ||
+ | | ||
+ | } | ||
+ | </ | ||
====part2==== | ====part2==== | ||
- | description of changes made and construction pursuits, and some details | + | I set up the leds circuit |
+ | |||
+ | < | ||
+ | val_Z = digitalRead(Z_Pin); | ||
+ | |||
+ | if(val_Z == 0){ | ||
+ | softPwmWrite(HREPIN, | ||
+ | } | ||
+ | else{ | ||
+ | softPwmWrite(HREPIN, | ||
+ | } | ||
+ | ///////////////////////////////////////////////////////////// | ||
+ | val_Y = adc-> | ||
+ | |||
+ | softPwmWrite(TWOPIN , val_Y); | ||
+ | |||
+ | ///////////////////////////////////////////////////////////// | ||
+ | val_X = adc-> | ||
+ | |||
+ | softPwmWrite(ONEPIN , val_X); | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | https:// | ||
====part3==== | ====part3==== | ||
- | description | + | When moving the joystick around the light changes color and when any of the values hit their max one of the single led's will turn on. |
+ | |||
+ | < | ||
+ | val_Z = digitalRead(Z_Pin); //read digital value of axis Z | ||
+ | |||
+ | if(val_Z == 0){ | ||
+ | softPwmWrite(HREPIN, 100); | ||
+ | | ||
+ | } | ||
+ | else{ | ||
+ | softPwmWrite(HREPIN, | ||
+ | | ||
+ | } | ||
+ | ///////////////////////////////////////////////////////////// | ||
+ | val_Y = adc-> | ||
+ | |||
+ | softPwmWrite(TWOPIN , val_Y); | ||
+ | |||
+ | if (val_Y == 247){ | ||
+ | digitalWrite (REDLED, 1); | ||
+ | } | ||
+ | else{ | ||
+ | digitalWrite (REDLED, 0); | ||
+ | } | ||
+ | ///////////////////////////////////////////////////////////// | ||
+ | </ | ||
+ | https:// | ||
=====clovell3===== | =====clovell3===== | ||
====premise==== | ====premise==== | ||
Line 115: | Line 214: | ||
====part3==== | ====part3==== | ||
- | description of finished project details (not full source code), but present your finished product | + | For the finished product, I have a seven segment display that shows a hexadecimal counter that can be slowed down or sped back up to regular speed. Pressing the blue button slows the counter down the more you press it. Pressing the red button sets the speed at which it counts back to normal. These two buttons can be used to slow or speed up the counter in a way, without having to worry about a negative delay happening. |
+ | |||
+ | {{: | ||
=====lrogers3===== | =====lrogers3===== | ||
Line 193: | Line 294: | ||
===updates=== | ===updates=== | ||
- | The MPU6050, Arduino Nano, and Servos have all been integrated on a circuit together. The servo meant to control the rudder has been fixed. Instead of using accelerometer data from the MPU6050, registers ACCEL_ZOUT_H (0x3F) and ACCEL_ZOUT_L (0x40) as specified on the register map, the code has been updated to use the gyroscopic data located at registers GYRO_ZOUT_H (0x47) and GYRO_ZOUT_L (0x48). | + | The MPU6050, Arduino Nano, and Servos have all been integrated on a circuit together. The servo meant to control the rudder has been fixed. Instead of using accelerometer data from the MPU6050, registers |
+ | |||
+ | ===code=== | ||
+ | After initial setup (everything outside of the " | ||
+ | |||
+ | This process is repeated for each Euler angle necessary (yaw, pitch, roll), so we need only to dissect one block to understand the rest: | ||
+ | < | ||
+ | //// X-axis: " | ||
+ | Wire.beginTransmission(mpu6050); | ||
+ | Wire.write(0x47); | ||
+ | Wire.endTransmission(false); | ||
+ | Wire.requestFrom(mpu6050, | ||
+ | AcX = Wire.read() << 8 | Wire.read(); | ||
+ | x_ang = AcX/180; | ||
+ | </ | ||
+ | |||
+ | The first 3 lines of this block, | ||
+ | < | ||
+ | Wire.beginTransmission(mpu6050); | ||
+ | Wire.write(0x47); | ||
+ | Wire.endTransmission(false); | ||
+ | </ | ||
+ | are mostly self-explanatory. | ||
+ | |||
+ | On the first line, we're starting an I2C connection to the MPU6050 using it's address (0x68). | ||
+ | From the second line, we queue up the information we want to send; namely, the register we're trying to access. | ||
+ | And the third line ends the transmission, | ||
+ | |||
+ | The next three lines of code: | ||
+ | < | ||
+ | Wire.requestFrom(mpu6050, | ||
+ | AcX = Wire.read() << 8 | Wire.read(); | ||
+ | x_ang = AcX/180; | ||
+ | </ | ||
+ | On the first, we're requesting bytes at the register address 0x47 (as previously set up) from the MPU6050. Specifically, | ||
+ | |||
+ | On the second line, we read the bytes we requested on the previous line. We left shift a byte to read the data from the adjacent register, 0x48, and OR those bytes together to retrieve the full information we need. | ||
+ | |||
+ | The final line is simply our scaling factor and a variable assignment. | ||
+ | |||
+ | |||
+ | |||
====part3==== | ====part3==== | ||
- | description of finished project details (not full source code), but present your finished product | + | ===video=== |
+ | https:// | ||
+ | |||
+ | ===finished project details=== | ||
+ | |||
+ | As shown in the video above, all of the electronics are attached to a glider, with the main components | ||
+ | |||
+ | There are two servos on the tail, one for the elevator and the other for the rudder. The rudder (yaw) is the " | ||
+ | |||
+ | The servos on the ailerons both function using the " | ||
+ | |||
+ | The glider is set on a flat surface before receiving power. As soon as the microcontroller, | ||
+ | |||
+ | Once the glider is calibrated, it can be freely moved wherever it needs to be moved before launching. Each of the servos will attempt to maintain a neutral position of all control surfaces. This results in a glider that maintains stabilization and heads straight (no rudder/ | ||
+ | |||
+ | The factors used to maintain these angles are described extensively in part 2. | ||
+ | This was a really fun project that I was more than happy to take part in. There are so many features that I imagine for future iterations that were beyond the scope, like having the glider follow a GPS-based path for a true " | ||
=====nbutler5===== | =====nbutler5===== | ||
====premise==== | ====premise==== | ||
Line 219: | Line 378: | ||
====part2==== | ====part2==== | ||
- | description of changes | + | The only additions |
====part3==== | ====part3==== | ||
- | description of finished | + | |
+ | eap2 is the finished | ||
+ | |||
+ | {{: | ||
+ | {{: | ||
=====rford5===== | =====rford5===== | ||
Line 247: | Line 411: | ||
====part2==== | ====part2==== | ||
The objective in eap1 is to make 3 leds flash for different distances. So for example I will have a red, blue and green LED all hooked up. When the ultra-sonic sensor reads any distance below 25cm the red LED will flash red. When the distance is between 26-50 the blue LED will flash up and the red one will turn off. When the distance exceeds 50cm the green LED will create a flash and the blue one will turn off. | The objective in eap1 is to make 3 leds flash for different distances. So for example I will have a red, blue and green LED all hooked up. When the ultra-sonic sensor reads any distance below 25cm the red LED will flash red. When the distance is between 26-50 the blue LED will flash up and the red one will turn off. When the distance exceeds 50cm the green LED will create a flash and the blue one will turn off. | ||
+ | |||
+ | {{: | ||
====part3==== | ====part3==== | ||
- | description of finished project details (not full source code), but present your finished product | + | My finished product |
+ | {{: | ||
=====wjohns11===== | =====wjohns11===== | ||
====premise==== | ====premise==== |