Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#include liscenses
- #include <SD.h>
- #include <PString.h>//for pstrings
- #include <Streaming.h>// << << <<
- //#include <SoftwareSerial.h>
- #define chipSelect 10
- #define RS485RWPIN 7
- #define XMISSION_BUFFER_SIZE 1000
- //add defines for indicator LED on the final hardware revision
- //insert RS485 code here
- char GPSInBuf[90];
- char weatherInBuf[90];
- char radInBuf[40];
- char IMUInBuf[40];
- char GPSParseBuf[90];
- char weatherParseBuf[90];
- char radParseBuf[40];
- char IMUParseBuf[40];
- char *parseptr;
- PString GPSInBuffer(GPSInBuf,90);
- PString weatherInBuffer(weatherInBuf,90);
- PString radInBuffer(radInBuf,40);
- PString IMUInBuffer(IMUInBuf,40);
- boolean GPSParseReady = false;
- boolean weatherParseReady = false;
- boolean radParseReady = false;
- boolean IMUParseReady = false;
- //---------------------------------------
- //parse vars
- //-----------------------------------------
- //gps vars:
- uint32_t timeHHMMSS;
- int8_t fixQuality;
- float longitude,lattitude,alt,trueHeading,magneticHeading,speedKnots,speedKMH;
- boolean gpsFix=false;
- //weather vars:
- float barometricPressureInches,barometricPressureBars,airTemp,relativeHumidity,dewPoint;
- float windDirectionTrue,windDirectionMagnetic,windSpeedKnots,windSpeedMetersPerSecond;
- float weatherPitch,weatherRoll,weatherYaw,relativeWindChill,theoreticalWindChill;
- //radation vars
- float microSievertPerHour;
- int countPerMinute;
- //AHRS vars:
- float yaw,pitch,roll;
- //-------------------------------------------------
- //transmission vars//
- //-------------------------------------------------
- char transmissionBuffer[XMISSION_BUFFER_SIZE];//large because all the data is a significant size
- PString transmissionString(transmissionBuffer,XMISSION_BUFFER_SIZE);
- long transmissionTimer=0;
- long LCDTimer = 0;
- boolean SDCardPresent = false;
- void setup(){
- /*Setup is as follows:
- *GPS serial 2!!!!!DO NOT USE PORT 0 FOR GPS THIS CAUSES THE SD CARD TO NOT WORK AND MANY OTHER IISUES
- *IMU serial 3!!!!!REASON IS UNKNOWN AT THIS TIME
- *RAD serial 0
- *WTH serial 1
- */
- //please see appropriate data sheets
- //---------------------------------------
- //dont forget to list the data sheets!@!@!@!@!@!@
- //---------------------------------------
- //Rad/Complete Data Set Out config BEGIN
- //---------------------------------------
- Serial.begin(115200);
- Serial.println("Congifuration Start");
- Serial2.begin(9600);
- //---------------------------------------
- //Rad/Complete Data Set Out config END
- //weather station config
- //----------------------------------
- pinMode(RS485RWPIN,OUTPUT);
- digitalWrite(RS485RWPIN,HIGH);
- Serial1.begin(4800);
- Serial.println("waiting for weather station boot");
- for (int j=15;j>0;j--){
- Serial.println(j);
- delay(1000);
- }
- Serial.println("transmitting strings");
- Serial1.println("$PAMTC,HEATER,A*05");//enable heater
- delay(100);
- Serial1.println("$PAMTC,BAUD,38400*66");//set baud rate to 38400
- delay(100);
- Serial1.end();
- Serial1.begin(38400);
- delay(100);
- digitalWrite(RS485RWPIN,LOW);//Set mode to read now that config is done
- Serial.println("Weather station config complete");
- //---------------------------------------
- //GPS congig
- //currently this is going to run on 9600 and give default sentences
- Serial2.println("$PSRF100,1,115200,8,1,0*05");
- delay(100);//wait one second for config to take
- Serial2.end();
- Serial2.begin(115200);
- Serial2.println("$PSRF151,01*0F");
- //IMU config
- Serial3.begin(115200);
- //---------------------------------------------------------
- //SD card setup
- //-------------------------------------------------------------
- if (!SD.begin(chipSelect)) {
- Serial.println("Card failed, or not present");
- // don't do anything more:
- }
- else{
- Serial.println("card initialized.");
- SDCardPresent = true;
- }
- //initialize 5 hz transmission timer
- delay(1000);
- transmissionTimer = millis();
- }
- void loop(){
- getString();
- if(GPSParseReady == true){
- parseptr = GPSParseBuf;
- parseString();
- GPSParseReady = false;
- }
- if(weatherParseReady==true){
- parseptr = weatherParseBuf;
- parseString();
- weatherParseReady = false;
- }
- if(radParseReady==true){
- parseptr = radParseBuf;
- parseString();
- radParseReady = false;
- }
- if(IMUParseReady==true){
- parseptr = IMUParseBuf;
- parseString();
- IMUParseReady = false;
- }
- if(millis()- transmissionTimer >=200){
- transmission();
- transmissionTimer = millis();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement