Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Patch to control motorised dish with SG-2100



Patch to move the dish to the required satellite automagically.

Uses Moteck SG-2100 positioner, maybe it works also with
Stab HH-120 but Stab refused to give any programming info about
their extensions to DiSEqc 1.2 or USALS protocol.

Satellite position is taken directly from channels.conf (S19.2E),
actual position is then calculated and disk moved to correct
direction.
Installation longitude (Your position) needs to be inserted in setup
(Setup LNB/UseGotoX/MyLocation).
The value must be in fixedpoint form (24.7E = 247 or 5W = 3550)
as I'm too dumb/lazy to make new valuetype for menu.
This has not been tested in real life, because it's too bloody
cold (-18) to go and mess with the dish, but it appears to
turn into right directions on the table.
This could be expanded to USALS protocol with automatic hunting
for best position.
Maybe somebody with installed positioner (Moteck or Stab) could test this.
Any feedback is welcome.

-----------------------------------
--- ./orig/vdr-1.3.2/config.c	2004-01-11 17:38:11.000000000 +0200
+++ vdr-1.3.2/config.c	2004-01-21 17:16:12.000000000 +0200
@@ -255,6 +255,9 @@
   LnbFrequLo =  9750;
   LnbFrequHi = 10600;
   DiSEqC = 0;
+  UseGotoX = 1;
+  IsSouth = 0;
+  MyLongitude = 247;
   SetSystemTime = 0;
   TimeTransponder = 0;
   MarginStart = 2;
@@ -442,6 +445,9 @@
   else if (!strcasecmp(Name, "LnbFrequLo"))          LnbFrequLo         = atoi(Value);
   else if (!strcasecmp(Name, "LnbFrequHi"))          LnbFrequHi         = atoi(Value);
   else if (!strcasecmp(Name, "DiSEqC"))              DiSEqC             = atoi(Value);
+  else if (!strcasecmp(Name, "UseGotoX"))            UseGotoX           = atoi(Value);
+  else if (!strcasecmp(Name, "IsSouth"))             IsSouth            = atoi(Value);
+  else if (!strcasecmp(Name, "MyLongitude"))         MyLongitude        = atoi(Value);
   else if (!strcasecmp(Name, "SetSystemTime"))       SetSystemTime      = atoi(Value);
   else if (!strcasecmp(Name, "TimeTransponder"))     TimeTransponder    = atoi(Value);
   else if (!strcasecmp(Name, "MarginStart"))         MarginStart        = atoi(Value);
@@ -494,6 +500,9 @@
   Store("LnbFrequLo",         LnbFrequLo);
   Store("LnbFrequHi",         LnbFrequHi);
   Store("DiSEqC",             DiSEqC);
+  Store("UseGotoX",           UseGotoX);
+  Store("IsSouth",            IsSouth);
+  Store("MyLongitude",        MyLongitude);
   Store("SetSystemTime",      SetSystemTime);
   Store("TimeTransponder",    TimeTransponder);
   Store("MarginStart",        MarginStart);
--- ./orig/vdr-1.3.2/config.h	2004-01-11 23:42:23.000000000 +0200
+++ vdr-1.3.2/config.h	2004-01-21 17:06:24.000000000 +0200
@@ -216,6 +216,9 @@
   int LnbFrequLo;
   int LnbFrequHi;
   int DiSEqC;
+  int UseGotoX;
+  int IsSouth;
+  int MyLongitude;
   int SetSystemTime;
   int TimeTransponder;
   int MarginStart, MarginStop;
Only in vdr-1.3.2: config.o
Only in vdr-1.3.2: cutter.o
Only in vdr-1.3.2: device.o
Only in vdr-1.3.2: diseqc.o
--- ./orig/vdr-1.3.2/dvbdevice.c	2004-01-10 14:21:41.000000000 +0200
+++ vdr-1.3.2/dvbdevice.c	2004-01-22 22:53:54.000000000 +0200
@@ -197,10 +197,88 @@
                tone = SEC_TONE_ON;
                }
             int volt = (channel.Polarization() == 'v' || channel.Polarization() == 'V') ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18;
-            CHECK(ioctl(fd_frontend, FE_SET_VOLTAGE, volt));
-            CHECK(ioctl(fd_frontend, FE_SET_TONE, tone));
-            }

+/*	Use unofficial modification to DiSEqc 1.2, introduced by Stab and Moteck
+	Enchanced (DiSEqc 1.3) command 'Goto Angular Position (degrees)'
+	Format of command: E0 31 6E tu vx
+	Where:
+	t:	D for West / E for East on Northern Hemisphere
+	u v:	degrees = 16 * u + v
+	x:	0 for 0.0 degree
+		1 or 2 for 0.1 degree
+		3 for 0.2 degree
+		4 or 5 for 0.3
+		6 for 0.4
+		7 or 8 for 0.5
+		9 or A for 0.6
+		B for 0.7
+		C or D for 0.8
+		E for 0.9
+*/
+	    if (Setup.UseGotoX) {
+		bool Verbose  = 1;			// Some info into user.log
+		bool TurnWest = 0;
+		unsigned int frac[] = {0,1,3,4,6,7,9,0xb,0xc,0xe};
+		struct dvb_diseqc_master_cmd gox;
+		unsigned int RealPos = 0;
+		unsigned int Longitude = Setup.MyLongitude;
+		unsigned int SatPos = channel.Source() & 0x7ff;
+		if (!(channel.Source() & 0x800)) {
+		    SatPos = 3600 - SatPos;		// make range 0.0 - 359.9 degrees
+		}
+		if (SatPos == Longitude) {		// Special case, satellite is at True South, (recalibrate to zero)
+		    gox.msg_len = 4;
+		    gox.msg[0]  = 0xE0;
+		    gox.msg[1]  = 0x31;
+		    gox.msg[2]  = 0x6B;
+		    gox.msg[3]  = 0x00;
+		    dsyslog("Turn to satellite pos 0 (zero reference position) at %u.%u", SatPos/10, SatPos%10);
+		} else {
+    		    if (Longitude < 1800) {			// Our location is East from 0 meridian
+			TurnWest = (SatPos < Longitude) || (SatPos > 1800);
+			if (SatPos < 1800) {
+			    RealPos = abs(SatPos - Longitude);
+			} else {
+			    RealPos = abs(3600 - (SatPos - Longitude));
+    			}
+		    } else {					// Our location is West from 0 meridian
+			TurnWest = (SatPos > Longitude) && (SatPos > 1800);
+			if (SatPos > Longitude) {
+			    RealPos = abs(SatPos - Longitude);
+			} else {
+			    RealPos = abs((3600 + SatPos) - Longitude);
+    			}
+		    }
+    		    if (Setup.IsSouth) TurnWest = !TurnWest;	// We are Down Under with 'roos
+		    gox.msg_len = 5;				// Angular position calculated, let's make command string
+		    gox.msg[0]  = 0xE0;
+		    gox.msg[1]  = 0x31;
+		    gox.msg[2]  = 0x6E;
+		    unsigned int u = (RealPos/10)/16;
+		    unsigned int v = (RealPos/10)%16;
+		    (TurnWest) ? gox.msg[3] = 0xD0 + u : gox.msg[3] = 0xE0 + u;
+		    gox.msg[4] = (v * 16) + frac[RealPos%10];
+		    if (Verbose) {				// Some info to log, maybe..
+			char *RealDir = NULL;
+			dsyslog("Satellite located at %u.%u degrees", SatPos/10, SatPos%10);
+				 (TurnWest) ? RealDir = "West" : RealDir = "East";
+			dsyslog("Dish needs to point to %u.%u %s from True South (%u.%u)",
+			         RealPos/10, RealPos%10, RealDir, Longitude/10, Longitude%10);
+			dsyslog("DiSEqC command string %x %x %x %x %x",
+			         gox.msg[0], gox.msg[1], gox.msg[2], gox.msg[3], gox.msg[4]);
+		    }
+		}
+        	CHECK(ioctl(fd_frontend, FE_SET_TONE, SEC_TONE_OFF));
+                CHECK(ioctl(fd_frontend, FE_SET_VOLTAGE, volt));
+		usleep(15000);			// WAIT 15 ms
+                CHECK(ioctl(fd_frontend, FE_DISEQC_SEND_MASTER_CMD, &gox));
+		usleep(15000);			// WAIT 15 ms
+        	CHECK(ioctl(fd_frontend, FE_SET_TONE, tone));
+	    } else {
+                CHECK(ioctl(fd_frontend, FE_SET_VOLTAGE, volt));
+        	CHECK(ioctl(fd_frontend, FE_SET_TONE, tone));
+            }
+	 }
          frequency = abs(frequency); // Allow for C-band, where the frequency is less than the LOF
          Frontend.frequency = frequency * 1000UL;
          Frontend.inversion = fe_spectral_inversion_t(channel.Inversion());
--- ./orig/vdr-1.3.2/i18n.c	2004-01-17 16:39:38.000000000 +0200
+++ vdr-1.3.2/i18n.c	2004-01-22 22:46:35.000000000 +0200
@@ -2625,6 +2625,61 @@
     "Utilitzar DiSEqC",
     "žáßÞÛì×ÞÒÐâì DiSEqC",
   },
+  { "Setup.LNB$Use GotoX Positioner)",
+    "",
+    "",
+    "",
+    "",
+    "",
+    "",
+    "",
+    "Käytä GotoX Moottoria",
+    "",
+    "",
+    "",
+    "",
+    "",
+    "",
+    "",
+    "",
+  },
+  { "Setup.LNB$Location is Southern hemisphere ?)",
+    "",
+    "",
+    "",
+    "",
+    "",
+    "",
+    "",
+    "Olet eteläisellä pallonpuoliskolla",
+    "",
+    "",
+    "",
+    "",
+    "",
+    "",
+    "",
+    "",
+  },
+  { "Setup.LNB$My longitude is (24.7E = 247))",
+    "",
+    "",
+    "",
+    "",
+    "",
+    "",
+    "",
+    "Pituusasteeni on (24.7E = 247)",
+    "",
+    "",
+    "",
+    "",
+    "",
+    "",
+    "",
+    "",
+  },
+
   { "Setup.CICAM$CICAM DVB",
     "CICAM DVB",
     "CICAM DVB",
--- ./orig/vdr-1.3.2/menu.c	2004-01-17 16:17:00.000000000 +0200
+++ vdr-1.3.2/menu.c	2004-01-21 17:37:11.000000000 +0200
@@ -2181,6 +2181,11 @@
      Add(new cMenuEditIntItem( tr("Setup.LNB$SLOF (MHz)"),               &data.LnbSLOF));
      Add(new cMenuEditIntItem( tr("Setup.LNB$Low LNB frequency (MHz)"),  &data.LnbFrequLo));
      Add(new cMenuEditIntItem( tr("Setup.LNB$High LNB frequency (MHz)"), &data.LnbFrequHi));
+     Add(new cMenuEditBoolItem(tr("Setup.LNB$Use GotoX positioner"),     &data.UseGotoX));
+     if(data.UseGotoX) {
+        Add(new cMenuEditBoolItem(tr("Setup.LNB$Location is southern hemi"),&data.IsSouth));
+        Add(new cMenuEditIntItem( tr("Setup.LNB$My longitude is"),          &data.MyLongitude));
+	}
      }

   SetCurrent(Get(current));
----------------------------------------





--
Info:
To unsubscribe send a mail to ecartis@linuxtv.org with "unsubscribe vdr" as subject.



Home | Main Index | Thread Index