Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed problem, required increasing delay between requesting battery v…

…oltage,

and reading.
  • Loading branch information...
commit 1a890fd414982914767ec085007373f55c96b05f 1 parent a390a5a
authored April 09, 2011

Showing 1 changed file with 15 additions and 56 deletions. Show diff stats Hide diff stats

  1. 71  main.c
71  main.c
@@ -313,7 +313,7 @@ void receiveCommandHandler(uint8_t receiveDataLength, uint8_t* recieveData)
313 313
 {
314 314
     uint8_t temp;
315 315
 
316  
-    lprintf_P(PSTR("FCPU RX I2C\n"));
  316
+    lprintf_P(PSTR("CPU I2C\n"));
317 317
     for(int i=0; i < receiveDataLength; i++)
318 318
     {
319 319
         lprintf("%x ", recieveData[i]);
@@ -588,55 +588,10 @@ void receiveCommandHandler(uint8_t receiveDataLength, uint8_t* recieveData)
588 588
 	}
589 589
 }
590 590
 
591  
-/*void dumpInternalState(void)
592  
-{
593  
-
594  
-    //Raw Batt Voltage
595  
-    //get raw pack voltage
596  
-	//AD7998 Interfacing
597  
-	i2cSendStart();
598  
-	i2cWaitForComplete();
599  
-	i2cSendByte(AD7992);
600  
-	i2cWaitForComplete();
601  
-	i2cSendByte(0x10);
602  
-	i2cWaitForComplete();
603  
-	i2cSendStop();
604  
-	_delay_us(5);
605  
-
606  
-	i2cSendStart();
607  
-	i2cWaitForComplete();
608  
-	i2cSendByte(AD7992+1);
609  
-	i2cWaitForComplete();
610  
-	i2cReceiveByte(1);
611  
-	i2cWaitForComplete();
612  
-	uint16_t batteryValue = (uint16_t)i2cGetReceivedByte() << 8;
613  
-	i2cWaitForComplete();
614  
-	i2cReceiveByte(0);
615  
-	i2cWaitForComplete();
616  
-	batteryValue += i2cGetReceivedByte();
617  
-	i2cWaitForComplete();
618  
-	i2cSendStop();
619  
-	batteryValue &= 0x0FFF;
620  
-	//This is not such a magic value.  12 bits AD = 4096
621  
-	//Divider network = 4.07 kohms and 20 khoms
622  
-	//(3.3 volts / 4096) * (24.07/4.07) = 0.0047647
623  
-	//Multiply by 10 to get bigger value.
624  
-	float myVoltage = ((float)batteryValue*0.0047647);
625  
-	lprintf("Batt Volts: %f\n", myVoltage);
626  
-
627  
-    //Batt Temp
628  
-    uint16_t rawBattTemp = tmp100rawTemp(TMP101BH)>>4;
629  
-	int16_t btinm = get12bit2scomp(rawBattTemp);
630  
-	int8_t batteryTemperature = (int8_t)(btinm/16);
631  
-	lprintf("Batt Temp: %f\n", (float)btinm/16.);
632  
-    //
633  
-
634  
-}
635  
-*/
636 591
 void updateSpeedDial(uint16_t speedDial)
637 592
 {
638 593
     #ifdef FCPUDEBUG
639  
-        lprintf_P(PSTR("Change SpdDial\n"));
  594
+        lprintf_P(PSTR("SpdDial\n"));
640 595
     #endif
641 596
     switch(speedDial)
642 597
     {
@@ -835,7 +790,8 @@ void processMonitor(uint32_t time)
835 790
         eeprom_write_word(&EEhfTimeToTx, time+eeprom_read_byte(&EEhfDataTransmitInterval));
836 791
     }
837 792
 
838  
-	getGPS(&currentPositionData);
  793
+	getGPS(&currentPositionData);
  794
+
839 795
 	if(currentPositionData.status == 0)
840 796
 	{
841 797
 		gpsFailures = 0;
@@ -888,7 +844,8 @@ void processMonitor(uint32_t time)
888 844
 	i2cSendByte(0x10);
889 845
 	i2cWaitForComplete();
890 846
 	i2cSendStop();
891  
-	_delay_us(5);
  847
+
  848
+	_delay_ms(5);
892 849
 
893 850
 	i2cSendStart();
894 851
 	i2cWaitForComplete();
@@ -909,7 +866,8 @@ void processMonitor(uint32_t time)
909 866
 	//(3.3 volts / 4096) * (24.07/4.07) = 0.0047647
910 867
 	//Multiply by 10 to get bigger value.
911 868
 	batteryValue = (uint16_t)((((float)batteryValue*0.0047647))*10.);
912  
-	uint8_t outputVoltage = (uint8_t)batteryValue;
  869
+	uint8_t outputVoltage = (uint8_t)batteryValue;
  870
+
913 871
 	if(batteryValue < 15)
914 872
 	{
915 873
 		currentBitmask[0] |= _BV(1);
@@ -920,7 +878,8 @@ void processMonitor(uint32_t time)
920 878
     eeprom_write_dword(&EEcurrentTelemetryBitmap[2], currentBitmask[2]);
921 879
 
922 880
 
923  
-	scheduleQueueAdd(&processMonitor, time+5);
  881
+	scheduleQueueAdd(&processMonitor, time+5);
  882
+
924 883
 }
925 884
 
926 885
 //Calculate Running Avg. of Vertical Speed
@@ -1559,7 +1518,7 @@ void transmitShortReport(uint32_t time)
1559 1518
 void transmitSamples(uint32_t time)
1560 1519
 {
1561 1520
 	#ifdef FCPUDEBUG
1562  
-		lprintf_P(PSTR("In Sample TX\n"));
  1521
+		lprintf_P(PSTR("Sample TX\n"));
1563 1522
 	#endif
1564 1523
 	loadBatch();
1565 1524
 	flushSatQueue();
@@ -1584,7 +1543,7 @@ void transmitSamples(uint32_t time)
1584 1543
 void rapidHFXmit(uint32_t time)
1585 1544
 {
1586 1545
 	#ifdef FCPUDEBUG
1587  
-		lprintf_P(PSTR("In Rapid HF TX\n"));
  1546
+		lprintf_P(PSTR("Rapid HF TX\n"));
1588 1547
 	#endif
1589 1548
 	if(rapidHFEnable == 1 && hfSema != 2)
1590 1549
 	{
@@ -1602,7 +1561,7 @@ void rapidHFXmit(uint32_t time)
1602 1561
 void ballastStaticTickle(uint32_t time)
1603 1562
 {
1604 1563
 	#ifdef FCPUDEBUG
1605  
-		lprintf_P(PSTR("In ballast tickle\n"));
  1564
+		lprintf_P(PSTR("bllst tckl\n"));
1606 1565
 	#endif
1607 1566
 	if((time - lastBallastTime) > 1800)
1608 1567
 	{
@@ -1660,7 +1619,7 @@ void flightPhaseLogic(uint32_t time)
1660 1619
 				//Save time
1661 1620
 			}
1662 1621
 			#ifdef FCPUDEBUG
1663  
-				lprintf_P(PSTR("Phase 0: Prelaunch\n"));
  1622
+				lprintf_P(PSTR("Phase 0: Pre\n"));
1664 1623
 
1665 1624
 			#endif
1666 1625
 			//reschedule 1 second from now
@@ -1697,7 +1656,7 @@ void flightPhaseLogic(uint32_t time)
1697 1656
 			{
1698 1657
 			    #ifdef FCPUDEBUG
1699 1658
                     lprintf_P(PSTR("Phase 3 Criteria\n"));
1700  
-                    lprintf_P(PSTR("VS: %d A: %d\n"), vSpeedAvg, thisAltitude);
  1659
+                    //lprintf_P(PSTR("VS: %d A: %d\n"), vSpeedAvg, thisAltitude);
1701 1660
                 #endif
1702 1661
 				myPhase = 3;
1703 1662
 			}

0 notes on commit 1a890fd

Please sign in to comment.
Something went wrong with that request. Please try again.