41
Iowa State University AerE 294X/AerE 494X Make to Innovate M:2:I Milestone 1 Telemetry System and Dashboard Project: Cardinal Flight Team: Electrical Team Author(s): Alex Nielsen Angie Burke Christopher McGrory Mitchell Skatter Kathryn Spierings Ryan Story Role: Team Leader Team Member Team Member Team Member Team Member Team Member Faculty Adviser: Dr. Ran Dai March 10, 2017

M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

Iowa State University

AerE 294X/AerE 494X

Make to Innovate

M:2:I Milestone 1 TelemetrySystem and Dashboard

Project: Cardinal FlightTeam: Electrical Team

Author(s):Alex NielsenAngie BurkeChristopher McGroryMitchell SkatterKathryn SpieringsRyan Story

Role:Team Leader

Team MemberTeam MemberTeam MemberTeam MemberTeam Member

Faculty Adviser: Dr. Ran Dai

March 10, 2017

Page 2: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

Contents

Abstract 2

1 Introduction 3

2 Background 32.1 Deliverable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.2 Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

3 Problem Identification 5

4 Problem Solution 5

5 Experimental Validation 85.1 Experimental Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . 85.2 Experimental Procedure . . . . . . . . . . . . . . . . . . . . . . . . . 95.3 Experimental Results . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

6 Discussion 11

7 Conclusion 11

8 Acknowledgments 11

A Appendix 12A.1 Operators Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12A.2 Arduino Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17A.3 Processing Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

1

Page 3: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

Abstract

The Cardinal Flight Team is working to build a solar powered unmanned aerialvehicle, named Arrow. The team will be divided into groups regarding individualpieces of its construction. This milestone report will cover the first set of tasks forthe Electrical Team for the Spring 2017 term. Throughout this report, the processthe Electrical Team took to complete milestone 1 will be explained with detail.The report will discuss how the team achieved its goal of devising a way for Arrowto communicate and store flight data that will be taken during a flight. Whilestaying on schedule, the team was very successful in achieving a working system totransmit and store this telemetry data from the sensors attached to the aircraft. Thedeliverables for this milestone include creating a wiring schematic of the completesystem, proof of electronics in operation, finalized Arduino and Processing codes,and an operators manual to guide users in installation and operation. This milestoneis the first step for Arrow to be able to record and transmit data. This is importantbecause it will help the goals of Cardinal Flight to further understand solar poweredflight. Receiving data that will tell more about what is going on during a flight andwill further the team’s knowledge of how to better design a similar aircraft in thefuture.

2

Page 4: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

1 Introduction

Milestone 1 of Cardinal Flight Electrical Team during Spring 2017 is to completethe telemetry system and dashboard design for the designed aircraft Arrrow. Morespecifically, create a system that will be able to record, transmit, and store dataduring flight while at the same time, analyze it real time at a ground station. Atelemetry system will send data taken from on board sensors to this ground stationwith a user friendly dashboard that allows a person to easily interpret the data.In addition to this, an operator’s manual will assist anyone attempting to use thetelemetry system and ground station or in some cases help troubleshoot it.

2 Background

Cardinal Flight’s overall goal is to design, build, and test a high efficiency smallunmanned aerial vehicle (sUAV) using off the shelf components. The Cardinal FlightElectrical Team was formed to handle all electrical components of the aircraft beingconstructed. These electrical components consist of motors, speed controllers, flightcontrollers, batteries, servos, transmitters, and receivers. For this semester and theprevious semester, the team was to help integrate these various electrical componentsinto Arrow. During the previous semester, the team began construction of the solarsystem of Arrow and recorded the process of the construction. The team constructedthis solar system as a demonstration for future presentations and testing. This solarsystem was tested under Dr. Ran Dai’s UV lights due to cloudy weather, to ensurethat the construction was successful. The primary function of this team is to ensurethe success of all these components working together during operation in Arrow.To fulfill this function, the team performs initial calculations using a theoreticalapproach on different configurations of a proposed electrical system. Once satisfiedwith the calculations, the team obtains, builds, tests, and installs these components.Finally, the goal is to get the hardware to a working state prior to installing onboard the aircraft, then install it onto Arrow.

2.1 Deliverable

The deliverables for the first milestone of the Electrical Team:

1. Wiring Schematic of Complete System

2. Pictures and Video of the electronics in operation

3

Page 5: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

3. Finalized Arduino and Processing Codes

4. Report outlining the operation and performance

5. Operators manual to guide users in installation and operation

2.2 Tasks

The tasks and dates for milestone one:

1. Complete Wiring Schematic. (02/03/17)

2. Have Arduino able to record data. (02/17/17)

3. Be able to transmit data to ground station and record. (03/03/17)

4. Code in new sensors to Processing sketch. (02/10/17)

5. Finish Processing dashboard. (03/03/17)

4

Page 6: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

3 Problem Identification

The electrical team for this milestone was required to create a telemetry system anda user interface for Arrow. Theoretically, while the aircraft is in flight, solar panelswill charge its batteries while the batteries power the motor and other parts of thesUAV. Having sensors that measure the current and voltage at each stage will helpunderstand what is happening at each moment during flight. Along with currentand voltage data collected, the batteries will need to be closely monitored in case onefails. Battery failure could result in an on board fire and monitoring each batterytemperature will help prevent this.

Now that this data is being collected, it needs to be stored and transmitted. Aground station will be needed to receive the data transmitted. The data going tothis ground station will be read by a person. In order for this person to efficientlyunderstand the data, a dashboard of graphs and gauges will visually help theiranalysis of the incoming data. Finally, an operator’s manual will need to be madeto ensure the correct procedures are carried out when using the system. Afteridentifying the above problems, the following problem solution will explain in detailhow these issues were executed successfully.

4 Problem Solution

The team’s solution to the problem identified above is to use an Arduino board withthe appropriate sensors attached that will transmit data to a personal computer (PC)running a Processing sketch. An Arduino board is able to take in data from a widerange of different types of sensors. In this case, the sensors needed are temperature,current, and voltage. After the Arduino collects the data from the sensors, it willwrite the data values to an attached SD card. Then, using an RFD900 transmitter,the Arduino board is able to instantaneously send out the data it collects to anRFD900 receiver. This receiver is plugged into the PC running a Processing sketch.Processing is a coding language that is designed around graphics use. For this case, adashboard that will display all the incoming data will be designed using Processing.This dashboard will be easy to read and understand. In Figure 1 below the teamcreated a wiring schematic of the entire system. This was done to understand eachcomponent, how it will connect, and where it will be placed within the system.Along with this plan, the team planned out a rough idea for the dashboard layout(see Figure 2).

5

Page 7: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

Figure 1: Wiring Schematic

6

Page 8: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

Figure 2: Dashboard Layout Drawing

7

Page 9: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

5 Experimental Validation

The first milestone for the Electrical Team did not include much physical experi-mental data, the only true validation was the dashboard showing all the gauges andbar graphs moving in relation to the data sensors being manipulated. This meansif the entire system from a sensor on the aircraft, to the dashboard on the groundworks the team achieved the goal of milestone one.

5.1 Experimental Theory

Before physically setting up any sensors, part of our milestone involved planningout the system as a whole. This planning was done by making a wiring schematic(Figure 1) which ultimately helped find potential problems before we ever toucheda sensor or started coding. This schematic also was a good reference in case a wirewas accidentally pulled out, then anyone should be able to look at the diagram andknow exactly where or what it should be plugged back into. The expected result wasto make sure there are little to no problems when going about building the system.

The sensors are to be connected to an Arduino board and coded in. For the voltageand current sensors, many examples helped in getting these to work; however, forthe temperature sensors, this was not the case. These temperature sensors arewhat known as a “one-wire” sensor, meaning the sensor connects to the Arduinoboard with a single data wire yet still powered with power and ground wires. Thisbecomes a trickier problem when one wants to attach multiple “one-wire” sensors.In order to do this, one must connect each added sensor in parallel meaning thereare multiple sensors sending data over one data wire to the Arduino board. So,the code must be able to determine difference between all the sensors on that onewire. The way it does this is each “one-wire” sensor has its own address and thecode written in this case will spend about 6 seconds on startup searching for anyaddresses it can find. Then, for each address it finds, it creates a separate variablefor each address (sensor). Finally, the system can run and store a data value foreach “one-wire” sensor attached. For Arrow, there are four battery packs to monitorthe temperature of each; so, our Arduino code finds each temperature sensor is thenable to record each individual battery pack’s temperature.

Next, the solution in transmitting the data is by using an RFD900 radio transmitterand an RFD900 radio receiver on the ground connected to the ground station PC.These radios will automatically connect to each other when powered up and take alittle bit of coding on each end to send the data and receive the data.

On top of the planning for the system, the dashboard is expected to be easy to read

8

Page 10: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

and straightforward to use. Making this dashboard easy to read involves havinggauges and graphs that make common sense. An increase in temperature shouldresult in a bar graph rising as opposed to decreasing. Also, having it change colorsfrom green, yellow, to red as the temperature increases is another way to make thedata make more sense to the operator.

5.2 Experimental Procedure

The team went about coding and attaching all the sensors to the Arduino so allthe data could be read and stored it on an SD card shield. The procedures fortesting all the sensors involved testing only one sensor at a time. This made iteasier to debug an error that occurs when coding because you have then limitedthe number of variables that could be causing errors. This was also the procedurewhen assembling all the sensors together, one sensor at a time then test. Thebiggest problem of the entire system arose when multiple temperature sensors wereconnected. When testing one at a time, they worked fine; however, when a secondone was added, this made the code change much more. Like stated earlier, thiswas all due to the sensor being a “one-wire” type sensor. After searching onlineendlessly for an example of how multiple “one-wire” sensors work, a solution waseventually found and tested. The sensors were tested by heating up each individualtemperature sensor and seeing a single data readout change compared to the otherthree data readouts for temperature. Then, for the voltage and current sensors tests,the motor was connected WITHOUT the propeller attached. The motor was spunat low rpm and given a small friction load with a hand to show the current sensordata would then rise. Doing this with both current/voltage sensors ensured theyboth worked. Sending the data to the transmitter resulted in the receiver feeding thedata via USB port to the PC. This data is shown graphically using the Processingcode.

The same approach was conducted for the dashboard. As more Processing code waswritten, every so often the team member would run the code to make sure the fewnew lines of code did not cause any error. Then, to test the gauges and bar graphwere receiving data, the electrical team placed the code to create gauges and thebar graph into different scripts then inputted data to see if the the graphs behavedas expected.

In creating this graphical interface, multiple people were asked for their input onwhat visual graphs would be visually easy to read and interpret. The solution tocoding this visual dashboard was using a program called Processing. This language isbased on C++ and has a coordinate plane that helps place various visual components

9

Page 11: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

(such as gauges or bar graphs) in their respected areas. To place the repeated gaugesin their proper positions, a class was created in the code. The result was the desiredlocation of a gauge only has to be entered once and it is then the code for the bargraph was constructed and then adjusted three times to get the 4 bar graphs toshow up on the dashboard.

After the both systems were constructed, the merging of the two came next. Thisbrought up a few problems because one team member had coded data to store asa line where the other member wrote the other to take in a column of data. A fewhours of debugging later and the system was operational! In Figure 3 shows theactual wired system in operation and the dashboard in operation in Figure 4.

5.3 Experimental Results

After merging the Arduino and dashboard, the data was able to be recorded, trans-mitted, and plotted on the dashboard. The dashboard moved the gauges in responseto the current draw change and the temperature bar graphs changed in the correctmanner when manipulating the temperature sensors. Figure 3 and Figure 4 bothshow the system in full operation.

10

Page 12: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

6 Discussion

For the most part, the system came together fairly well. Besides a few dead endswhen coding, there was always a team member who stepped up to try and find asolution. Having quite a few more members on the electrical team this semesterhelped a lot as far as getting work done. That being said, it was really hard whencoding because that can really only be done by one person. When coding, peoplehave different approaches and when the team was passing the code around, it causedmore errors to occur than if one person did it. This did make it hard on some becausealternatively sitting behind the person coding and offering suggestions every onceand awhile was not very productive for them. So, having six team members on theElectrical Team definitely had its advantages and disadvantages.

Looking forwards at milestone 2, the team will have to reconstruct the entire systeminside the aircraft. This could cause problems in making sure things are pluggedback into the same places. Because of milestone one’s deliverable of the wiringschematic, this process should prove easier than figuring everything out again.

7 Conclusion

Overall, milestone one was a success and was ample work to keep team membersworking on solving problems and learning. The biggest struggle of this milestone wasdebugging code. The error would sometimes be a software issue or a hardware issue;however, the team was able to work together well helping to solve each problem.Even though the team is successful in having the system working the way it should,there is always room for improvement and the system will for sure be modified alongthe way during the next milestone to improve functionality, visual appeal, and easeof use. In the end, the system is ready to start being installed in the aircraft as soonas the fuselage is assembled.

8 Acknowledgments

Arduino and Processing Website and Forums

11

Page 13: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

1

Cardinal Flight Arrow Operator Manual

Spring 2017

Table of Contents 1. Abstract 3

2. Set up procedure 4

3. Wiring Schematic 6

4. Processing Code 7

5. Arduino Code 8

6. List of Electrical Components 9

Abstract: The purpose of the Arrow Operator Manual is act as reference for set-up, operation, and data

storage for the current and future Cardinal Flight members. This manual explains the order of

operations from a successful start-up to post-processing, as well as explains the various

components and their locations within the system.

Things to note:

- Make sure to double check connections before plugging any power source into system.

- Be careful of propellor! Always remove propeller for a ground test.

- Ground station computer needs the RFD 900 telemetry ratio plugged in via usb

Set up procedure: This procedure should be followed as a checklist:

1. Hardware - Check system components are plugged in and in correct location

a. EXCEPT the battery, everything should be plugged in according to the “wiring

schematic”

b. Reference the “components list” (pg.) for the name, location, function/purpose

c. Reference the “wiring diagram” (pg.) to make sure things are plugged into where

they should be

2. Coding languages

a. Processing is needed on ground station computer to receive telemetry from system

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

A Appendix

A.1 Operators Manual

12

Page 14: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

2

i. Run processing code on ground station computer to link up the system to

the ground station.

ii. Will need telemetry radio (RFD 900) with the usb plugged into ground station

computer

b. Arduino - only used to make adjustments to code if needed

3. Steps to operate - By this step, you should have double checked wires are all connected

where they should be and have processing downloaded on the ground station computer.

a. Step 1: Aircraft setup

i. Have ground station computer, aircraft, and battery close together

ii. Check for loose wires on aircraft

iii. Make sure SD card is plugged in

iv. Remove propellor

(image)

b. Step 2: Dashboard setup

i. Plug RFD900 receiver module into usb port on ground station computer

ii. Run processing code “dashboardARROW.pde”

(image)

c. Step 3: Powering on

i. into the aircraft and wait 10 seconds for the system to start up. After 10

seconds has passed, the dashboard should be reading telemetry data from

the aircraft automatically.

ii. Plug battery into aircraft

iii. Wait 10 seconds for it to start up

iv. After 10 seconds, check ground station to see guages are moving

(image)

d. Step 4: Flight

i. RFD900 antenna should have minimal obstruction

ii. Orientate antennas at 90 degrees for best connection

e. Step 5: Shutdown.

i. Click the “save” button in the dashboard

ii. Close dashboard

iii. Unplug the battery to the aircraft

iv. Remove the SD card from the arduino to retrieve the onboard data file

Wiring Schematic: The diagram below is sketch of the Arduino wiring schematic for Arrow.

When checking, DO NOT PLUG IN BATTERY. The battery is only connected right before

operation.

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

13

Page 15: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

3

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

14

Page 16: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

4

Processing Program Start-up:

1. Make sure to download Processing on your computer from the internet

2. Download Processing code from Cardinal Flight > Spring 2017 > Electrical Team > Code

2017 > Cardinal_Flight_ARROW_Dashboard_Code

a. Code: dashboardARROW.pde

3. Run

4. Dashboard window should appear and gauges will not be moving until it receives data from

aircraft.

Arduino Program Start-up:

1. Download Arduino code from Cardinal Flight > Spring 2017 > Electrical Team > Code 2017

> Cardinal_Flight_ARROW_Arduino_Code

a. Code: Cardinal_Flight_ARROW_Arduino_Code_3_introduce_processing.ino

2. Download the following directories from Arduino program

a. Open Arduino > Sketch > Include Library > Manage Libraries

i. Search for following libraries within Arduino

1. SPI.h

2. SD.h

3. OneWire.h

4. DallasTemperature.h

**Note: these libraries must be saved within Cardinal_Flight_ARROW_Arduino_Code_3_introduce_proecessing.ino folder**

3. Open Cardinal_Flight_ARROW_Arduino_Code_3_introduce_processing.ino within Arduino

program

a. Code is commented in regards to function duties

i. Pre-process Allocation

1. Sets up libraries within SD card, finds temperature sensors, saves

data to LOGGER00.txt on SD card

ii. Section 1

1. Initialization of SD card, locates temperature sensors

iii. Section 2

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

15

Page 17: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

5

1. Reads temperature sensor data (180A), writes temperature and

voltage data to LOGGER00.txt file on SD card, transmitted to

Cardinal Flight Dashboard via Processing

4. Connect the arduino mega board with the usb cable to the arduino connector cable

5. Run Cardinal_Flight_ARROW_Arduino_Code_3_introduce_processing.ino program by

clicking “Verify” to check code, then “Upload” to upload code to arduino mega

a. If you only want to see data coming in: click on the “serial monitor” in the upper right

hand corner and set the “Baud rate” to 57600.

Components List 1. Arduino Mega

a. Has a circuit board on top called a Data logger “shield”

b. SD card needs to be inserted into slot before powered up

c. 4 main wires from shield to arduino mega

i. - 53 to L3

ii. - Arduino pin 50 to datalog pin 12

iii. - Arduino pin 51 to datalog pin 11

iv. - Arduino pin 52 to datalog pin 13

v. - Arduino pin 53 to datalog pin gs

2. Voltage Regulator

a. 8v - Supplies voltage to Arduino

3. Lipo Batteries

a. Powers entire system for the aircraft

b. These 4 batteries are connected in parallel

c. 6 lithium ion cells fully charged should read 25.2 volts and when discharged should

read 21.0 volts

4. ESC (“Electronic speed controller”)

a. Controls the motor

b. Can take up to 50 amps

c. Has power in from battery, signal wire going to receiver, connected to motor with 3

wires

5. Motor

a. High efficiency U8 series motor from T-motor

b. The three wires connected to the esc

6. Receiver

a. Takes information from transmitter

b. Connected to the ESC and all servos

7. RFD900 (transmitter)

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

16

Page 18: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

A.2 Arduino Code

17

Page 19: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

18

Page 20: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

19

Page 21: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

A.3 Processing Code

///////////////////////////////////////////////////////// //// CARDINAL FLIGHT TELEMETRY DASHBOARD //// V3.0 01/23/2017 //// /////////////////////////////////////////////////////////

//−−−−− DECLARATIONS −−−−−−−−−−−−−−−−−−−−−−−−−−−−−− (0)import pro c e s s i ng . s e r i a l . ∗ ;

f loat s ta r tAng l e = 145 ;f loat spanAngle = 250 ;f loat [ ] l o c a lAng l e s = {0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0} ;f loat a ;f loat b ;f loat oldWidth ;f loat oldHeight ;f loat gaugeDiameter ;int numOfGauges ;PImage img ; // Declare a v a r i a b l e to r e f e r ence Header imagePFont font ; // Declare a v a r i a b l e to r e f e r ence the FontTable t ab l e ; // Declare v a r i b l e to r e f e r ence Tablef loat minTemp = 20 ; // Minimum temperature va luef loat maxTemp = 45 ; // Maximum temperature va luef loat tempY = 400 ; // Top coord ina te o f temp d i s p l a yf loat tempX = 221 ; // Le f t coord ina te o f temp d i s p l a y .

// Disp lay Time & Dateint s ec = second ( ) ; // Values from 0 − 59int min = minute ( ) ; // Values from 0 − 59int h = hour ( ) ; // Values from 0 − 23int d = day ( ) ; // Day o f Month 1 − 31int mon = month ( ) ; // Month o f Year 1−12int y = year ( ) ; // Year 20XX

St r ing s t r s e c = s t r ( s ec ) ; //Convert i n t to S t r ingSt r ing strmin = s t r (min ) ; // ’ ’St r ing s t rh = s t r (h) ; // ’ ’St r ing s t rd = s t r (d) ; // ’ ’St r ing strmon = s t r (mon) ; // ’ ’St r ing s t ry = s t r ( y ) ; // ’ ’St r ing time ;S t r ing date ;

// Data r e c e i v ed from the s e r i a l por t :f loat Var1 = 0 ; // Tempf loat Var2 = 0 ; // Temp

20

Page 22: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

f loat Var3 = 0 ; // Tempf loat Var4 = 0 ; // Tempf loat Var5 = 0 ; // Vol tagef loat Var6 = 0 ; // Currentf loat Var7 = 0 ;f loat Var8 = 0 ;f loat Var9 = 0 ;f loat Var10 = 0 ;

S e r i a l myPort ; // The s e r i a l por t

ADLinechart ampsGraph ;ADLinechart voltsGraph ;ADLinechart wattsGraph ;ADLinechart tempsGraph ;t imer t ;int i =0, d e l t a =1;int dataSets =1;

dualCircularGauge amps = new dualCircularGauge (300 , ”Amperage (A) ” , ”Out” , ” In” ) ;

dualCircularGauge v o l t s = new dualCircularGauge (300 , ”Voltage (V) ” , ”Out” , ” In” ) ;

// dualCircu larGauge wat t s = new dualCircu larGauge (300 , ”Wattage (W) ” , ”Out” , ” In ”) ;

//graphBox ampsGraph = new graphBox () ;

void setup ( ) {s i z e (1800 , 1000) ;oldWidth = width ;o ldHeight = he ight ;s u r f a c e . s e tRe s i z ab l e ( true ) ;noStroke ( ) ;//noLoop () ; // Run once and s top

background (0) ;

img = loadImage ( ”header2 . png” ) ; // Load Cardinal F l i g h t Header Image

numOfGauges = 3 ;gaugeDiameter = 300 ;

i f ( ( numOfGauges∗gaugeDiameter )<=width ) {amps . se tCenter ( ( width /2)−(gaugeDiameter ) −(0.02∗width )+200 , (1 .553∗

gaugeDiameter ) /2+140) ;v o l t s . s e tCenter ( width /2+300 , (1 .553∗ gaugeDiameter ) /2+140) ;// wat t s . se tCenter ( ( width /2)+(gaugeDiameter ) +(0.02∗width ) , (1 .553∗

gaugeDiameter ) /2+140) ;

21

Page 23: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

}

// I n i t i a l i z e the d i a l guaguesamps . minValue = 0 . 0 ;amps . maxValue = 10 . 0 ;amps . valueOption = 1 ;amps . redGreenValue = 1 . 0 ;amps . greenRedValue = 9 . 0 ;

v o l t s . minValue = 20 ;v o l t s . maxValue = 25 . 2 ;v o l t s . valueOption = 2 ;v o l t s . redGreenValue = 20 . 5 ;v o l t s . greenRedValue = 25 . 0 ;

//−−−−−−−−−−−−−−− .CSV TABLE −−−−−t ab l e = new Table ( ) ; // Create a Table to Store Var i b l e s

t ab l e . addColumn( ”Time : ” ) ; // Column A T i t l et ab l e . addColumn( ” So la r Voltage (V) : ” ) ; // Column B T i t l et ab l e . addColumn( ” So la r Amperage (mA) : ” ) ; // Column C T i t l et ab l e . addColumn( ” So la r Wattage (W) : ” ) ; // Column D T i t l et ab l e . addColumn( ” Fina l Voltage (V) : ” ) ; // Column E T i t l et ab l e . addColumn( ” Fina l Amperage (A) : ” ) ; // Column F T i t l et ab l e . addColumn( ” Fina l Wattage (W) : ” ) ; // Column G T i t l et ab l e . addColumn( ”Temp 1 (F) : ” ) ;t ab l e . addColumn( ”Temp 2 (F) : ” ) ;t ab l e . addColumn( ”Temp 3 (F) : ” ) ;t ab l e . addColumn( ”Temp 4 (F) : ” ) ;t ab l e . addColumn( ”Marked : ” ) ;//−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

//−−−−−−−−−−−−− SERIAL SETUP −−−−−i f ( S e r i a l . l i s t ( ) . l ength > 0) {

pr intArray ( S e r i a l . l i s t ( ) ) ; // L i s t a l l t he a v a i l a b l e s e r i a l po r t s

// I know tha t the f i r s t por t in the s e r i a l l i s t on my mac// i s a lways my Arduino , so I open S e r i a l . l i s t ( ) [ 0 ] .// Open whatever por t i s the one you ’ re us ing .myPort = new S e r i a l ( this , S e r i a l . l i s t ( ) [ 0 ] , 57600) ;// don ’ t genera te a s e r i a lEv en t ( ) un l e s s you ge t a newl ine

charac t e r :myPort . bu f f e rUn t i l ( ’ \n ’ ) ;

}//−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

}

void draw ( ) {

22

Page 24: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

background (0) ;f ont = createFont ( ” univers−black− i t a l i c −wd. t t f ” ,48 , true ) ;textFont ( f ont ) ;

// Disp lay Header Imageimage ( img , ( width /2)−(img . width /2) , 0) ; // header2 . png (Top−Centered )

i f ( oldWidth != width ) {amps . se tCenter ( ( width /2)−(gaugeDiameter ) −(0.02∗width ) , (1 . 553∗

gaugeDiameter ) /2+140) ;v o l t s . s e tCenter ( width /2 , (1 . 553∗ gaugeDiameter ) /2+140) ;// wat t s . se tCenter ( ( width /2)+(gaugeDiameter ) +(0.02∗width ) , (1 .553∗

gaugeDiameter ) /2+140) ;}

a = mouseX ;b = mouseY ;amps . aValue = 5 ;amps . bValue = 8 ;amps . update ( ) ;v o l t s . aValue = 25 ;v o l t s . bValue = 22 . 0 ;v o l t s . update ( ) ;

saveAndExit ( ) ;

displayTime ( ) ;

markLog ( ) ;

drawTemps ( ) ;

}

//−−−−− DRAW GRAPHS −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−void drawGraph ( ){

i f ( t . over ( ) ){

ampsGraph . pushValue (mouseY , i , 0 ) ;ampsGraph . pushValue (mouseX , i , 1 ) ;voltsGraph . pushValue (mouseY , i , 0 ) ;voltsGraph . pushValue (mouseX , i , 1 ) ;wattsGraph . pushValue (mouseY , i , 0 ) ;wattsGraph . pushValue (mouseX , i , 1 ) ;tempsGraph . pushValue (mouseY , i , 0 ) ;tempsGraph . pushValue (mouseX , i , 1 ) ;i+=de l t a ;t . r e s e t ( ) ;

23

Page 25: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

}ampsGraph . update ( ) ;voltsGraph . update ( ) ;wattsGraph . update ( ) ;tempsGraph . update ( ) ;

}//−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

//−−−−− SERIAL READ −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−void s e r i a lEven t ( S e r i a l myPort ) {

// ge t the ASCII s t r i n g :St r ing i nS t r i n g = myPort . r e adSt r i ngUnt i l ( ’ \n ’ ) ;

// i f ( i nS t r i n g != nu l l ) {// trim o f f any whi te space :i nS t r i n g = trim ( i nS t r i n g ) ;// s p l i t the s t r i n g on the commas and conver t the// r e s u l t i n g s u b s t r i n g s in t o an i n t e g e r array :f loat [ ] data = f loat ( s p l i t ( inSt r ing , ” ” ) ) ;// i f the array has at l e a s t 6 elements , you know// you got the whole t h ing . Put the numbers in the// Data v a r i a b l e s :// i f ( data . l e n g t h > 0) {

Var1 = data [ 0 ] ;Var2 = data [ 1 ] ;Var3 = data [ 2 ] ;Var4 = data [ 3 ] ;Var5 = data [ 4 ] ;Var6 = data [ 5 ] ;//Var7 = data [ 6 ] ;//Var8 = data [ 7 ] ;//Var9 = data [ 8 ] ;//Var10 = data [ 9 ] ;

p r i n t l n (Var1 + ”\ t ” + Var2 + ”\ t ” + Var3 + ”\ t ” + Var4 + ”\ t ” +Var5 + ”\ t ” + Var6 ) ; //+ ”\ t ” + Var7 + ”\ t ” + Var8 + ”\ t ” +Var9 + ”\ t ” + Var10 ) ;

//}//}

}//−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

//−−−−−−−−−−−−−−−−Save Table Button−−−−−−−−−−−−−−−−−void saveAndExit ( ) {

//−−−−− VARIBLE STORE & SAVE −−−−− (2h )// Add Elements to TableTableRow newRow = tab l e . addRow( ) ;

newRow . s e t S t r i n g ( ”Time : ” , time ) ;newRow . s e tF l oa t ( ” So la r Voltage (V) : ” , Var1 ) ;

24

Page 26: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

newRow . s e tF l oa t ( ” So la r Amperage (mA) : ” , Var2 ) ;newRow . s e tF l oa t ( ” So la r Wattage (W) : ” , Var3 ) ;newRow . s e tF l oa t ( ” Fina l Voltage (V) : ” , Var4 ) ;newRow . s e tF l oa t ( ” Fina l Amperage (A) : ” , Var5 ) ;newRow . s e tF l oa t ( ” Fina l Wattage (W) : ” , Var6 ) ;newRow . s e tF l oa t ( ” Fina l Wattage (W) : ” , Var7 ) ;newRow . s e tF l oa t ( ” Fina l Wattage (W) : ” , Var8 ) ;newRow . s e tF l oa t ( ” Fina l Wattage (W) : ” , Var9 ) ;newRow . s e tF l oa t ( ” Fina l Wattage (W) : ” , Var10 ) ;

// Save Elements and Exi t Programf i l l ( 237 ,28 ,36) ;noStroke ( ) ;r e c t ( ( width ) −200 ,50 ,150 ,50) ;

f i l l (255) ;t ex tAl i gn (CENTER,CENTER) ;t e x tS i z e (20) ;t ex t ( ”Save & Exit ” , ( width ) −200 ,50 ,150 ,50) ;

i f (mouseX>=(width )−200 && mouseY>=50 && mouseX<=(width )−50 && mouseY<=50 && mousePressed==true ) {

f i l l (150 , 0 , 0) ;noStroke ( ) ;r e c t ( ( width ) −200 ,50 ,150 ,50) ;

f i l l (255) ;t e x tS i z e (20) ;t ex t ( ”Save & Exit ” , ( width ) −200 ,50 ,150 ,50) ;S t r ing f i l ename = time + ” ” + date + ” ” + ” t e s t . csv ” ;saveTable ( tab le , f i l ename , ” csv ” ) ;de lay (300) ;e x i t ( ) ;

}else i f (mouseX>=(width )−200 && mouseY>=50 && mouseX<=(width )−50 &&

mouseY<=100){

f i l l (255) ;noStroke ( ) ;r e c t ( ( width ) −200 ,50 ,150 ,50) ;

f i l l ( 0 ) ;t e x tS i z e (20) ;t ex t ( ”Save & Exit ” , ( width ) −200 ,50 ,150 ,50) ;

}}//−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

// Disp lay Time XX:XX:XX

25

Page 27: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

void displayTime ( ) {pushStyle ( ) ;f i l l ( 0 ) ;r e c t (100 ,40 ,250 ,80) ;f i l l (255) ;t e x tS i z e (20) ;time = st rh + ”h ” + strmin + ”min ” + s t r s e c + ” sec ” ;t ex t ( ”Time : ” + time ( ) ,200 ,60) ;

// Disp lay Date XX/XX/XXXXdate = strmon + ”−” + st rd + ”−” + s t ry ;t ex t ( ”Date : ” + date ( ) ,200 ,90) ;popStyle ( ) ;

}//−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

//−−−−−−−−−−−−−−−− Mark Log Button −−−−−−−−−−−−−−−−−void markLog ( ) {

//−−−−− VARIBLE STORE & SAVE −−−−− (2h )// Add Elements to TableTableRow newRow = tab l e . addRow( ) ;

newRow . s e t S t r i n g ( ”Time : ” , time ) ;newRow . s e tF l oa t ( ” So la r Voltage (V) : ” , Var1 ) ;newRow . s e tF l oa t ( ” So la r Amperage (mA) : ” , Var2 ) ;newRow . s e tF l oa t ( ” So la r Wattage (W) : ” , Var3 ) ;newRow . s e tF l oa t ( ” Fina l Voltage (V) : ” , Var4 ) ;newRow . s e tF l oa t ( ” Fina l Amperage (A) : ” , Var5 ) ;newRow . s e tF l oa t ( ” Fina l Wattage (W) : ” , Var6 ) ;newRow . s e tF l oa t ( ”Temp 1 (F) : ” , Var7 ) ;newRow . s e tF l oa t ( ”Temp 2 (F) : ” , Var8 ) ;newRow . s e tF l oa t ( ”Temp 3 (F) : ” , Var9 ) ;newRow . s e tF l oa t ( ”Temp 4 (F) : ” , Var10 ) ;newRow . s e tF l oa t ( ”Marked : ” , 0) ;

// Save Elements and Exi t Programf i l l ( 0 , 191 ,55) ;noStroke ( ) ;r e c t ( ( width ) −375 ,50 ,150 ,50) ;

f i l l (255) ;t ex tAl i gn (CENTER,CENTER) ;t e x tS i z e (20) ;t ex t ( ”Mark” , ( width ) −375 ,50 ,150 ,50) ;

i f (mouseX>=(width )−375 && mouseY>=50 && mouseX<=(width )−225 &&mouseY<=100 && mousePressed==true ) {

f i l l (150 , 0 , 0) ;noStroke ( ) ;r e c t ( ( width ) −375 ,50 ,150 ,50) ;

26

Page 28: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

f i l l (255) ;t e x tS i z e (20) ;t ex t ( ”Mark” , ( width ) −375 ,50 ,150 ,50) ;S t r ing f i l ename = time + ” ” + date + ” ” + ” t e s t . csv ” ;newRow . s e tF l oa t ( ”Marked : ” , 1) ;saveTable ( tab le , f i l ename , ” csv ” ) ;de lay (300) ;

}else i f (mouseX>=(width )−375 && mouseY>=50 && mouseX<=(width )−225 &&

mouseY<=100){

f i l l (255) ;noStroke ( ) ;r e c t ( ( width ) −375 ,50 ,150 ,50) ;

f i l l ( 0 ) ;t e x tS i z e (20) ;t ex t ( ”Mark” , ( width ) −375 ,50 ,150 ,50) ;

}}

// Temperature Graphvoid drawTemps ( ) {

//Text boxes// t i t l et extAl i gn (CENTER) ;t e x tS i z e (30) ;f i l l ( 200 ,16 ,46) ;t ex t ( ”Temperature” , tempX , tempY) ;

//Bat tery Labe l st extAl i gn (CORNER) ;t e x tS i z e (20) ;//B1t ex t ( S t r ing . format ( ”%.1 f ” ,Var1 ) , tempX − 155 , tempY+240) ;

//B2t ex t ( S t r ing . format ( ”%.1 f ” ,Var2 ) , tempX − 69 , tempY+240) ;

//B3t ex t ( S t r ing . format ( ”%.1 f ” ,Var3 ) , tempX + 14 , tempY+240) ;

//B4t ex t ( S t r ing . format ( ”%.1 f ” ,Var4 ) , tempX + 96 , tempY+240) ;

Var1 = 25 ;Var2 = 30 ;Var3 = 22 ;

27

Page 29: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

Var4 = 50 ;

// c r ea t e s one bar o f the graph , t h i s r e c t an g l e w i l l be b l a c kf loat temp1 = calculateLocalValueTemp (Var1 ) ;f i l l (#150606) ;r e c t ( tempX − 148 , tempY + 20 , 50 , 200) ;

// code below c r ea t e s a r e c t an g l e t ha t w i l l change co l o rrectMode (CORNER) ;

i f ( temp1 <= 67) {f i l l (#54FA03) ; // green

}else i f ( temp1 > 134) {

f i l l (#FA0B03) ; // red} else {f i l l (#F9FA03) ; // ye l l ow}

i f ( temp1 > 200) {r e c t ( tempX − 148 , tempY + 20 , 50 , 200) ;

} else i f ( temp1 <= 0) {//Don ’ t draw anyth ing

} else {r e c t (tempX − 148 , tempY + 220 , 50 , −temp1 ) ; //<>//}//−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

// second bar−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−f loat temp2 = calculateLocalValueTemp (Var2 ) ;f i l l (#150606) ;r e c t ( tempX − 64 , tempY + 20 , 50 , 200) ;

i f ( temp2 <= 67) {f i l l (#54FA03) ;} else i f ( temp2 > 134) {f i l l (#FA0B03) ;} else {f i l l (#F9FA03) ;}

i f ( temp2 > 200) {r e c t ( tempX − 64 , tempY + 20 , 50 , 200) ;

} else i f ( temp2 <= 0) { //<>////Don ’ t draw anyth ing

} else {r e c t (tempX − 64 , tempY + 220 , 50 , −temp2 ) ;}//−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

28

Page 30: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

//Third Bar−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−f loat temp3 = calculateLocalValueTemp (Var3 ) ;f i l l (#150606) ;r e c t ( tempX + 19 , tempY + 20 , 50 , 200) ;

i f ( temp3 <= 67) {f i l l (#54FA03) ;

} else i f ( temp3 > 134) {f i l l (#FA0B03) ;

} else {f i l l (#F9FA03) ;

}i f ( temp3 > 200) { //<>//

r e c t ( tempX + 19 , tempY + 20 , 50 , 200) ; //<>//} else i f ( temp3 <= 0) {

//Don ’ t draw anyth ing} else {

r e c t (tempX + 19 , tempY + 220 , 50 , −temp3 ) ; //<>//}//−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

//Fourth Bar−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−f loat temp4 = calculateLocalValueTemp (Var4 ) ;f i l l (#150606) ;r e c t ( tempX + 102 , tempY + 20 , 50 , 200) ;

i f ( temp4 <= 67) {f i l l (#54FA03) ;

} else i f ( temp4 > 134) {f i l l (#FA0B03) ;

} else {f i l l (#F9FA03) ;

}

i f ( temp4 > 200) {r e c t ( tempX + 102 , tempY + 20 , 50 , 200) ; //<>//

} else i f ( temp1 <= 0) {//Don ’ t draw anyth ing

} else {r e c t (tempX + 102 , tempY + 220 , 50 , −temp4 ) ; //<>//

}}

// Convert a temperature va lue to a l o c a l va lue to draw the tempr e c t an g l e

f loat calculateLocalValueTemp ( f loat value ) {return 0+(( value−minTemp) /(maxTemp−minTemp) ∗200) ;

}

29

Page 31: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

class c i r cu larGauge {f loat diameter ;S t r ing gaugeName ;S t r ing leftValueName ;S t r ing rightValueName ;f loat centerX ;f loat centerY ;f loat aValue ;f loat bValue ;f loat minValue ;f loat maxValue ;

f loat redGreenValue ;f loat greenRedValue ;

c i r cu larGauge ( f loat d , S t r ing name , S t r ing leftName , S t r ingrightName ) {

diameter = d ;gaugeName = name ;leftValueName = leftName ;rightValueName = rightName ; //<>//

}

void se tCenter ( f loat x , f loat y ) {centerX = x ;centerY = y ;

}

void setDiameter ( f loat d) {diameter = d ;

}

void update ( ) {// checkGaugeFit ( diameter ) ;t e x tS i z e ( diameter /10) ;t ex tAl i gn (CENTER, CENTER) ;

f loat l a s tAng l e = rad ians ( s ta r tAng l e ) ; //<>//f i l l (255 ,255 ,255) ;e l l i p s e ( centerX , centerY , diameter , diameter ) ;

f i l l ( 255 ,0 , 0 ) ;arc ( centerX , centerY , diameter , diameter , las tAngle , rad ians (

ca l cu l a t eLoca lVa lue ( redGreenValue ) ) ) ;arc ( centerX , centerY , diameter , diameter , rad ians (

ca l cu l a t eLoca lVa lue ( greenRedValue ) ) , rad ians ( s ta r tAng l e+spanAngle ) ) ;

f i l l (255 ,255 ,255) ;e l l i p s e ( centerX , centerY , .85∗ diameter , . 85∗ diameter ) ; //<>//

30

Page 32: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

f i l l ( 255 ,165 ,0 ) ;

e l l i p s e ( centerX , centerY , 0 .1∗ diameter , 0 .1∗ diameter ) ;

pushMatrix ( ) ;t r a n s l a t e ( centerX , centerY ) ;r o t a t e ( rad ians ( ca l cu l a t eLoca lVa lue ( aValue−bValue )+90) ) ;// t r a n s l a t e (0 , −60) ;t r i a n g l e (−(0.1∗ diameter ) /2 , 0 , 0 , −0.5∗diameter , ( 0 . 1∗ diameter ) /2 ,

0) ;popMatrix ( ) ;

f i l l ( 0 ) ;r e c t ( centerX−(diameter /2) , ( centerY )+(diameter /2) , diameter /3 , (

diameter /6) ) ;f i l l ( 200 ,16 ,46) ;t ex t ( s t r ( aValue ) , centerX−(diameter /2) , ( centerY )+(diameter /2) ,

diameter /3 , ( diameter /6) ) ;t ex t ( leftValueName , centerX−(diameter /2) , ( centerY )+(diameter /1 . 5 ) ,

diameter /3 , ( diameter /6) ) ;

f i l l ( 0 ) ;r e c t ( centerX+(diameter /6) , centerY+(diameter /2) , diameter /3 ,

diameter /6) ;f i l l ( 200 ,16 ,46) ;// t e x t S i z e (30) ;t ex t ( s t r ( bValue ) , centerX+(diameter /6) , centerY+(diameter /2) ,

diameter /3 , diameter /6) ;t ex t ( rightValueName , centerX+(diameter /6) , centerY+(diameter /1 . 5 ) ,

diameter /3 , diameter /6) ;

f i l l ( 0 ) ;r e c t ( centerX−(diameter /2) , centerY −(0.72∗ diameter ) , ( centerX+(

diameter /2) )−(( centerX )−(diameter /2) ) , ( diameter /6) ) ;f i l l ( 200 ,16 ,46) ;t ex t ( gaugeName , centerX−(diameter /2) , centerY −(0.72∗ diameter ) , (

centerX+(diameter /2) )−(( centerX )−(diameter /2) ) , ( diameter /6) ) ;

pushStyle ( ) ;s t r oke (0 ) ;f i l l ( 0 ) ;int hour = 3 ;for ( f loat a = star tAng l e +2; a < spanAngle + star tAng l e ; a+=(

spanAngle + star tAng l e ) /10 . 0 ) {f loat ang le = rad ians ( a ) ;f loat x = centerX + cos ( ang le ) ∗ ( diameter − 200) ;f loat y = centerY + s in ( ang le ) ∗ ( diameter − 200) ;ver tex (x , y ) ;

31

Page 33: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

t ex t ( hour , x , y ) ;hour++;i f ( hour > 12) {

hour = 1 ;}

}

//// Draw the do t s// s trokeWeight (2) ;// beginShape (POINTS) ;// f o r ( f l o a t a = s ta r tAng l e ; a < spanAngle ; a+=30) {// f l o a t ang l e = radians (a ) ;// f l o a t x = centerX + cos ( ang l e ) ∗ ( diameter − 195) ;// f l o a t y = centerY + s in ( ang l e ) ∗ ( diameter − 195) ;// v e r t e x ( x , y ) ;//}//endShape () ;popStyle ( ) ;

}

// vo id checkGaugeFit ( f l o a t d ) {// // I f the width o f the window i s l e s s than the diameter o f the

gauge , then make the gauge diameter sma l l e r// i f ( width<d ) {// setDiameter ( width ) ;// }//}

f loat ca l cu l a t eLoca lVa lue ( f loat value ) {return s ta r tAng l e +(( value−minValue ) /(maxValue−minValue ) ∗ spanAngle ) ;

}}class dualCircularGauge {

f loat diameter ;S t r ing gaugeName ;S t r ing leftValueName ;S t r ing rightValueName ;f loat centerX ;f loat centerY ;f loat aValue ;f loat bValue ;f loat minValue ;f loat maxValue ;int valueOption ;f loat [ ] markerValuesAmps = {0 , 2 , 4 , 6 , 8 , 10} ;f loat [ ] markerValuesVolts = {20 , 21 , 22 , 23 , 24 , 2 5 . 2} ;

32

Page 34: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

f loat redGreenValue ;f loat greenRedValue ;

dualCircularGauge ( f loat d , S t r ing name , S t r ing leftName , S t r ingrightName ) {

diameter = d ;gaugeName = name ;leftValueName = leftName ;rightValueName = rightName ;

}

void se tCenter ( f loat x , f loat y ) {centerX = x ;centerY = y ;

}

void setDiameter ( f loat d) {diameter = d ;

}

void setup ( ) {}

void update ( ) {// checkGaugeFit ( diameter ) ;t e x tS i z e ( diameter /10) ;t ex tAl i gn (CENTER, CENTER) ;

f loat l a s tAng l e = rad ians ( s ta r tAng l e ) ;

// Gauge 1f i l l (255 ,255 ,255) ;e l l i p s e ( centerX , centerY , diameter , diameter ) ;

f i l l ( 255 ,0 , 0 ) ;arc ( centerX , centerY , diameter , diameter , las tAngle , rad ians (

ca l cu l a t eLoca lVa lue ( redGreenValue ) ) ) ;arc ( centerX , centerY , diameter , diameter , rad ians (

ca l cu l a t eLoca lVa lue ( greenRedValue ) ) , rad ians ( s ta r tAng l e+spanAngle ) ) ;

f i l l (255 ,255 ,255) ;e l l i p s e ( centerX , centerY , .85∗ diameter , . 85∗ diameter ) ;

f i l l ( 255 ,165 ,0 ) ;

e l l i p s e ( centerX , centerY , 0 .1∗ diameter , 0 .1∗ diameter ) ;

pushMatrix ( ) ;

33

Page 35: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

t r a n s l a t e ( centerX , centerY ) ;r o t a t e ( rad ians ( ca l cu l a t eLoca lVa lue ( aValue )+90) ) ;// t r a n s l a t e (0 , −60) ;t r i a n g l e (−(0.1∗ diameter ) /2 , 0 , 0 , −0.5∗diameter , ( 0 . 1∗ diameter ) /2 ,

0) ;popMatrix ( ) ;

// Gauge 2f i l l (255 ,255 ,255) ;e l l i p s e ( centerX , centerY+400 , diameter , diameter ) ;

f i l l ( 255 ,0 , 0 ) ;arc ( centerX , centerY+400 , diameter , diameter , las tAngle , rad ians (

ca l cu l a t eLoca lVa lue ( redGreenValue ) ) ) ;arc ( centerX , centerY+400 , diameter , diameter , rad ians (

ca l cu l a t eLoca lVa lue ( greenRedValue ) ) , rad ians ( s ta r tAng l e+spanAngle ) ) ;

f i l l (255 ,255 ,255) ;e l l i p s e ( centerX , centerY+400 , .85∗ diameter , . 85∗ diameter ) ;

f i l l ( 255 ,165 ,0 ) ;

e l l i p s e ( centerX , centerY+400 , 0 .1∗ diameter , 0 .1∗ diameter ) ;

pushMatrix ( ) ;t r a n s l a t e ( centerX , centerY+400) ;r o t a t e ( rad ians ( ca l cu l a t eLoca lVa lue ( bValue )+90) ) ;// t r a n s l a t e (0 , −60) ;t r i a n g l e (−(0.1∗ diameter ) /2 , 0 , 0 , −0.5∗diameter , ( 0 . 1∗ diameter ) /2 ,

0) ;popMatrix ( ) ;//

///////////////////////////////////////////////////////////////////////////

f i l l ( 0 ) ;r e c t ( centerX−(diameter /2) , ( centerY )+(diameter /2) , diameter /3 , (

diameter /6) ) ;f i l l ( 200 ,16 ,46) ;t ex t ( s t r ( aValue ) , centerX−(diameter /2) , ( centerY )+(diameter /2) ,

diameter /3 , ( diameter /6) ) ;t ex t ( leftValueName , centerX−(diameter /2) , ( centerY )+(diameter /1 . 5 ) ,

diameter /3 , ( diameter /6) ) ;

f i l l ( 0 ) ;r e c t ( centerX+(diameter /6) , centerY+(diameter /2) , diameter /3 ,

diameter /6) ;f i l l ( 200 ,16 ,46) ;

34

Page 36: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

// t e x t S i z e (30) ;t ex t ( s t r ( bValue ) , centerX+(diameter /6) , centerY+(diameter /2) ,

diameter /3 , diameter /6) ;t ex t ( rightValueName , centerX+(diameter /6) , centerY+(diameter /1 . 5 ) ,

diameter /3 , diameter /6) ;

f i l l ( 0 ) ;r e c t ( centerX−(diameter /2) , centerY −(0.72∗ diameter ) , ( centerX+(

diameter /2) )−(( centerX )−(diameter /2) ) , ( diameter /6) ) ;f i l l ( 200 ,16 ,46) ;t ex t ( gaugeName , centerX−(diameter /2) , centerY −(0.72∗ diameter ) , (

centerX+(diameter /2) )−(( centerX )−(diameter /2) ) , ( diameter /6) ) ;

pushStyle ( ) ;s t r oke (0 ) ;f i l l ( 0 ) ;f loat value = minValue ;t e x tS i z e ( diameter /15) ;// f o r ( f l o a t a = s ta r tAng l e ; a < spanAngle + s ta r tAng l e ; a+=(

maxValue−minValue ) /10) {// f l o a t ang l e = radians (a ) ;// f l o a t x = centerX + cos ( ang l e ) ∗ ( diameter − 200) ;// f l o a t y = centerY + s in ( ang l e ) ∗ ( diameter − 200) ;// v e r t e x ( x , y ) ;

// f l o a t x2 = centerX + cos ( ang l e ) ∗ ( diameter − 200) ;// f l o a t y2 = ( centerY + 400) + s in ( ang l e ) ∗ ( diameter − 200) ;// v e r t e x ( x2 , y2 ) ;

// t e x t ( S t r ing . format (”%.1 f ” , va lue ) , x , y ) ;// t e x t ( S t r ing . format (”%.1 f ” , va lue ) , x2 , y2 ) ;// va lue+=(maxValue−minValue ) /10;//}

i f ( valueOption == 1) {

for ( int i =0; i<markerValuesAmps . l ength ; i++) { //<>//f loat x = centerX + cos ( rad ians ( ca l cu l a t eLoca lVa lue (

markerValuesAmps [ i ] ) ) ) ∗ ( diameter − 200) ;f loat y = centerY + s in ( rad ians ( ca l cu l a t eLoca lVa lue (

markerValuesAmps [ i ] ) ) ) ∗ ( diameter − 200) ;ver tex (x , y ) ;

f loat x2 = centerX + cos ( rad ians ( ca l cu l a t eLoca lVa lue (markerValuesAmps [ i ] ) ) ) ∗ ( diameter − 200) ;

f loat y2 = 400 + centerY + s in ( rad ians ( ca l cu l a t eLoca lVa lue (markerValuesAmps [ i ] ) ) ) ∗ ( diameter − 200) ;

ver tex ( x2 , y2 ) ;

35

Page 37: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

t ex t ( S t r ing . format ( ”%.1 f ” ,markerValuesAmps [ i ] ) , x , y ) ;t ex t ( S t r ing . format ( ”%.1 f ” ,markerValuesAmps [ i ] ) , x2 , y2 ) ;// va lue+=(maxValue−minValue ) /10;

}} else i f ( valueOption == 2) {

for ( int i =0; i<markerValuesVolts . l ength ; i++) {f loat x = centerX + cos ( rad ians ( ca l cu l a t eLoca lVa lue (

markerValuesVolts [ i ] ) ) ) ∗ ( diameter − 200) ;f loat y = centerY + s in ( rad ians ( ca l cu l a t eLoca lVa lue (

markerValuesVolts [ i ] ) ) ) ∗ ( diameter − 200) ;ver tex (x , y ) ;

f loat x2 = centerX + cos ( rad ians ( ca l cu l a t eLoca lVa lue (markerValuesVolts [ i ] ) ) ) ∗ ( diameter − 200) ;

f loat y2 = 400 + centerY + s in ( rad ians ( ca l cu l a t eLoca lVa lue (markerValuesVolts [ i ] ) ) ) ∗ ( diameter − 200) ;

ver tex ( x2 , y2 ) ;

t ex t ( S t r ing . format ( ”%.1 f ” , markerValuesVolts [ i ] ) , x , y ) ;t ex t ( S t r ing . format ( ”%.1 f ” , markerValuesVolts [ i ] ) , x2 , y2 ) ;// va lue+=(maxValue−minValue ) /10;

}}

//// Draw the do t s// s trokeWeight (2) ;// beginShape (POINTS) ;// f o r ( f l o a t a = s ta r tAng l e ; a < spanAngle ; a+=30) {// f l o a t ang l e = radians (a ) ;// f l o a t x = centerX + cos ( ang l e ) ∗ ( diameter − 195) ;// f l o a t y = centerY + s in ( ang l e ) ∗ ( diameter − 195) ;// v e r t e x ( x , y ) ;//}//endShape () ;popStyle ( ) ;

}

// vo id checkGaugeFit ( f l o a t d ) {// // I f the width o f the window i s l e s s than the diameter o f the

gauge , then make the gauge diameter sma l l e r// i f ( width<d ) {// setDiameter ( width ) ;// }//} }

f loat ca l cu l a t eLoca lVa lue ( f loat value ) {return s ta r tAng l e +(( value−minValue ) /(maxValue−minValue ) ∗ spanAngle ) ;

36

Page 38: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

}}////////////////////////////////////////////////////////////class t imer{

f loat startTime ;int tOver ;

t imer ( int m i l l i s e c s ){

startTime=m i l l i s ( ) ;tOver=m i l l i s e c s ;

}

boolean over ( ){

i f ( ( m i l l i s ( ) − startTime )>tOver )return true ;

elsereturn fa l se ;

}

void r e s e t ( ){

startTime=m i l l i s ( ) ;}

void setOver ( int m i l l i s e c s ){

tOver=m i l l i s e c s ;r e s e t ( ) ;

}}////////////////////////////////////////////////////////////St r ing time ( ){

St r ing h=s t r ( hour ( ) ) ,m=s t r (minute ( ) ) , s=s t r ( second ( ) ) ;

h=(h . l ength ( )==1)?”0”+h : h ;m=(m. l ength ( )==1)?”0”+m:m;s=(s . l ength ( )==1)?”0”+s : s ;

return h+” : ”+m+” : ”+s ;}////////////////////////////////////////////////////////////St r ing date ( ){

St r ing d=s t r ( day ( ) ) ,m=s t r (month ( ) ) ;

37

Page 39: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

d=(d . l ength ( )==1)?”0”+d : d ;m=(m. l ength ( )==1)?”0”+m:m;

return d+”/”+m+”/”+s t r ( year ( ) ) ;}

38

Page 40: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

Figure 3: Picture of System in Operation

39

Page 41: M:2:I Milestone 1 Telemetry System and Dashboardm2i.aere.iastate.edu/cardinalflight/files/2017/03/... · M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen 3 Problem Identi

M:2:I Milestone 1 Telemetry System and Dashboard Alex Nielsen

Figure 4: Dashboard Layout in Operation

40