Commits

bsaid committed 8dd389d

Transmitter data successfully tested.

Comments (0)

Files changed (4)

firmware/YuniflyLibraries/fastPWM.hpp

 //#include "basic.hpp"
 
+int const minPWMvalue = -32;	//min is -127, set -32 for debug
+int const maxPWMvalue = 32;		//max is 127, set 32 for debug
+
 int convertPWMValue(int value)
 {
 	return ((value+128)<<3)+500;
 
 void testRangePWM()		//must not test motor range!
 {
-	for(int i=-127;i<=127;i++)
+	for(int i=minPWMvalue;i<=maxPWMvalue;i++)
 	{
 		setAllPWMs(i,i,i,i,i,i);
 		_delay_ms(10);	//todo: time is not constant
 	}
-	for(int i=127;i>=-127;i--)
+	for(int i=maxPWMvalue;i>=minPWMvalue;i--)
 	{
 		setAllPWMs(i,i,i,i,i,i);
 		_delay_ms(10);	//todo: time is not constant

firmware/YuniflyLibraries/firmware.aws

-<AVRWorkspace><IOSettings><CurrentRegisters/></IOSettings><part name="ATMEGA128"/><Files><File00000 Name="D:\Beda\Aktualni data\Yunifly\Yunifly\YuniflyLibraries\firmware.c" Position="266 97 1397 591" LineCol="23 23" State="Maximized"/><File00001 Name="D:\Beda\Aktualni data\Yunifly\Yunifly\YuniflyLibraries\uart.hpp" Position="291 122 1414 586" LineCol="6 0" State="Maximized"/><File00002 Name="D:\Beda\Aktualni data\Yunifly\Yunifly\YuniflyLibraries\accelerometer.hpp" Position="316 147 1439 611" LineCol="76 0" State="Maximized"/><File00003 Name="D:\Beda\Aktualni data\Yunifly\Yunifly\YuniflyLibraries\paralTransmitter.hpp" Position="341 172 1464 636" LineCol="11 0" State="Maximized"/><File00004 Name="D:\Beda\Aktualni data\Yunifly\Yunifly\YuniflyLibraries\fastPWM.hpp" Position="366 197 1489 661" LineCol="49 27" State="Maximized"/><File00005 Name="D:\Beda\Aktualni data\Yunifly\Yunifly\YuniflyLibraries\led.hpp" Position="258 67 1626 798" LineCol="21 17" State="Maximized"/></Files></AVRWorkspace>
+<AVRWorkspace><IOSettings><CurrentRegisters><USART1><register register="UBRR1H" group="USART1" display="1" locked="0"/></USART1><USART1><register register="UBRR1L" group="USART1" display="1" locked="0"/></USART1><USART1><register register="UCSR1A" group="USART1" display="1" locked="0"/></USART1><USART1><register register="UCSR1B" group="USART1" display="1" locked="0"/></USART1><USART1><register register="UCSR1C" group="USART1" display="1" locked="0"/></USART1><USART1><register register="UDR1" group="USART1" display="1" locked="0"/></USART1></CurrentRegisters></IOSettings><part name="ATMEGA128"/><Files><File00000 Name="D:\Beda\Aktualni data\Yunifly\Yunifly\YuniflyLibraries\firmware.c" Position="909 769 1069 796" LineCol="43 0"/><File00001 Name="D:\Beda\Aktualni data\Yunifly\Yunifly\YuniflyLibraries\uart.hpp" Position="749 769 909 796" LineCol="6 0"/><File00002 Name="D:\Beda\Aktualni data\Yunifly\Yunifly\YuniflyLibraries\accelerometer.hpp" Position="83 120 856 701" LineCol="36 65"/><File00003 Name="D:\Beda\Aktualni data\Yunifly\Yunifly\YuniflyLibraries\paralTransmitter.hpp" Position="429 769 589 796" LineCol="9 0"/><File00004 Name="D:\Beda\Aktualni data\Yunifly\Yunifly\YuniflyLibraries\fastPWM.hpp" Position="269 769 429 796" LineCol="62 0"/><File00005 Name="D:\Beda\Aktualni data\Yunifly\Yunifly\YuniflyLibraries\led.hpp" Position="109 769 269 796" LineCol="3 0"/></Files></AVRWorkspace>

firmware/YuniflyLibraries/firmware.c

 	debug.wait();
 	
 	blink();
-	firstAccCalibration();
-	blink();
+	//firstAccCalibration();
+	//blink();
 	testRangePWM();
 	blink();
 	//BTRCinit();	//todo: uncomment or delete with declaration; set concurent access
 	//accInit();	//todo: uncomment or delete with declaration; set concurent access
 	
-	int kolikrat = 0;	//only for testing
+	int plus = 1;
 	for(;;)
 	{
-		kolikrat++;
-		toggleLed();
-		/*BTRCupdate();
-
-		//todo: delete this code; only for debug
-		for(int i=0;i<channels;i++)
-		{
-			rs2321.send_char(RCchannels[i]);
-		}*/
-
-		//todo: debug this code with transmitter
-		/*for(int i=0;i<channels;i++)
-		{
-			setFastPWM( i, RCchannels[ servosPosition[i] ]/8 );
-		}
-		toggleLed();
-		*/
+		BTRCupdate();
 
 		//driving by accelerometers
 		for(int i=0;i<channels;i++)
 		{
-			wantAcc[i] = kolikrat%200-100;		//todo: set values from transmitter
+			wantAcc[i] = RCchannels[i]/8;
 		}
 
-		for(int i=0;i<20;i++)	//todo: set asynchronic cycle for reading faster accelerometer uart line
+		for(int i=0;i<channels;i++)
+		{
+			setFastPWM( servosPosition[i], wantAcc[i]);
+		}
+
+		/*for(int i=0;i<20;i++)	//todo: set asynchronic cycle for reading faster accelerometer uart line
 		{
 			while(!accUpdate());
 		}
 
-		debug.wait();
+		for(int i=0;i<channels;i++)
+		{
+			if(drivenByAcc[i] && getBit(buttons,0))
+			{
+				setFastPWM( servosPosition[i], (accData[ accChannelsPosition[i] ]/100) * accReverzCorrection[i] - wantAcc[i]);
+			}
+			else
+			{
+				setFastPWM( servosPosition[i], wantAcc[i]);
+			}
+		}*/
+		toggleLed();
+
+		/*debug.wait();
 		for(int j=2;j<8;j++)
 			debug << sumAcc[j] << "     |     ";
 			//debug << accData[j]/100 << "     |     ";
-		debug << "\r";
-
-		for(int i=0;i<channels;i++)
-		{
-			if(drivenByAcc[i])
-			{
-				setFastPWM( servosPosition[i], (accData[ accChannelsPosition[i] ]/100) * accReverzCorrection[i] - wantAcc[i]);
-			}
-		}
+		debug << "\r";*/
 	}
 
 	return 0;

firmware/YuniflyLibraries/paralTransmitter.hpp

 int const servosPosition[channels] = {0,1,2,3,4,5};		//configuration of PWMs and transmitter channels
 bool const drivenByAcc[channels] = {true, true, true, true, true};		//configuration of channels driven by accelerometers stabilization
 int const accChannelsPosition[channels] = {2,3,4,5,6,7};					//configuration of accelerotmeter channels and transmitter channels
-int const accReverzCorrection[channels] = {1,1,1,1,1,1};					//set reverz and multiplied correction for transmitter channels
 
+int accReverzCorrection[channels] = {1,1,1,1,1,1};					//set reverz and multiplied correction for transmitter channels
 int32_t RCchannels[channels];
 int32_t wantAcc[channels];
+char buttons = 0;
+
+bool getBit(char value, int poce)
+{
+	return value & (1<<poce);
+}
 
 
 void BTRCinit()