Arduino DiSEqC Decoder

Status
Please reply by conversation.

KE4EST

SatelliteGuys Is My Second Home
Original poster
Staff member
HERE TO HELP YOU!
Lifetime Supporter
Aug 9, 2004
26,892
7,246
EM75xb
Over the last few weeks I have been working on a DiSEqC decoder using an Arduino board.
The idea started a few years ago when Mike Berg, N0QBH posted his decoder using a PIC chip.
My weapon(micro-controller) of choice is the Atmel series of chips. Most of the Arduino boards have Atmel chips, so their boards are perfect. I built the PIC version from Mike and it worked perfect. However, it did just what it said and decoded the DiSEqC packets and printed the Hex numbers. I wanted more. I wanted it to print out on a display what all those numbers meant.
When I get a print out of: E0 31 6B 04, ok now what? Okay, so I go to the documentation over at, Eutelsat, download a PDF and look it up.
I don't want to have to do that every time. This is not 1985, I have a micro-controller chip with enough memory and fast enough to decode all this, and print to a display in-between packets.

So the search began, kinda as a side thing, I didn't pour hours into it at first.
Didn't want to re-invent the wheel, so began searching Google for Arduino + DiSEqC.
WOW, really nobody had done it before. I know FTA is niche in NA, but not in other parts of the world.
Arduino + Atmel same thing, people had asked about it on the arduino forum, but no one offered a solution or any code. YouTube has a couple of videos in languages I do not speak, showing a very poor video decoding but no code offered or any website to their code. Trying to email these people yielded nothing.
I did run across the stuff over at http://www.juras-projects.org/eng/projects.php, which everyone always posts here on the site when someone mentions DiSEqC decoding. However, they do not release the source code, just the hex file to burn to a chip.
Then one day qwert1515 posted something about using an arduino to decode DiSEqC packets. So my interest piqued again and I fired off an email to him. He quickly sent me some working code and a schematic.
Finally!!!!!
Except I tried everything and could never get it to decode. :(
He said his worked fine; all it did was print the binary to a serial port, ie. 1110 0000 0001, etc., but was a start.
However, I never got it to work. So got off to other things, and it went to the back burner again.

At some point along the way I bread boarded the circuit again loaded the code up on an uno, or nano board and tried again. Nope.

Fast forward to a couple of months ago.

I decided I was going to this again and it will work!
So built up the circuit again and loaded up the code. Not surprising still nothing.
I knew the code on the Arduino was trying to do something, because if I touched the pin the code was reading I got a hundreds of random 1's and 0's on the screen... and only when I touched it.

Ok, time for me to really sit down and read all the pages of documentation over at Eutelsat and see how this works. I had went over it before, but had not had the determination I did now. Okay, so I think I got this, so going through Jeremy's(qwert1515) code, it should work. There was one line in his code I didn't understand, I meant I knew what it did, but couldn't figure out what it was doing in this case. I asked, he told me and I was like aha okay. So went back through his code and knowing how everything worked, made a few changes to suit my taste.
It should work, no reason for it not to.
Okay time to fire up the oscilloscope. Hmmm, what I thought I should see and what I was seeing was different. Okay...hmmm..Okay so I tried another receiver. Hey, that looks right, still nothing though.
Sooo, I started probing through the very simple circuit. Noticed was getting very much output going to the arduino. Tried a new transistor and a couple of caps, same result. What is going on here, the circuit is simple and should work fine.
Hmmm let's see, what if? Yes, of course, put a load on it. So I hooked up a LNBF and low and behold I stated seeing gibberish on the screen. :)
OK, but I don't want 1's and 0's. I remembered a couple of years ago, Jeremy had sent me some code to convert the pulses to the Hex output. I looked it up and put it with the code and there is was. :):)
I was seeing what looked right. After some further looking though, it was not right. The commands printed did not match anything on Eutelsat or anywhere. Only thing that was right was the E0 at the start. Okay back to the documentation. Aha, each byte also includes a odd parity bit that is not necessary for decoding for what I want. So add some line to the code to ignore every ninth bit that is received.

Finally after over two years there it was decoding and decoding properly to the screen via the serial port. :)
This was all based on Jeremy's code and using polling. I have tried to contact him, but he is busy with work right now and, I have not got a reply back, so I will not post his code or the version I modified based on his code.

However, during on this over the last few weeks, I wrote a program from scratch and using interrupts. I don't have the code fully documented as to what everything does, but I will post it.
I have searched for over two years trying to find something for the Arduino, I sure am not going to brag about mine and not post it. I hope it can help someone else.
I hope someone on here will do it themselves. I would really like it if someone built it that knows C programming well and can offer their changes to make the code better and why they did it.
My code is far from Dennis Ritchie, but it works and seems to work pretty well.

Enjoy.
 
Last edited:
Here is the current code. I am still tweaking it and adding to it. I need to go through it and comment it better though out the code.

C:
/**
  This code for the Arduino was written by KE4EST, Michael Graves, starting in May of 2016.
  The purpose of this code is to decode the DiSEqC commands issued by most FTA receivers.
  This is Version 0.4.7 and is constantly being updated.
  Feel free to use this code for your own project. All I ask is that you leave a reference to myself, KE4EST.
  This code has been tested on the Arduino, Nano, Uno, and the Mega.

  *********A couple of lines need to be changed depending on which board is being used.**************

**/
#include <LiquidCrystal.h>
#define rawBtn A5

#define detectReg 7 // for Mega
//#define detectReg 5 // for Uno, Nano
LiquidCrystal lcd(12, 11, 7, 6, 5, 4);

volatile int pwm_value = 0; //used inside interrupt for microseconds between pulses
volatile int prev_time = 0; //used with pwm_value to grab the start time

volatile bool nibble1[4]; //array to hold each nibble
volatile bool nextLineOK = 1;  //OK to start counter for next line
volatile int bitCount = 0;  // used to count the bits(when you hit 4 you have a nibble that can be processed)
volatile int ninthBitCount = 0; //Used to look for 9th bit to ignore

volatile bool packetDetect = 0; //Used to let toneCount know it can start counting
volatile int toneCount = 0; //Used to count to flash LED to indicate tone has been detected
int byteParse = 0; //used to group the output into two's so that, E0316B3C look like E0 31 6B 3C
int nextPacket = 0; //increments with each full nibble, to know when 8 is achieved so it knows end of packet has been reached

unsigned long purge = 0;  // used to count after packet, to issue a CR

String diseqc = ""; //String to store the commands as string, used to parse data for displaying what the commands are
//  Switch port 1, or Motor goto 16, etc.
String rawInput; //String to store the raw input ie. 1110 0000 0011 0001......
String hexOutput;  //String to test for repeats
long test = -1;
bool insertZero = 0;
bool errorCheck = 1;
byte newChar[8] = { B00000, B00000, B01010, B11111, B11111, B11111, B01110, B00100 };
unsigned long errorCount = 0;


void setup(void)
{
  //  digitalWrite(11, 1);
  lcd.begin(20, 4);
  lcd.createChar(0, newChar);
  pinMode(rawBtn, INPUT);
  pinMode(13, OUTPUT);
  Serial.begin(115200);
  lcd.setCursor(7, 0);
  lcd.print("Arduino");
  lcd.setCursor(3, 1);
  lcd.print("DISEQC Decoder");
  lcd.setCursor(0, 2);
  lcd.print("  By: KE4EST");
  lcd.setCursor(0, 3);
  lcd.print("Ver. 0.4.7  08.11.16");
  Serial.println("KE4EST Arduino DiSEqC Decoder");
  Serial.println("Version 0.4.7");
  Serial.println("August 11th 2016");
  delay(2000);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("DISEQC: ");
  lcd.setCursor(0, 1);
  lcd.print("Cmd Type:  ");
  lcd.setCursor(0, 2);
  lcd.print("Data");
  //  lcd.setCursor(0, 3);
  //  lcd.print("");
  //Serial.println();

  attachInterrupt(0, rising, RISING); // when pin D2 goes high, call the rising function


}

void loop(void)
{

  if (packetDetect)
  {
  PORTB |= (1 << detectReg); // Tone detect LED attached to pin 13

  lcd.setCursor(19, 3);
  lcd.write((byte)0);
  toneCount++;
  if (toneCount == 256)
  {
  PORTB &= ~(1 << detectReg);
  lcd.setCursor(19, 3);
  lcd.print(" ");
  toneCount = 0;
  packetDetect = 0;
  }
  }

  purge++;

  if (ninthBitCount == 9)
  {
  //rawInput -= " ";
  bitCount = 0;
  ninthBitCount = 0;
  }
  if (bitCount == 4)
  {
  //rawInput += " ";

  outputNibble(nibble1);
  if (insertZero)
  {
  bitCount = 1;
  nibble1[0] = 0;
  ninthBitCount++;
  insertZero = 0;
  }
  else
  {
  bitCount = 0;
  }
  byteParse += 1;
  if (byteParse == 2)
  {
  diseqc += " ";
  byteParse = 0;
  }
  nextPacket = nextPacket + 1;
  }
  if (nextPacket == 8)
  {
  if (diseqc != "")
  {
  if (digitalRead(rawBtn) == 1)
  {
  Serial.println();
  Serial.print("Raw: ");
  Serial.println(rawInput);
  test += 1;
  }
  else
  {
  Serial.println();
  test += 1;
  Serial.print(test);
  Serial.print("::");
  }


  Serial.print("Hex:: ");
  Serial.print(diseqc);
  lcd.setCursor(8, 0);
  lcd.print(diseqc);
  if (hexOutput == diseqc)
  {
  Serial.println(" ::Repeated Command");
  lcd.setCursor(0, 3);
  lcd.print("Repeated ");
  lcd.print(test);
  if (test == 1)
  {
  lcd.print(" Time");
  }
  else
  {
  lcd.print(" Times");
  }
  }
  else
  {
  test = 0;
  hexOutput = diseqc;
  Serial.println();
  lcd.setCursor(0, 3);
  lcd.print("  ");
  }
  }
  if (digitalRead(rawBtn) == 1)
  {
  String raw1 = rawInput.substring(0, 19);
  String raw2 = rawInput.substring(20, 39);
  lcd.setCursor(0, 1);
  lcd.print(raw1);
  lcd.setCursor(0, 2);
  lcd.print(raw2);
  }
  else
  {
  DATA_EXTRACT(diseqc);
  }
  rawInput = "";
  diseqc = "";
  nextPacket = 0;
  errorCheck = 1;
  EIFR = 1;
  //bitCount = 0;

  }

  if (purge > 1024 && diseqc != "")
  {
  Serial.print(test);
  Serial.println();
  Serial.print("Hex:: ");
  Serial.print(diseqc);
  lcd.setCursor(17, 0);
  lcd.print("  ");
  lcd.setCursor(8, 0);
  lcd.print(diseqc);
  if (hexOutput == diseqc)
  {
  Serial.println(" ::Repeated Command");
  lcd.setCursor(0, 3);
  lcd.print("Repeated ");
  lcd.print(test);
  if (test == 1)
  {
  lcd.print(" Time");
  }
  else
  {
  lcd.print(" Times");
  }
  }
  else
  {
  test = 0;
  hexOutput = diseqc;
  Serial.println();
  lcd.setCursor(0, 3);
  lcd.print("  ");
  }
  if (digitalRead(rawBtn) == 1)
  {
  String raw1 = rawInput.substring(0, 19);
  String raw2 = rawInput.substring(20, 39);
  lcd.setCursor(0, 1);
  lcd.print(raw1);
  lcd.setCursor(0, 2);
  lcd.print(raw2);
  }
  else
  {
  DATA_EXTRACT(diseqc);
  }
  rawInput = "";
  diseqc = "";
  nextPacket = 0;
  purge = 0;
  bitCount = 0;
  EIFR = 1;

  }
  errorCheck = 1;
}

void rising(void)
{
  attachInterrupt(0, falling, FALLING);
  prev_time = micros();

}

void falling(void)
{
  attachInterrupt(0, rising, RISING);
  packetDetect = 1;
  pwm_value = micros() - prev_time;
  //  Serial.print(pwm_value); //uncomment for testing
  //  Serial.print(" ");
  if (pwm_value < 550)
  {
  nibble1[bitCount] = 0;
  bitCount++;
  ninthBitCount++;
  }
  if (pwm_value >= 550)
  {
  nibble1[bitCount] = 1;
  bitCount++;
  ninthBitCount++;
  }
}

void outputNibble(volatile bool nibble[4])
{
  purge = 0;


  if (nibble[0] == 0 && nibble[1] == 0 && nibble[2] == 0 && nibble[3] == 0)
  {
  diseqc += "0";
  rawInput += "0000 ";
  }
  else if (nibble[0] == 0 && nibble[1] == 0 && nibble[2] == 0 && nibble[3] == 1)
  {
  diseqc += "1";
  rawInput += "0001 ";
  }
  else if (nibble[0] == 0 && nibble[1] == 0 && nibble[2] == 1 && nibble[3] == 0)
  {
  diseqc += "2";
  rawInput += "0010 ";
  }
  else if (nibble[0] == 0 && nibble[1] == 0 && nibble[2] == 1 && nibble[3] == 1)
  {
  //Serial.print("3");
  diseqc += "3";
  rawInput += "0011 ";
  }
  else if (nibble[0] == 0 && nibble[1] == 1 && nibble[2] == 0 && nibble[3] == 0)
  {
  diseqc += "4";
  rawInput += "0100 ";
  }
  else if (nibble[0] == 0 && nibble[1] == 1 && nibble[2] == 0 && nibble[3] == 1)
  {
  diseqc += "5";
  rawInput += "0101 ";
  }
  else if (nibble[0] == 0 && nibble[1] == 1 && nibble[2] == 1 && nibble[3] == 0)
  {
  diseqc += "6";
  rawInput += "0110 ";
  }
  else if (nibble[0] == 0 && nibble[1] == 1 && nibble[2] == 1 && nibble[3] == 1)
  {
  diseqc += "7";
  rawInput += "0111 ";
  }
  else if (nibble[0] == 1 && nibble[1] == 0 && nibble[2] == 0 && nibble[3] == 0)
  {
  diseqc += "8";
  rawInput += "1000 ";
  }
  else if (nibble[0] == 1 && nibble[1] == 0 && nibble[2] == 0 && nibble[3] == 1)
  {
  //Serial.print("9");
  diseqc += "9";
  rawInput += "1001 ";
  }
  else if (nibble[0] == 1 && nibble[1] == 0 && nibble[2] == 1 && nibble[3] == 0)
  {
  diseqc += "A";
  rawInput += "1010 ";
  }
  else if (nibble[0] == 1 && nibble[1] == 0 && nibble[2] == 1 && nibble[3] == 1)
  {
  //Serial.print("B");
  diseqc += "B";
  rawInput += "1011 ";
  }
  else if (nibble[0] == 1 && nibble[1] == 1 && nibble[2] == 0 && nibble[3] == 0)
  {
  if (errorCheck)
  {
  Serial.println("Error Caught!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
  errorCount ++;
  lcd.setCursor(16, 2);
  lcd.print(errorCount);
  diseqc += "E";
  rawInput += "1110 ";
  errorCheck = 0;
  insertZero = 1;
  }
  else
  {
  diseqc += "C";
  rawInput += "1100 ";
  }
  }
  else if (nibble[0] == 1 && nibble[1] == 1 && nibble[2] == 0 && nibble[3] == 1)
  {
  diseqc += "D";
  rawInput += "1101 ";
  }
  else if (nibble[0] == 1 && nibble[1] == 1 && nibble[2] == 1 && nibble[3] == 0)
  {
  diseqc += "E";
  rawInput += "1110 ";
  }
  else if (nibble[0] == 1 && nibble[1] == 1 && nibble[2] == 1 && nibble[3] == 1)
  {
  diseqc += "F";
  rawInput += "1111 ";
  }
}


void DATA_EXTRACT(String data)
{
  String diseqcParse = data.substring(3, 5);
  //  Serial.print("Sub String Test = ");
  //  Serial.println(diseqcParse);
  if (diseqcParse == "31")
  {
  Serial.print("Motor Command: ");
  lcd.setCursor(0, 1);
  lcd.print("Cmd Type: Motor  ");
  String diseqcParse = data.substring(6, 8);
  String mNumber = data.substring(9, 11);
  Motor(diseqcParse, mNumber);
  }
  else if (diseqcParse == "10")
  {
  Serial.print("Switch Command: ");
  lcd.setCursor(0, 1);
  lcd.print("Cmd Type: Switch  ");
  String diseqcParse = data.substring(6, 8);
  String swNumber = data.substring(9, 11);
  Switch(diseqcParse, swNumber);
  }
  else
  {
  Serial.println("Unrecognized Command!!");
  lcd.setCursor(0, 1);
  lcd.print("Decode Error!! ");
  }
}


void Motor(String mData, String mNum)
{
  if (mData == "6B")
  {
  Serial.print("Goto: ");
  Serial.println(hexStoDec(mNum));
  lcd.setCursor(0, 2);
  lcd.print("  ");
  lcd.setCursor(0, 2);
  lcd.print("Goto: ");
  lcd.print(hexStoDec(mNum));
  }
  if (mData == "6A")
  {
  Serial.print("Store As Position: ");
  Serial.println(hexStoDec(mNum));
  lcd.setCursor(0, 2);
  lcd.print("Store As Pos: ");
  lcd.print(hexStoDec(mNum));
  }
  if (mData == "69")
  {
  Serial.print("Move West: ");
  Serial.println(commandLookUp(mNum));
  lcd.setCursor(0, 2);
  lcd.print("Go West ");
  lcd.print(commandLookUp(mNum));
  }
  if (mData == "68")
  {
  Serial.print("Move East: ");
  Serial.println(commandLookUp(mNum));
  lcd.setCursor(0, 2);
  lcd.print("Go East ");
  lcd.print(commandLookUp(mNum));
  }
  if (mData == "60")
  {
  Serial.println("Motor Stop!!");
  lcd.setCursor(0, 2);
  lcd.print("STOP!!!  ");
  }
  if (mData == "63")
  {
  Serial.println("Disable Limits");
  }
  if (mData == "66")
  {
  Serial.println("Set East Limit");
  }
  if (mData == "67")
  {
  Serial.println("Set West Limit");
  }
  if (mData == "6B" && mNum == "00")
  {
  Serial.println("Goto Reference");
  }
  if (mData == "67")
  {
  Serial.println("Set West Limit");
  }
  if (mData == "6F")
  {
  Serial.println("(Re)Calculate Posit");
  }
}


void Switch(String sData, String sNum)
{
  if (sData == "38")
  {
  Serial.print("DiSEqC 1.0, Port ");
  Serial.println(swCommCommandLookUp(sNum));
  }
  if (sData == "39")
  {
  Serial.print("DiSEqC 1.1, Port ");
  Serial.println(swUncommCommandLookUp(sNum));
  }
}


unsigned int hexStoDec(String hexString)
{
  unsigned int decValue = 0;
  int nextInt;

  for (int i = 0; i < hexString.length(); i++) {

  nextInt = int(hexString.charAt(i));
  if (nextInt >= 48 && nextInt <= 57) nextInt = map(nextInt, 48, 57, 0, 9);
  if (nextInt >= 65 && nextInt <= 70) nextInt = map(nextInt, 65, 70, 10, 15);
  if (nextInt >= 97 && nextInt <= 102) nextInt = map(nextInt, 97, 102, 10, 15);
  nextInt = constrain(nextInt, 0, 15);

  decValue = (decValue * 16) + nextInt;
  }

  return decValue;
}


String commandLookUp(String command)
{
  if (command == "FE")
  {
  return "Nudge";
  }
  if (command == "00")
  {
  return "Continuous";
  }
}


int swUncommCommandLookUp(String command)
{
  if (command == "F0")
  {
  return 1;
  }
  if (command == "F1")
  {
  return 2;
  }
  if (command == "F2")
  {
  return 3;
  }
  if (command == "F3")
  {
  return 4;
  }
  if (command == "F4")
  {
  return 5;
  }
  if (command == "F5")
  {
  return 6;
  }
  if (command == "F6")
  {
  return 7;
  }
  if (command == "F7")
  {
  return 8;
  }
  if (command == "F8")
  {
  return 9;
  }
  if (command == "F9")
  {
  return 10;
  }
  if (command == "FA")
  {
  return 11;
  }
  if (command == "FB")
  {
  return 12;
  }
  if (command == "FC")
  {
  return 13;
  }
  if (command == "FD")
  {
  return 14;
  }
  if (command == "FE")
  {
  return 15;
  }
  if (command == "FF")
  {
  return 16;
  }
}


int swCommCommandLookUp(String command)
{
  if (command == "F0" || command == "F2")
  {
  return 1;
  }
  if (command == "F4" || command == "F6")
  {
  return 2;
  }
  if (command == "F8" || command == "FA")
  {
  return 3;
  }
  if (command == "FC" || command == "FE")
  {
  return 4;
  }
}

Minor update: August 11, 2016. Download the 47 file.
 

Attachments

  • DiSEqC_INTERR_Ver046.zip
    3.4 KB · Views: 729
  • Diseqc_IRR_47.zip
    3.4 KB · Views: 731
Last edited:
Here is the schematic:
DI4.png


Edit: 06.28.2016 Updated Schematic
 
Last edited:
Next is to put all this on a nice neat circuit board and get rid of the rats nest of wires on the test board. :)
 
OK.... I love the DiSEqC decoder built and gifted to me by Magic Static, but I now have project envy! From our messaging I knew what you were working on, but never thought that it was also providing the binary conversion.... Excellent project!!!

Could this output or be saved to a file? I also grow weary of using the conversion and EutelSat tables to convert the strings...

:hail:hail:hail Congratulations on providing an excellent contribution and thank you for sharing your wealth of knowledge with the satellite community! :hail:hail:hail
 
Could this output or be saved to a file?
Yes, it could! This is why one reason, I like sharing this stuff with the community.
It gives me ideas I didn't think of. :)

There is more to it than this, also. :)
If I am going to make this in a box that you can carry around, and since it feeds off the coax.....why stop at DiSEqC?
Right now I am adding to the circuit and the code, so that it will display the voltage and current. ;)
 
  • Like
Reactions: Magic Static
Speaking of binary conversion. If one wants to see the actual binary before it is converted to hex, for those extreme troubleshooting cases....just flip a switch. ;)
IMG_20160623_164136852.jpg
 
  • Like
Reactions: . Raine
Michael,

Persistence pays off, congratulations!

I rewrote "outputNibble" for you. It should be functionally equivalent to what you have now. I can rewrite more of the functions if it would help -- just let me know.

...I was looking into what it would take to generate DiSEqC signals. I ran across this chip: http://www.datasheetspdf.com/PDF/INN8186/938208/1 Its an LNB supply and control voltage regulator which also appears to send and receive DiSEqC. I wonder how easy it would be to use it to build a DiSEqC sender?

Here is the code module I rewrote. Its more compact and simpler, I think.

Code:
void outputNibble(volatile bool nibble[4])
  {
  int n;
  String hex[16] = {“0”, “1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, “A”, “B”, “C”, “D”, “E”, “F”};
  String bits[16] = {“0000”, “0001”, “0010”, “0011”, “0100”, “0101”, “0110”, “0111”, “1000”, “1001”, “1010”, “1011”, “1100”, “1101”, “1110”, “1111”};

  purge = 0;
  n = (nibble[0] ? 8 : 0) + (nibble[1] ? 4 : 0) + (nibble[2] ? 2 : 0) + (nibble[3] ? 1 : 0); // Compute the nibble using conditionals
  if ((n==12) && errorCheck)
  {
  Serial.println("Error Caught!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
  errorCount ++;
  lcd.setCursor(16, 2);
  lcd.print(errorCount);
  diseqc += "E";
  rawInput += "1110 ";
  errorCheck = 0;
  insertZero = 1;
  }
  else
  {
  diseqc +=hex[n];
  rawInput += bits[n];
  }
  }
 
Last edited by a moderator:
Thanks Brett!
This absolutely cleans up that function. I replaced mine with this and am currently not getting the desired result. I will have to spend more time later and try to figure out why.
It consistently is missing the 6th nibble, like it is ignoring it. Not sure if it is not liking the extra Strings declarations in the middle of the packet using interrupts, or what it is. All that stuff is happening so fast at that part of the code. That packet is just a few milliseconds long and with using interrupts, I have to be careful what is going on in the middle of that interrupt. :)
Also added this so my raw output was easier to read, like I have in mine:
Code:
{
diseqc +=hex[n];
rawInput += bits[n];
rawInput += " ";
}

I know you are doing this blindly so it is hard to troubleshoot on your end.

Anyway thanks very very much. Your version shaved off 206 bytes in the complied code. :)
I have more that needs cleaned up. :)
 
I will have to spend more time later and try to figure out why.
Got time to have a look at it.
...and that was it. I moved the declaration of the Strings. I moved them up top making their scope global and it works like a charm.
Thanks again Brett!

ps. I'm sure qwert1515 will like it too, that was a function of his from his original program, that I borrowed and added to.
 
Got time to have a look at it.
...and that was it. I moved the declaration of the Strings. I moved them up top making their scope global and it works like a charm.
Thanks again Brett!

ps. I'm sure qwert1515 will like it too, that was a function of his from his original program, that I borrowed and added to.
Glad it works now. Maybe by declaring the Strings as local to the function, it used up too much stack space? Good idea moving them to globals -- no stack space needed.

The rest of the code looks good, but let me know what else you think needs cleaning up. Maybe some of the "if" statements in the last 3 functions could be changed to "switch" statements. The other thing I might do is add parity error checking in the main loop.

... Now that I understand the code, I am tempted to build one too!
 
Maybe some of the "if" statements in the last 3 functions could be changed to "switch" statements.
I already considered this in those functions. They are not very long and I would have to convert the Strings to char constants or int's before calling the function. So I left them.
However, if you see something I am not and you want to, feel free to re-work them.
The other thing I might do is add parity error checking in the main loop.
Yeah, I am thinking the same, I want to get back to that.
Right, now I am busy adding voltage and current readout.
Also working on dumping to an SD card and Bluetooth serial out instead of RS-232, or most likely have it user select-able.
I doubt I will have both running at the same time.

I also find the circuit to be finicky at times, hard to explain. Maybe it will clear up when it is hard wired and leads are much shorter.
 
  • Like
Reactions: Titanium
Updated the schematic to include the 22kHz tone detection part of the circuit.
I am just using an off the shelf 567 PLL chip. I have several from other projects, so grabbed one and put it to use.
Did some calculations, to select the proper values for the associated parts to tune it to 22k or close to it.
The calculation comes out to 22.957kHz for the center frequency. The bandwidth is plenty though to go either side a few kilohertz.

The dotted heavy line is where 18/13 volts is always present. Anything else is 5V or less.

diseqc_sch_tone_rev_2.png
 
Updated the schematic to include the 22kHz tone detection part of the circuit.
I am just using an off the shelf 567 PLL chip. ...
I understand how the 567 PLL chip works in your circuit to light the LED from its output (pin 8) if an approximately 22kHz tone is present.

Instead of using the output of pin 8 to light the LED, couldn't it also be used as input to the Arduino for DiSEqC decoding? I think this might eliminate the need for much of the rest of the circuit. Or am I wrong?
 
I tried that and I don't think the chip can switch on and off fast enough first off. The input and output frequency on my scope is drastically different.
Second, pin 8 goes low when a tone is detected, so I would have to re do some things.
Am I missing something? Attached is a data sheet for the 567.
 

Attachments

  • lm567.pdf
    2.6 MB · Views: 494
I had the same experience with a 567. It worked fine as a 22kHz detector driving a LED. But the output wasn't clean enough to decode DiSEqC commands.

At the time, I did a little research and it looked like a XR2211 might be a better choice. But I haven't gotten around to trying it yet, and won't anytime soon.
 
  • Like
Reactions: N6BY and KE4EST
Status
Please reply by conversation.
***

Users Who Are Viewing This Thread (Total: 1, Members: 0, Guests: 1)

Who Read This Thread (Total Members: 5)