SlideShare a Scribd company logo
1 of 16
Download to read offline
Diseqc x/USALS interface
ZSOLT LEVENTE Page 1
V 1
Short description:
This equipment is intended to interface Diseqc & Usals compatible
receivers with old parabolic dish actuators.
The interface takes its power supply from IF coax which connects receiver and
LNB. When valid data comes from receiver the interface powers up and the
decoded command is executed.
Diseqc x/USALS interface
ZSOLT LEVENTE Page 2
SCHEMATIC :
Diseqc x/USALS interface
ZSOLT LEVENTE Page 3
Code :
//--------------------------------------------------------------------------------------
// HED'S
//--------------------------------------------------------------------------------------
#include <math.h>
//--------------------------------------------------------------------------------------
// DEF'S
//--------------------------------------------------------------------------------------
#define goE RB7
#define in RB6
#define goW RB4
#define out RB3
#define power RB5
#define inHall RA0
//----------------------------------------------------------------------------------
#define frame1 0xE0 // Command from Master, No reply required, First transmission
#define frame2 0xE1 // Command from Master, No reply required, Repeated transmission
#define frame3 0xE2 // Command from Master, Reply required, First transmission
#define frame4 0xE3 // Command from Master, Reply required, Repeated transmission
#define frame5 0xE4 // Reply from Slave, “OK”, no errors detected
#define frame6 0xE5 // Reply from Slave, Command not supported by slave
#define frame7 0xE6 // Reply from Slave, Parity Error detected - Request repeat
#define frame8 0xE7 // Reply from Slave, Command not recognised - Request repeat
//--------------------------------------------------------------------------------------
Diseqc x/USALS interface
ZSOLT LEVENTE Page 4
// GLOBAL'S
//--------------------------------------------------------------------------------------
char timer=0;
int steptimer=0, timedMove=0;
char REC_FRAME=0,REC_ADDRESS=0,REC_CMD=0,REC_DATA=0;
//--------------------------------------------------------------------------------------
// PREDEF'S
//--------------------------------------------------------------------------------------
unsigned char DISEQC_REC (void);
void Halt(void);
void LimitsOff(void);
void PosStat(void);
void LimitE(void);
void LimitW(void);
void DriveEast(void);
void DriveWest(void);
void Storenn(void);
void Gotonn(void);
void Gotoxx(void);
void SetPosns(void);
void CommandTask (void);
void Reply1(void);
void Reply2(void);
void ReqReTransm(void);
void Setup(void);
Diseqc x/USALS interface
ZSOLT LEVENTE Page 5
//***********************************************************************************
**
// INTERUPT SERVICE ROUTINES
//***********************************************************************************
**
static void interrupt
isr(void)
{
if(T0IF)
{
T0IF=0;
// WriteTimer0(64098); // 1ms
if(timer>0)timer--;
if(steptimer>0)steptimer--;
if(timedMove && !steptimer)Halt();
}
}
//***********************************************************************************
**
// return x Byte received
OK
// 0 Timedout
Diseqc x/USALS interface
ZSOLT LEVENTE Page 6
// 'P' parity error
//***********************************************************************************
**
unsigned char DISEQC_REC (void)
{
unsigned char par=1,inbit=0;
int result=0,i=0;
REC_FRAME=0;REC_ADDRESS=0;REC_CMD=0;REC_DATA=0;
while(1)
{
timer=2;
while(!in){ if(!timer)goto Rxend;if(in==1)break;}
TMR1L=0;
__delay_us(1050);//1050us
result=TMR1L;
if(result>19 & result<25)inbit=0;
if(result>9 & result<14)inbit=1;
if(i>=0 && i<8) {
REC_FRAME=REC_FRAME<<1;
if(inbit==1){REC_FRAME=REC_FRAME | 0x01;par=~par;}
}
if(i==8) { if(par==inbit)return 'P'; par=1;}
if(i>=9 && i<17) {
REC_ADDRESS=REC_ADDRESS<<1;
if(inbit==1){REC_ADDRESS=REC_ADDRESS | 0x01;par=~par;}
Diseqc x/USALS interface
ZSOLT LEVENTE Page 7
}
if(i==17){if(par==inbit)return 'P'; par=1;}
if(i>=18 && i<26) {
REC_CMD=REC_CMD<<1;
if(inbit==1){REC_CMD=REC_CMD | 0x01;par=~par;}
}
if(i==26){if(par==inbit)return 'P'; par=1;}
if(i>=27 && i<35) {
REC_DATA=REC_DATA<<1;
if(inbit==1){REC_DATA=REC_DATA | 0x01;par=~par;}
}
if(i==35){if(par==inbit)return 'P'; par=1;}
i++;
}
Rxend:
if (i==0)return 0;
else return i;
}
//***********************************************************************************
**
// Identify command,execute & reply if needed
Diseqc x/USALS interface
ZSOLT LEVENTE Page 8
//***********************************************************************************
**
void CommandTask ()
{
switch (REC_CMD)
{
case 0x60: Halt(); break;
case 0x63: LimitsOff(); break;
case 0x64: PosStat(); break;
case 0x66: LimitE(); break;
case 0x67: LimitW(); break;
case 0x68: DriveEast(); break;
case 0x69: DriveWest(); break;
case 0x6A: Storenn(); break;
case 0x6B: Gotonn(); break;
case 0x6E: Gotoxx(); break;
case 0x6F: SetPosns(); break;
}
switch (REC_FRAME)
{
case frame1: break;
case frame2: break;
case frame3: Reply1(); break;
case frame4: Reply2(); break;
}
}
Diseqc x/USALS interface
ZSOLT LEVENTE Page 9
//***********************************************************************************
**
// Stop Positioner movement
//***********************************************************************************
**
void Halt()
{
goE=goW=0;
}
//***********************************************************************************
**
// Disable Limits
//***********************************************************************************
**
void LimitsOff()
{
}
//***********************************************************************************
**
// Read Positioner Status Register
//***********************************************************************************
**
void PosStat()
{
}
Diseqc x/USALS interface
ZSOLT LEVENTE Page 10
//***********************************************************************************
**
// Set East Limit
//***********************************************************************************
**
void LimitE()
{
}
//***********************************************************************************
**
// Set West Limit
//***********************************************************************************
**
void LimitW()
{
}
//***********************************************************************************
**
// Drive Motor East with optional: timeout (REC_DATA>0) [s]
// steps (REC_DATA<0) [engle]
//***********************************************************************************
**
void DriveEast()
{
Halt();
Diseqc x/USALS interface
ZSOLT LEVENTE Page 11
goE=1;goW=0;
if(REC_DATA==0){ steptimer=0; timedMove=0; }
if(REC_DATA>0) { steptimer=(int)REC_DATA*1000; timedMove=1; }
if(REC_DATA<0) { steptimer=(int)fabs((float)REC_DATA)*2000; timedMove=1; }
}
//***********************************************************************************
**
// Drive Motor West with optional: timeout (REC_DATA>0) [s]
// steps (REC_DATA<0) [engle]
//***********************************************************************************
**
void DriveWest()
{
Halt();
goE=0;goW=1;
if(REC_DATA==0){ steptimer=0; timedMove=0; }
if(REC_DATA>0) { steptimer=(int)REC_DATA*1000; timedMove=1; }
if(REC_DATA<0) { steptimer=(int)fabs((float)REC_DATA)*2000; timedMove=1; }
}
//***********************************************************************************
**
// Store Satellite Position & Enable Limits
//***********************************************************************************
**
void Storenn()
Diseqc x/USALS interface
ZSOLT LEVENTE Page 12
{
}
//***********************************************************************************
**
// Drive Motor to Satellite Position nn
//***********************************************************************************
**
void Gotonn()
{
}
//***********************************************************************************
**
// Drive Motor to Angular Position (°)
//***********************************************************************************
**
void Gotoxx()
{
}
//***********************************************************************************
**
// (Re-) Calculate Satellite Positions
//***********************************************************************************
**
void SetPosns()
{
Diseqc x/USALS interface
ZSOLT LEVENTE Page 13
}
//***********************************************************************************
**
// FIRST REPLY FROM SLAVE
//***********************************************************************************
**
void Reply1()
{
}
//***********************************************************************************
**
// SECOND REPLY FROM SLAVE
//***********************************************************************************
**
void Reply2()
{
}
//***********************************************************************************
**
// REQUEST RETRANSMIT TO MASTER
//***********************************************************************************
**
void ReqReTransm()
{
}
Diseqc x/USALS interface
ZSOLT LEVENTE Page 14
//***********************************************************************************
**
// GENERAL PROIECT SETUP
//***********************************************************************************
**
void Setup ()
{
goE=goW=0;
//---------------------- i/0 setup
TRISB=0b01000000;
TRISA=0;
//---------------------- intSet
INTCON=0b10100000; // GIE,PEIE,T0IE
//---------------------- counter (T1)
T1CON=0b00000010;
//---------------------- timer (T0)
OPTION=0b00000111; //256presc
//WriteTimer1(64098); // 1ms
}
//***********************************************************************************
**
Diseqc x/USALS interface
ZSOLT LEVENTE Page 15
//===================================================================================
=============
// 2012 Jakab Zsolt
// DISEQC 1.2;2.2/USALS compatible interface
// PIC16F628, osc 4 Mhz,
// RB3 - tx
// RA4 - rx
// RB6 - cmdEAST
// RB7 - cmdWest
//
=====================================================================================
==========
#include <htc.h>
#include <stdlib.h>
__CONFIG( WDTDIS & PWRTEN & HS & BOREN & LVPDIS & UNPROTECT );
#ifndef _XTAL_FREQ
#define _XTAL_FREQ 4000000
#include "usalsHED.h"
#endif
//---------------------------------------------------------------------------------------------
void main(void)
{
unsigned char s=0,z=0,u=0,rec=0;
Setup ();
Diseqc x/USALS interface
ZSOLT LEVENTE Page 16
while(1)
{
//-----------------------------rx
rec=DISEQC_REC ();
//-----------------------------
if(rec>0)
{
if(REC_CMD==96)Halt();
if(REC_CMD==104)DriveEast();
if(REC_CMD==105)DriveWest();
}
}
}
//---------------------------------------------------------------------------------------------

More Related Content

Viewers also liked

One-to-Many relational Web Application
One-to-Many relational Web ApplicationOne-to-Many relational Web Application
One-to-Many relational Web ApplicationOnline Database
 
Manual de serviço nx350 partida
Manual de serviço nx350 partidaManual de serviço nx350 partida
Manual de serviço nx350 partidaThiago Huari
 
barış_geçer_tez
barış_geçer_tezbarış_geçer_tez
barış_geçer_tezBaris Geçer
 
Manual de serviço xlx350 r cabecote
Manual de serviço xlx350 r cabecoteManual de serviço xlx350 r cabecote
Manual de serviço xlx350 r cabecoteThiago Huari
 
Mission SAY No to Cervical Cancer With HPV Vaccination DR. SHARDA JAIN S...
Mission SAY No to Cervical Cancer   With HPV Vaccination DR. SHARDA JAIN  S...Mission SAY No to Cervical Cancer   With HPV Vaccination DR. SHARDA JAIN  S...
Mission SAY No to Cervical Cancer With HPV Vaccination DR. SHARDA JAIN S...Lifecare Centre
 
USPS® Rate Change 2017: What You Need To Know
USPS® Rate Change 2017: What You Need To Know USPS® Rate Change 2017: What You Need To Know
USPS® Rate Change 2017: What You Need To Know Pitney Bowes
 
La Restauración II (1902-1923)
La Restauración II (1902-1923)La Restauración II (1902-1923)
La Restauración II (1902-1923)cherepaja
 

Viewers also liked (12)

One-to-Many relational Web Application
One-to-Many relational Web ApplicationOne-to-Many relational Web Application
One-to-Many relational Web Application
 
JASIM PROCESS OPERATOR
JASIM PROCESS OPERATORJASIM PROCESS OPERATOR
JASIM PROCESS OPERATOR
 
HDIACJournal_March232015
HDIACJournal_March232015HDIACJournal_March232015
HDIACJournal_March232015
 
Manual de serviço nx350 partida
Manual de serviço nx350 partidaManual de serviço nx350 partida
Manual de serviço nx350 partida
 
barış_geçer_tez
barış_geçer_tezbarış_geçer_tez
barış_geçer_tez
 
Manual de serviço xlx350 r cabecote
Manual de serviço xlx350 r cabecoteManual de serviço xlx350 r cabecote
Manual de serviço xlx350 r cabecote
 
IFAC
IFACIFAC
IFAC
 
Introducing HPV Vaccine
Introducing HPV VaccineIntroducing HPV Vaccine
Introducing HPV Vaccine
 
Mission SAY No to Cervical Cancer With HPV Vaccination DR. SHARDA JAIN S...
Mission SAY No to Cervical Cancer   With HPV Vaccination DR. SHARDA JAIN  S...Mission SAY No to Cervical Cancer   With HPV Vaccination DR. SHARDA JAIN  S...
Mission SAY No to Cervical Cancer With HPV Vaccination DR. SHARDA JAIN S...
 
USPS® Rate Change 2017: What You Need To Know
USPS® Rate Change 2017: What You Need To Know USPS® Rate Change 2017: What You Need To Know
USPS® Rate Change 2017: What You Need To Know
 
La Restauración II (1902-1923)
La Restauración II (1902-1923)La Restauración II (1902-1923)
La Restauración II (1902-1923)
 
Cervical cancer hpv
Cervical cancer hpvCervical cancer hpv
Cervical cancer hpv
 

Similar to Diseqc x/USALS Interface Code

Lab08Lab08.cppLab08Lab08.cpp.docx
Lab08Lab08.cppLab08Lab08.cpp.docxLab08Lab08.cppLab08Lab08.cpp.docx
Lab08Lab08.cppLab08Lab08.cpp.docxDIPESH30
 
Alvedit programs
Alvedit programsAlvedit programs
Alvedit programsmcclintick
 
6Modify the bfs.java program (Listing A) to find the minimu.docx
6Modify the bfs.java program (Listing  A) to find the minimu.docx6Modify the bfs.java program (Listing  A) to find the minimu.docx
6Modify the bfs.java program (Listing A) to find the minimu.docxevonnehoggarth79783
 
The Ring programming language version 1.9 book - Part 68 of 210
The Ring programming language version 1.9 book - Part 68 of 210The Ring programming language version 1.9 book - Part 68 of 210
The Ring programming language version 1.9 book - Part 68 of 210Mahmoud Samir Fayed
 
Oracle 12c far sync standby instance
Oracle 12c far sync standby instanceOracle 12c far sync standby instance
Oracle 12c far sync standby instanceMonowar Mukul
 
Alv interactive ABAPreport
Alv interactive ABAPreportAlv interactive ABAPreport
Alv interactive ABAPreportRavi Kanudawala
 
Enabling the Perforce Administrator via Mobile Device
Enabling the Perforce Administrator via Mobile Device  Enabling the Perforce Administrator via Mobile Device
Enabling the Perforce Administrator via Mobile Device Perforce
 
Oracle_TDE_Configurations_steps_ukoug.pdf
Oracle_TDE_Configurations_steps_ukoug.pdfOracle_TDE_Configurations_steps_ukoug.pdf
Oracle_TDE_Configurations_steps_ukoug.pdfssuser865ecd
 

Similar to Diseqc x/USALS Interface Code (16)

Lab08Lab08.cppLab08Lab08.cpp.docx
Lab08Lab08.cppLab08Lab08.cpp.docxLab08Lab08.cppLab08Lab08.cpp.docx
Lab08Lab08.cppLab08Lab08.cpp.docx
 
Alvedit programs
Alvedit programsAlvedit programs
Alvedit programs
 
6Modify the bfs.java program (Listing A) to find the minimu.docx
6Modify the bfs.java program (Listing  A) to find the minimu.docx6Modify the bfs.java program (Listing  A) to find the minimu.docx
6Modify the bfs.java program (Listing A) to find the minimu.docx
 
The Ring programming language version 1.9 book - Part 68 of 210
The Ring programming language version 1.9 book - Part 68 of 210The Ring programming language version 1.9 book - Part 68 of 210
The Ring programming language version 1.9 book - Part 68 of 210
 
Quick reference for hql
Quick reference for hqlQuick reference for hql
Quick reference for hql
 
Quick reference for sqoop
Quick reference for sqoopQuick reference for sqoop
Quick reference for sqoop
 
Readme
ReadmeReadme
Readme
 
serialEEPROM
serialEEPROMserialEEPROM
serialEEPROM
 
002207866
002207866002207866
002207866
 
Oracle 12c far sync standby instance
Oracle 12c far sync standby instanceOracle 12c far sync standby instance
Oracle 12c far sync standby instance
 
Alv interactive ABAPreport
Alv interactive ABAPreportAlv interactive ABAPreport
Alv interactive ABAPreport
 
Wall coordinate
Wall coordinateWall coordinate
Wall coordinate
 
Enabling the Perforce Administrator via Mobile Device
Enabling the Perforce Administrator via Mobile Device  Enabling the Perforce Administrator via Mobile Device
Enabling the Perforce Administrator via Mobile Device
 
Alv Block
Alv BlockAlv Block
Alv Block
 
Orasta500.c
Orasta500.cOrasta500.c
Orasta500.c
 
Oracle_TDE_Configurations_steps_ukoug.pdf
Oracle_TDE_Configurations_steps_ukoug.pdfOracle_TDE_Configurations_steps_ukoug.pdf
Oracle_TDE_Configurations_steps_ukoug.pdf
 

More from Jakab Zsolt

BINARY CLOCKSpecs
BINARY CLOCKSpecsBINARY CLOCKSpecs
BINARY CLOCKSpecsJakab Zsolt
 
Modified JDM programer
Modified JDM programerModified JDM programer
Modified JDM programerJakab Zsolt
 
Modified JDM programer
Modified JDM programerModified JDM programer
Modified JDM programerJakab Zsolt
 
WIND GENERATOR MONITORING AND CONTROL SYSTEM (1)
WIND GENERATOR MONITORING AND CONTROL SYSTEM (1)WIND GENERATOR MONITORING AND CONTROL SYSTEM (1)
WIND GENERATOR MONITORING AND CONTROL SYSTEM (1)Jakab Zsolt
 
incarcare baterii de Elevatoare zona sortare
incarcare baterii de Elevatoare zona sortareincarcare baterii de Elevatoare zona sortare
incarcare baterii de Elevatoare zona sortareJakab Zsolt
 
Regulator automat de nivel la statia de epurare
Regulator automat de nivel la statia de epurareRegulator automat de nivel la statia de epurare
Regulator automat de nivel la statia de epurareJakab Zsolt
 
TABLOU ALIMENTARE ST. EPURARE
TABLOU ALIMENTARE ST. EPURARETABLOU ALIMENTARE ST. EPURARE
TABLOU ALIMENTARE ST. EPURAREJakab Zsolt
 

More from Jakab Zsolt (8)

BINARY CLOCKSpecs
BINARY CLOCKSpecsBINARY CLOCKSpecs
BINARY CLOCKSpecs
 
Modified JDM programer
Modified JDM programerModified JDM programer
Modified JDM programer
 
Modified JDM programer
Modified JDM programerModified JDM programer
Modified JDM programer
 
WIND GENERATOR MONITORING AND CONTROL SYSTEM (1)
WIND GENERATOR MONITORING AND CONTROL SYSTEM (1)WIND GENERATOR MONITORING AND CONTROL SYSTEM (1)
WIND GENERATOR MONITORING AND CONTROL SYSTEM (1)
 
incarcare baterii de Elevatoare zona sortare
incarcare baterii de Elevatoare zona sortareincarcare baterii de Elevatoare zona sortare
incarcare baterii de Elevatoare zona sortare
 
Regulator automat de nivel la statia de epurare
Regulator automat de nivel la statia de epurareRegulator automat de nivel la statia de epurare
Regulator automat de nivel la statia de epurare
 
TABLOU ALIMENTARE ST. EPURARE
TABLOU ALIMENTARE ST. EPURARETABLOU ALIMENTARE ST. EPURARE
TABLOU ALIMENTARE ST. EPURARE
 
datalogger
dataloggerdatalogger
datalogger
 

Diseqc x/USALS Interface Code

  • 1. Diseqc x/USALS interface ZSOLT LEVENTE Page 1 V 1 Short description: This equipment is intended to interface Diseqc & Usals compatible receivers with old parabolic dish actuators. The interface takes its power supply from IF coax which connects receiver and LNB. When valid data comes from receiver the interface powers up and the decoded command is executed.
  • 2. Diseqc x/USALS interface ZSOLT LEVENTE Page 2 SCHEMATIC :
  • 3. Diseqc x/USALS interface ZSOLT LEVENTE Page 3 Code : //-------------------------------------------------------------------------------------- // HED'S //-------------------------------------------------------------------------------------- #include <math.h> //-------------------------------------------------------------------------------------- // DEF'S //-------------------------------------------------------------------------------------- #define goE RB7 #define in RB6 #define goW RB4 #define out RB3 #define power RB5 #define inHall RA0 //---------------------------------------------------------------------------------- #define frame1 0xE0 // Command from Master, No reply required, First transmission #define frame2 0xE1 // Command from Master, No reply required, Repeated transmission #define frame3 0xE2 // Command from Master, Reply required, First transmission #define frame4 0xE3 // Command from Master, Reply required, Repeated transmission #define frame5 0xE4 // Reply from Slave, “OK”, no errors detected #define frame6 0xE5 // Reply from Slave, Command not supported by slave #define frame7 0xE6 // Reply from Slave, Parity Error detected - Request repeat #define frame8 0xE7 // Reply from Slave, Command not recognised - Request repeat //--------------------------------------------------------------------------------------
  • 4. Diseqc x/USALS interface ZSOLT LEVENTE Page 4 // GLOBAL'S //-------------------------------------------------------------------------------------- char timer=0; int steptimer=0, timedMove=0; char REC_FRAME=0,REC_ADDRESS=0,REC_CMD=0,REC_DATA=0; //-------------------------------------------------------------------------------------- // PREDEF'S //-------------------------------------------------------------------------------------- unsigned char DISEQC_REC (void); void Halt(void); void LimitsOff(void); void PosStat(void); void LimitE(void); void LimitW(void); void DriveEast(void); void DriveWest(void); void Storenn(void); void Gotonn(void); void Gotoxx(void); void SetPosns(void); void CommandTask (void); void Reply1(void); void Reply2(void); void ReqReTransm(void); void Setup(void);
  • 5. Diseqc x/USALS interface ZSOLT LEVENTE Page 5 //*********************************************************************************** ** // INTERUPT SERVICE ROUTINES //*********************************************************************************** ** static void interrupt isr(void) { if(T0IF) { T0IF=0; // WriteTimer0(64098); // 1ms if(timer>0)timer--; if(steptimer>0)steptimer--; if(timedMove && !steptimer)Halt(); } } //*********************************************************************************** ** // return x Byte received OK // 0 Timedout
  • 6. Diseqc x/USALS interface ZSOLT LEVENTE Page 6 // 'P' parity error //*********************************************************************************** ** unsigned char DISEQC_REC (void) { unsigned char par=1,inbit=0; int result=0,i=0; REC_FRAME=0;REC_ADDRESS=0;REC_CMD=0;REC_DATA=0; while(1) { timer=2; while(!in){ if(!timer)goto Rxend;if(in==1)break;} TMR1L=0; __delay_us(1050);//1050us result=TMR1L; if(result>19 & result<25)inbit=0; if(result>9 & result<14)inbit=1; if(i>=0 && i<8) { REC_FRAME=REC_FRAME<<1; if(inbit==1){REC_FRAME=REC_FRAME | 0x01;par=~par;} } if(i==8) { if(par==inbit)return 'P'; par=1;} if(i>=9 && i<17) { REC_ADDRESS=REC_ADDRESS<<1; if(inbit==1){REC_ADDRESS=REC_ADDRESS | 0x01;par=~par;}
  • 7. Diseqc x/USALS interface ZSOLT LEVENTE Page 7 } if(i==17){if(par==inbit)return 'P'; par=1;} if(i>=18 && i<26) { REC_CMD=REC_CMD<<1; if(inbit==1){REC_CMD=REC_CMD | 0x01;par=~par;} } if(i==26){if(par==inbit)return 'P'; par=1;} if(i>=27 && i<35) { REC_DATA=REC_DATA<<1; if(inbit==1){REC_DATA=REC_DATA | 0x01;par=~par;} } if(i==35){if(par==inbit)return 'P'; par=1;} i++; } Rxend: if (i==0)return 0; else return i; } //*********************************************************************************** ** // Identify command,execute & reply if needed
  • 8. Diseqc x/USALS interface ZSOLT LEVENTE Page 8 //*********************************************************************************** ** void CommandTask () { switch (REC_CMD) { case 0x60: Halt(); break; case 0x63: LimitsOff(); break; case 0x64: PosStat(); break; case 0x66: LimitE(); break; case 0x67: LimitW(); break; case 0x68: DriveEast(); break; case 0x69: DriveWest(); break; case 0x6A: Storenn(); break; case 0x6B: Gotonn(); break; case 0x6E: Gotoxx(); break; case 0x6F: SetPosns(); break; } switch (REC_FRAME) { case frame1: break; case frame2: break; case frame3: Reply1(); break; case frame4: Reply2(); break; } }
  • 9. Diseqc x/USALS interface ZSOLT LEVENTE Page 9 //*********************************************************************************** ** // Stop Positioner movement //*********************************************************************************** ** void Halt() { goE=goW=0; } //*********************************************************************************** ** // Disable Limits //*********************************************************************************** ** void LimitsOff() { } //*********************************************************************************** ** // Read Positioner Status Register //*********************************************************************************** ** void PosStat() { }
  • 10. Diseqc x/USALS interface ZSOLT LEVENTE Page 10 //*********************************************************************************** ** // Set East Limit //*********************************************************************************** ** void LimitE() { } //*********************************************************************************** ** // Set West Limit //*********************************************************************************** ** void LimitW() { } //*********************************************************************************** ** // Drive Motor East with optional: timeout (REC_DATA>0) [s] // steps (REC_DATA<0) [engle] //*********************************************************************************** ** void DriveEast() { Halt();
  • 11. Diseqc x/USALS interface ZSOLT LEVENTE Page 11 goE=1;goW=0; if(REC_DATA==0){ steptimer=0; timedMove=0; } if(REC_DATA>0) { steptimer=(int)REC_DATA*1000; timedMove=1; } if(REC_DATA<0) { steptimer=(int)fabs((float)REC_DATA)*2000; timedMove=1; } } //*********************************************************************************** ** // Drive Motor West with optional: timeout (REC_DATA>0) [s] // steps (REC_DATA<0) [engle] //*********************************************************************************** ** void DriveWest() { Halt(); goE=0;goW=1; if(REC_DATA==0){ steptimer=0; timedMove=0; } if(REC_DATA>0) { steptimer=(int)REC_DATA*1000; timedMove=1; } if(REC_DATA<0) { steptimer=(int)fabs((float)REC_DATA)*2000; timedMove=1; } } //*********************************************************************************** ** // Store Satellite Position & Enable Limits //*********************************************************************************** ** void Storenn()
  • 12. Diseqc x/USALS interface ZSOLT LEVENTE Page 12 { } //*********************************************************************************** ** // Drive Motor to Satellite Position nn //*********************************************************************************** ** void Gotonn() { } //*********************************************************************************** ** // Drive Motor to Angular Position (°) //*********************************************************************************** ** void Gotoxx() { } //*********************************************************************************** ** // (Re-) Calculate Satellite Positions //*********************************************************************************** ** void SetPosns() {
  • 13. Diseqc x/USALS interface ZSOLT LEVENTE Page 13 } //*********************************************************************************** ** // FIRST REPLY FROM SLAVE //*********************************************************************************** ** void Reply1() { } //*********************************************************************************** ** // SECOND REPLY FROM SLAVE //*********************************************************************************** ** void Reply2() { } //*********************************************************************************** ** // REQUEST RETRANSMIT TO MASTER //*********************************************************************************** ** void ReqReTransm() { }
  • 14. Diseqc x/USALS interface ZSOLT LEVENTE Page 14 //*********************************************************************************** ** // GENERAL PROIECT SETUP //*********************************************************************************** ** void Setup () { goE=goW=0; //---------------------- i/0 setup TRISB=0b01000000; TRISA=0; //---------------------- intSet INTCON=0b10100000; // GIE,PEIE,T0IE //---------------------- counter (T1) T1CON=0b00000010; //---------------------- timer (T0) OPTION=0b00000111; //256presc //WriteTimer1(64098); // 1ms } //*********************************************************************************** **
  • 15. Diseqc x/USALS interface ZSOLT LEVENTE Page 15 //=================================================================================== ============= // 2012 Jakab Zsolt // DISEQC 1.2;2.2/USALS compatible interface // PIC16F628, osc 4 Mhz, // RB3 - tx // RA4 - rx // RB6 - cmdEAST // RB7 - cmdWest // ===================================================================================== ========== #include <htc.h> #include <stdlib.h> __CONFIG( WDTDIS & PWRTEN & HS & BOREN & LVPDIS & UNPROTECT ); #ifndef _XTAL_FREQ #define _XTAL_FREQ 4000000 #include "usalsHED.h" #endif //--------------------------------------------------------------------------------------------- void main(void) { unsigned char s=0,z=0,u=0,rec=0; Setup ();
  • 16. Diseqc x/USALS interface ZSOLT LEVENTE Page 16 while(1) { //-----------------------------rx rec=DISEQC_REC (); //----------------------------- if(rec>0) { if(REC_CMD==96)Halt(); if(REC_CMD==104)DriveEast(); if(REC_CMD==105)DriveWest(); } } } //---------------------------------------------------------------------------------------------