User Tools

Site Tools


notes:c4eng:fall2023:projects:eapx

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
notes:c4eng:fall2023:projects:eapx [2023/11/09 04:09] – [part2] mwinter4notes:c4eng:fall2023:projects:eapx [2023/11/16 01:26] (current) – [part3] acuno
Line 18: Line 18:
 {{:notes:c4eng:fall2023:projects:20231108_204827.jpg?400|}} {{:notes:c4eng:fall2023:projects:20231108_204827.jpg?400|}}
 ====part3==== ====part3====
-description of finished project details (not full source code)but present your finished product +The stepper motor system works well. There are two buttons. When one of the buttons is pressedthe motor rotates clockwise. When the other button is pressed, the motor rotates counterclockwise. The amount that the motor rotates is set within the program. 
 +{{:notes:c4eng:fall2023:projects:20231108_204902.jpg?linkonly|}}
 =====cgaffne1===== =====cgaffne1=====
 ====premise==== ====premise====
Line 35: Line 35:
 =====clamphi3===== =====clamphi3=====
 ====premise==== ====premise====
-Use joystick to change light color+I want to use joystick to change the color of a 4 legged light. 
 ====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.
  
 +
 +<blockquote>#include <wiringPi.h>
 +#include <stdio.h>
 +#include <stdlib.h>
 +#include <softPwm.h>
 +#include "ADCDevice.cpp"
 +#include <time.h>
 +/////////////////////////////////////////////////////////////////////
 +
 +#define Z_Pin 1 //define pin for axis Z
 +ADCDevice *adc; // Define an ADC Device class object
 +
 +/////////////////////////////////////////////////////////////////////
 +
 +                int main(void){
 +        adc = new ADCDevice();
 +        printf("Program is starting ... \n");
 +
 +        if(adc->detectI2C(0x48)){ // Detect the pcf8591.
 +        delete adc; // Free previously pointed memory
 +        adc = new PCF8591(); // If detected, create an instance of PCF8591.
 +        }
 +
 +        else if(adc->detectI2C(0x4b)){// Detect the ads7830
 +         delete adc; // Free previously pointed memory
 +         adc = new ADS7830(); // If detected, create an instance of ADS7830.
 +        }
 +
 +        else{
 +        printf("No correct I2C address found, \n"
 +        "Please use command 'i2cdetect -y 1' to check the I2C address! \n"
 +        "Program Exit. \n");
 +
 + return -1;
 + }
 +
 +        wiringPiSetup();
 +        pinMode(Z_Pin,INPUT); //set Z_Pin as input pin and pull-up mode
 +        pullUpDnControl(Z_Pin,PUD_UP);
 +        while(1){
 +                int val_Z = digitalRead(Z_Pin); //read digital value of axis Z
 +                int val_Y = adc->analogRead(0); //read analog value of axis X and Y
 +                int val_X = adc->analogRead(1);
 +        printf("val_X: %d ,\tval_Y: %d ,\tval_Z: %d \n",val_X,val_Y,val_Z);
 +        delay(100);
 + }
 + return 0;
 +}
 +</blockquote>
 ====part2==== ====part2====
-description of changes made and construction pursuitsand some details of C program interaction+I set up the leds circuit and using softPwmWrite made it so the lights numerical sate coresponded to the x,y or z value it was linked to. Although the z value can only be 1 or 0 so when it equaled 0 the third pin to the light would equal 100. 
 + 
 +<blockquote>                 
 +                val_Z = digitalRead(Z_Pin); //read digital value of axis Z 
 + 
 +                if(val_Z == 0){ 
 +                        softPwmWrite(HREPIN, 100); 
 +                } 
 +                else{ 
 +                        softPwmWrite(HREPIN, 0); 
 +                } 
 +                ///////////////////////////////////////////////////////////// 
 +                val_Y = adc->analogRead(0); //read analog value of axis X and Y 
 + 
 +                softPwmWrite(TWOPIN , val_Y); 
 + 
 +                ///////////////////////////////////////////////////////////// 
 +                val_X = adc->analogRead(1); 
 + 
 +                softPwmWrite(ONEPIN , val_X); 
 + 
 + 
 +</blockquote> 
 + 
 +https://youtu.be/nE6sX5U6sz4
  
 ====part3==== ====part3====
-description of finished project details (not full source code), but present your finished product+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. 
 + 
 +<blockquote>                ///////////////////////////////////////////////////////////// 
 +                val_Z = digitalRead(Z_Pin); //read digital value of axis Z 
 + 
 +                if(val_Z == 0){ 
 +                        softPwmWrite(HREPIN100); 
 +                         digitalWrite (GRNLED, 1); 
 +                } 
 +                else{ 
 +                        softPwmWrite(HREPIN, 0); 
 +                         digitalWrite (GRNLED, 0); 
 +                } 
 +                ///////////////////////////////////////////////////////////// 
 +                val_Y = adc->analogRead(0); //read analog value of axis X and Y 
 + 
 +                softPwmWrite(TWOPIN , val_Y); 
 + 
 +                        if (val_Y == 247){ 
 +                                digitalWrite (REDLED, 1); 
 +                        } 
 +                        else{ 
 +                                digitalWrite (REDLED, 0); 
 +                        } 
 +                ///////////////////////////////////////////////////////////// 
 +</blockquote>
  
 +https://www.youtube.com/playlist?list=PLpR-bDNsxP5swtO5DQ5bhKbo7tLxqU75V
 =====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. 
 + 
 +{{:notes:c4eng:fall2023:projects:screen_shot_2023-11-15_at_5.12.52_pm.png?400|}}
  
 =====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 <wrap hi>ACCEL_ZOUT_H</wrap> (0x3F) and <wrap hi>ACCEL_ZOUT_L</wrap> (0x40) as specified on the register map, the code has been updated to use the gyroscopic data located at registers <wrap hi>GYRO_ZOUT_H</wrap> (0x47) and <wrap hi>GYRO_ZOUT_L</wrap> (0x48). 
 + 
 +===code===  
 +After initial setup (everything outside of the "main" loop() function); where we create our Servo objects and attach them (via Servo.h), initialize important variables, and set up communications to our mpu6050; the remaining code simply reads data from the MPU6050, scales down the data by a factor of 180, and delivers that "angle" in degrees to our servos.  
 + 
 +This process is repeated for each Euler angle necessary (yaw, pitch, roll), so we need only to dissect one block to understand the rest:  
 +<code> 
 +  //// X-axis: "Yaw", although this would normally be the Z-axis 
 +  Wire.beginTransmission(mpu6050); 
 +  Wire.write(0x47); // gyroscope instead of accelerometer  
 +  Wire.endTransmission(false); 
 +  Wire.requestFrom(mpu6050, 4, true); 
 +  AcX = Wire.read() << 8 | Wire.read(); 
 +  x_ang = AcX/180; 
 +</code>  
 + 
 +The first 3 lines of this block,  
 +<code> 
 +  Wire.beginTransmission(mpu6050); 
 +  Wire.write(0x47); // gyroscope instead of accelerometer  
 +  Wire.endTransmission(false); 
 +</code>  
 +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, sending that information on its merry way over to the MPU6050.  
 + 
 +The next three lines of code:  
 +<code>  
 +  Wire.requestFrom(mpu6050, 4, true); 
 +  AcX = Wire.read() << 8 | Wire.read(); 
 +  x_ang = AcX/180; 
 +</code> 
 +On the first, we're requesting bytes at the register address 0x47 (as previously set up) from the MPU6050. Specifically, we're requesting 4 bytes. Our final argument, <wrap hi>true</wrap>, releases the MPU6050 from the connection.  
 + 
 +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://youtu.be/0KfVitGQHjw 
 + 
 +===finished project details=== 
 + 
 +As shown in the video above, all of the electronics are attached to a glider, with the main components (Arduino Nano, MPU6050, breadboard, etc.stored in the fuselage. Wires have been ran under the red material on the wings from the "brain" in the fuselage to each aileron servo.  As seen in the video, there are also wires wrapped around the black rod (arrow shaft) reaching to the servos on the tail.   
 + 
 +There are two servos on the tail, one for the elevator and the other for the rudder. The rudder (yaw) is the "X-axis" as described in the code, but this is due to the mpu6050 being setup in an atypical way. That is to say, the relative orientation of the mpu6050 was arbitrarily chosen and the axes were programmed for that perspective.  
 + 
 +The servos on the ailerons both function using the "Y-axis" (roll), and the elevator servo uses the "Z-axis."  
 + 
 +The glider is set on a flat surface before receiving power. As soon as the microcontroller, our Arduino Nano, receives power, the code starts. When the Arduino Nano turns on and supplies power to the MPU6050, the whole system calibrates itself to the orientation it currently sits at. This is why we need to make the glider level before supplying power.  
 + 
 +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/aileron movement for turning).  
 + 
 +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 "autopilot" system. 
 =====nbutler5===== =====nbutler5=====
 ====premise==== ====premise====
Line 219: Line 378:
  
 ====part2==== ====part2====
-description of changes made and construction pursuitsand some details of C program interaction+The only additions made, was a Blinking REDLED, which indicated whenever the CPU temperature would update. The interesting thing about it is you have to use one of the pin slots on the LCD module D7. 
  
 ====part3==== ====part3====
-description of finished project details (not full source code)but present your finished product+ 
 +eap2 is the finished programwhere the lcd module outputs the pi's CPU temperature and the time stamp associated with the temp readout. The temperature output is in Celsius and was 2 decimal places XX.XX. The program for the CPU temp updates every second, so I added a blinking led program for whenever the LCD display updates, giving a visual indicator.      
 + 
 +{{:notes:c4eng:fall2023:projects:lcd_circuit.png?nolink&400 |}} 
 +{{:notes:c4eng:fall2023:projects:led_circuit_.png?nolink&400 |}} 
  
 =====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.
 +
 +{{:notes:c4eng:fall2023:projects:img-7706.jpg?linkonly|}}
 ====part3==== ====part3====
-description of finished project details (not full source code), but present your finished product +My finished product consist of the ultrasonic Ranger, 3 LEDs and a buzzer. The LEDs turn on and off with certain distances. So the red will do 0-25, blue 26-50 and green 51-100. When the distance reads over 50 centimeters, the buzzer will begin to BUZZ! Using if and else statements for my lights and buzzer made this whole thing possible. 
 +{{:notes:c4eng:fall2023:projects:img-7732.jpg?400|}}
 =====wjohns11===== =====wjohns11=====
 ====premise==== ====premise====
notes/c4eng/fall2023/projects/eapx.1699502971.txt.gz · Last modified: 2023/11/09 04:09 by mwinter4