Go Down

Topic: Faster frequency measurement (Read 4797 times) previous topic - next topic

robinsuiker

#15
Aug 02, 2015, 03:47 pm Last Edit: Aug 03, 2015, 02:12 pm by robinsuiker
Hi Mark,

I'm trying to use SN74LV8154 to count two sequences of pulses. It seems you are the only one using this chip in the forum. Do you still have the schematic? I don't know how I should connect the RCLK pin.

BTW, in another post, you mentioned "What you don't do is reset the counters - that will lose counts, you take successive readings from each counter and subtract the previous reading to get the new count." In that case what if the counter reaches its limit? Will it roll back to 0 automatically?

Thanks
Hello,

I doubt this is still an issue for you, given the age of this thread. But i also had some trouble reading the SN74LV8154 counter.

Got it to work eventualy and here is the code, hope it saves someone some time if they stuble upon this post.

Code: [Select]

#include "SPI.h";

bool done = false;

// Counter pins (SN74LV8154)
const int cclr = 8;
const int clka = 9;
const int gal = 7;
const int gau = 6;
const int gbl = 5;
const int gbu = 4;
const int rclk = 3;
// all other non-Y pins pulled to GND

// Shift register pins (SN74HC165)
const int shLd = 2;
const int clk = 13;  // not used in code, pre-defined SPI pin in arduino UNO/Nano for clock signal
const int qh = 12;   // not used in code, pre-defined SPI pin in arduino UNO/Nano for data
// all other A-H pins to output of counter Y0 -> A, Y1 -> B, Y2 -> C etc...

void setup()
{
  // Counter pins
  pinMode(cclr, OUTPUT);
  pinMode(clka, OUTPUT);
  pinMode(gal, OUTPUT);
  pinMode(gau, OUTPUT);
  pinMode(gbl, OUTPUT);
  pinMode(gbu, OUTPUT);
  pinMode(rclk, OUTPUT);
  digitalWrite(gal, HIGH);
  digitalWrite(gau, HIGH);
  digitalWrite(gbl, HIGH);
  digitalWrite(gbu, HIGH);
  digitalWrite(cclr, LOW);
  digitalWrite(clka, LOW);
  digitalWrite(rclk, LOW);
  
  // Shift register pins (others are handled by SPI lib)
  pinMode(shLd, OUTPUT);
  
  Serial.begin(115200);
  SPI.begin();
}

void pulse(int pin, int value)
{
  digitalWrite(pin, value);
  digitalWrite(pin, !value);
}

void loop()
{
  if(!done)
  {
    Serial.println("start");

    // Clear counter
    pulse(cclr, LOW);

    // Some test clock cycles, 513 = 10 00000001
    for(int i = 0; i < 513; i++)
    {
      pulse(clka, HIGH);
    }
    
    // Transfer data from the counter to the register
    pulse(rclk, HIGH);

    // NOTE: counter can continue counting now, it will not effect the value in the register

    // Read low byte of register A
    digitalWrite(gal, LOW);    // Set low byte of register A to outputs
    pulse(shLd, LOW);          // Sample outputs data with shift register
    byte bl = SPI.transfer(0); // Read data from shift register
    
    // Read upper byte of register A
    digitalWrite(gal, HIGH);   // Prevent invalid state, only one ga_ may be LOW at any given time
    digitalWrite(gau, LOW);    // Set upper byte of register A to outputs
    pulse(shLd, LOW);          // Sample outputs data with shift register
    byte bu = SPI.transfer(0); // Read data from shift register
    
    Serial.println(bl);  // should be 1
    Serial.println(bu);  // should be 2
    int val = (bu << 8) + bl;
    Serial.println(val);  // should be 513
    Serial.println("end");
    done = true;
  }
}

dwightthinker

A couple things from my past.
One is to have a frequency reference of say 10MHz that you
feed into a balanced mixer with your unknown.
You use a low pass filter to pick out the lower side band and
measure that.
If you had a digitally tuned reference, you could cover bigger spans.

Another way we used to measure short time spans was to used a
constant current source to charge a capacitor. We could digitally
allow charging and not charging with a shunt load and diode
blocking. If the diode was reverse voltage to the capacitor, no
charging. if forward, it would charge.
We used this to measure time spans of single pulses down into the
sub ns range, once calibrated but only to about +- 2 digits.
Just some thoughts.
Dwight

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy