What to do with the Strobe pin in BCD Parallel Interface?

Question:
I have a strobe pin in BCD Parallel Interface that I do not know what to do about it. I read about connecting the strobe line to one of the Arduino inputs associated with an interrupt. I am not sure if I am on the right track and as a start, I would like to learn how to create a strobe in Arduino.

Context of my Project:
Enter an input frequency (from 0.3 to 18GHz) & set the Frequency Modulation mode in my PC where this data is sent to Arduino Mega ADK board and subsequently to the Frequency Synthesizer via a 50 pin connector, to control its output frequency and mode.

Setup:

Info from the Frequency Synthesizer's Data Sheet:

3

Progress thus far:
I have written a code to map the outputs to the respective pins as seen below. The user configurable parameters (Input Frequency & FM mode) are currently hardcoded & stored in arrays for easy retrieval to the BCD Parallel Interface. So for example, I have set the input frequency to be a random number at 17834533324Hz in this case.

void setup()
{
  //Pin Assignment
  pinMode(0, OUTPUT);
  pinMode(1, OUTPUT);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
  pinMode(14, OUTPUT);
  pinMode(15, OUTPUT);
  pinMode(16, OUTPUT);
  pinMode(17, OUTPUT);
  pinMode(18, OUTPUT);
  pinMode(19, OUTPUT);
  pinMode(20, OUTPUT);
  pinMode(21, OUTPUT);
  pinMode(22, OUTPUT);
  pinMode(23, OUTPUT);
  pinMode(24, OUTPUT);
  pinMode(25, OUTPUT);
  pinMode(26, OUTPUT);
  pinMode(27, OUTPUT);
  pinMode(28, OUTPUT);
  pinMode(29, OUTPUT);
  pinMode(30, OUTPUT);
  pinMode(31, OUTPUT);
  pinMode(32, OUTPUT);
  pinMode(33, OUTPUT);
  pinMode(34, OUTPUT);
  pinMode(35, OUTPUT);
  pinMode(36, OUTPUT);
  pinMode(37, OUTPUT);
  pinMode(38, OUTPUT);
  pinMode(39, OUTPUT);
  pinMode(40, OUTPUT);
  pinMode(41, OUTPUT);
  pinMode(42, OUTPUT);
  pinMode(43, OUTPUT);
  pinMode(44, OUTPUT);
  pinMode(45, OUTPUT);
  pinMode(46, OUTPUT);
  pinMode(47, OUTPUT);
  pinMode(48, OUTPUT);
  pinMode(49, OUTPUT);
  pinMode(50, OUTPUT);
  pinMode(51, OUTPUT);
  pinMode(52, OUTPUT);
  pinMode(53, OUTPUT);

  //Initialisation
  int freq[11] = {};
  int fm_mode[4] = {};
}

void loop()
{
  
  int freq[] = { 1,7,8,3,4,5,3,3,3,2,4 }; //Input frequency (from 0.3 to 18GHz)
  
  int fm_mode[] = { 0,0,0,0 }; //Frequency mode

  //Control FM Modulator
  digitalWrite(6, fm_mode[0] &1);
  digitalWrite(31, fm_mode[1] &1);
  digitalWrite(7, fm_mode[2] &1);
  digitalWrite(32, fm_mode[3] &1);

  //10GHz
  int i_10GHz = 0;
  digitalWrite(25, freq[i_10GHz]/2 &1);
  digitalWrite(30, freq[i_10GHz]/1 &1);

  //1GHz
  int i_1GHz = 1;
  digitalWrite(37, freq[i_1GHz]/8 &1);
  digitalWrite(38, freq[i_1GHz]/4 &1);
  digitalWrite(24, freq[i_1GHz]/2 &1);
  digitalWrite(13, freq[i_1GHz]/1 &1);

  //100MHz
  int i_100MHz = 2;
  digitalWrite(15, freq[i_100MHz]/8 &1);
  digitalWrite(16, freq[i_100MHz]/4 &1);
  digitalWrite(17, freq[i_100MHz]/2 &1);
  digitalWrite(45, freq[i_100MHz]/1 &1);

  //10MHz
  int i_10MHz = 3;
  digitalWrite(47, freq[i_10MHz]/8 &1);
  digitalWrite(21, freq[i_10MHz]/4 &1);
  digitalWrite(20, freq[i_10MHz]/2 &1);
  digitalWrite(46, freq[i_10MHz]/1 &1);

  //1MHz
  int i_1MHz = 4;
  digitalWrite(42, freq[i_1MHz]/8 &1);
  digitalWrite(41, freq[i_1MHz]/4 &1);
  digitalWrite(39, freq[i_1MHz]/2 &1);
  digitalWrite(40, freq[i_1MHz]/1 &1);

  //100kHz
  int i_100kHz = 5;
  digitalWrite(9, freq[i_100kHz]/8 &1);
  digitalWrite(8, freq[i_100kHz]/4 &1);
  digitalWrite(33, freq[i_100kHz]/2 &1);
  digitalWrite(34, freq[i_100kHz]/1 &1);

  //10kHz
  int i_10kHz = 6;
  digitalWrite(5, freq[i_10kHz]/8 &1);
  digitalWrite(4, freq[i_10kHz]/4 &1);
  digitalWrite(2, freq[i_10kHz]/2 &1);
  digitalWrite(3, freq[i_10kHz]/1 &1);

  //1kHz
  int i_1kHz = 7;
  digitalWrite(29, freq[i_1kHz]/8 &1);
  digitalWrite(28, freq[i_1kHz]/4 &1);
  digitalWrite(26, freq[i_1kHz]/2 &1);
  digitalWrite(27, freq[i_1kHz]/1 &1);

  //100Hz
  int i_100Hz = 8;
  digitalWrite(49, freq[i_100Hz]/8 &1);
  digitalWrite(22, freq[i_100Hz]/4 &1);
  digitalWrite(48, freq[i_100Hz]/2 &1);
  digitalWrite(23, freq[i_100Hz]/1 &1);

  //10Hz
  int i_10Hz = 9;
  digitalWrite(18, freq[i_10Hz]/8 &1);
  digitalWrite(43, freq[i_10Hz]/4 &1);
  digitalWrite(44, freq[i_10Hz]/2 &1);
  digitalWrite(19, freq[i_10Hz]/1 &1);

  //1Hz
  int i_1Hz = 10;
  digitalWrite(10, freq[i_1Hz]/8 &1);
  digitalWrite(35, freq[i_1Hz]/4 &1);
  digitalWrite(11, freq[i_1Hz]/2 &1);
  digitalWrite(36, freq[i_1Hz]/1 &1);

  delay(1000);
}

Please feel free to comment, I would appreciate any inputs. Thank you.

The strobe signal simply tells the frequency synthesiser that the data on the other signals is ready to be read. Just make the strobe pin HIGH then LOW.

Your code can be drastically improved. If interested, I can make some suggestions.

2 Likes

A strobe line typically triggers a latch in the target telling it to remember the current state. These are generally edge sensitive but not always. From your timing diagram connect it to an output of the Arduino and cycle it high to latch data into the target. Keeping it low at all other times should keep you out of trouble.

1 Like

On Mega, pins 0 & 1 are not available to use as outputs, they are used for uploading code and serial communications with the PC. You will need to choose other pins.

EDIT: checking the code again, I see that you are not actually using pins 0 & 1 as outputs. Your code simply sets every pin on the Mega as an output (and you cut, pasted and changed a line of code 53 times to achieve it). That's pretty dumb :wink:

1 Like
const byte freqPins[11][4] = {
  //4   3   2   1
  { 0,  0, 25, 30}, //10GHz
  {37, 28, 24, 12}, //1GHz
  {15, 16, 17, 35}, //100MHz
  {47, 21, 20, 46}, //10MHz
  {42, 41, 39, 40}, //1MHz
  { 8,  9, 33, 34}, //100KHz
  { 5,  4,  2,  3}, //10KHz
  {29, 28, 26, 27}, //1KHz
  {49, 22, 48, 23}, //100Hz
  {18, 43, 44, 19}, //10Hz
  {10, 35, 11, 36}  //1Hz
};

const byte fmModePins[4] = {6, 31, 7, 32};

const byte strobePin = 50;

void setup()
{
  //Pin Assignment
  for (byte d = 0; d < 11; d++) {
    for (byte b = 0; b < 4; b++) {
      if (freqPins[d][b] > 0) {
        pinMode(freqPins[d][b], OUTPUT);
      }
    }
  }
  
  for (byte b = 0; b < 4; b++) {
    pinMode(fmModePins[b], OUTPUT);
  }

  pinMode(strobePin, OUTPUT);
  
}

void loop()
{
  
  byte freq[] = { 1,7,8,3,4,5,3,3,3,2,4 }; //Input frequency (from 0.3 to 18GHz)
  
  byte fm_mode = 0b0000; //Frequency mode

  //Control FM Modulator
  for (byte b = 0; b < 4; b++) {
    digitalWrite(fmModePins[b], bitRead(fm_mode, b));
  }
  
  //Set Frequency
  for (byte d = 0; d < 11; d++) {
    for (byte b = 0; b < 4; b++) {
      if (freqPins[d][b] > 0) {
        digitalWrite(freqPins[d][b], bitRead(freq[d], b));
      }
    }
  }

  digitalWrite(strobePin, HIGH);
  digitalWrite(strobePin, LOW);

  delay(1000);
}
1 Like

Hi PaulRB,

thanks for reading through my chunk of code which was pretty much a dummy-proof way for me to get something out. I went through what you wrote and it was very clean with nice use of const and byte while I'm always stuck with using int that is just wasting my memory. :sweat_smile:

Anyway, I did some changes in the arrangement of pin numbers as my previous code was from MSB to LSB while the bitRead() reads bit from LSB to MSB. Everything else seems to be working in simulation now so next up, I will have to check with the actual equipment.

But before that, here are some questions that I would like to check with you:

  1. Does the usage of "for loops" within the void loop() cause the code to not complete on time? For example, I would like to reduce the delay() so that my strobe timing is shorter and it is able to check and "update" with the new BCD input data at a faster rate.

  2. By writing:
    digitalWrite(strobePin, HIGH);
    digitalWrite(strobePin, LOW);
    The strobe turns high before changing to low immediately. May I know if I could set different timings for when the strobe stays high and low respectively? I read that with a maximum clock frequency: 16 MHz, I am able to create a code that delays for 62.5ns?

Thanks for your time.

On time? For what?

Using a loop and arrays of pin numbers will be slower than writing out every individual digitalWrite() statement with fixed pin numbers, that's true. But the difference in speed will be so small that it will probably be hard to measure.

If performance needs to be improved, there are other ways to achieve that without needing to flatten the for-loops. Cross that bridge when, and if, you come to it.

Yes. But the high period must be >60ns, which is only a little less than the shortest pulse that 62.5ns period you mentioned. The low time will be determined by how quickly data from the PC takes to be received and processed and 50+ pins can be updated. The code I suggested can be improved further if necessary, at the cost of making it less portable to other models of Arduino.

1 Like

I see. Noted and thanks for the explanation! I will continue to work with what I have for now.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.