Setting Frequency IN | LabJack
 

Setting Frequency IN

7 posts / 0 new
Last post
gordon_uw
gordon_uw's picture
Setting Frequency IN

I am having a bit of struggle trying to read the Frequency into the T7.  I have been referencing documentation at https://labjack.com/support/datasheets/t7/digital-io/extended-features/frequency, however I am still in a bit of a bind.  I have looked at the C# examples and the SingleDIO Solution shows how to set and read a value from the FIO are straight forward.  However, how do you change set the DIO#_EF_ENABLE, DIO#_EF_OPTIONS, etc.?  If you have any code examples in C# that would help set these values it would be fantastic.  Thanks!

LabJack Support
labjack support's picture
I am not a C# person myself,

I am not a C# person myself, but I would expect to find some DIO-EF examples in our C# archive.  Let us know if you don't find any and are still stuck and I will have someone else follow up.

The section you linked is the right place to look.  It shows you the registers you need to write to configure, and also the registers you might want to read.  Then just use eWriteName (or eWriteNames) to write registers and use eReadName (or eReadNames) to read registers.

So the simplest way to get going would be to make 3 calls to eWriteName to set:

DIO_EF_CLOCK0_ENABLE = 1
DIO0_EF_INDEX = 3
DIO0_EF_ENABLE = 1

Now you can read the period in seconds from a 4th register DIO0_EF_READ_A_F using a call to eReadName.

Also, I suggest you update to the latest beta firmware 1.0188:

https://labjack.com/support/firmware/t7/beta

gordon_uw
gordon_uw's picture
Thanks!  I think I am making

Thanks!  I think I am making some progress, however I am not quite yet.  The above screenshot shows the status of the registers.  I did update the firmware to 1.0188 (nice update tool!).  The DIO_EF_READ_A_F state is reading as 0.  I was hoping to get some other values.  I read in some other instructions that Frequency should be read on FIO0-FIO1, in which we have a simple two wire audio cable connected to GND and FIO0.  I also looked for the example code for C# and didn't see a DIO-EF example in the package that I dowloaded (DotNet_LJM_2015_06_04.zip).  If someone could point me in the direction of that sample code that would be great.  Thank you for your help!

gordon_uw
gordon_uw's picture
Thanks!  This got me further

Thanks!  This got me further down the path, however I still am not quite there yet.  The register DIO0_EF_READ_A_F is reporting 0.  I was hoping to see this number show some different data.  It may be how we have the audio connected; we have a basic audio cable (like one that comes out of an iPhone) connected to GND and FIO0 trying to read the audio frequency of the source (BTW..not an iPhone).  I looked for the C# example but was unable to find it in the package I downloaded (DotNet_LJM_2015_06_04.zip), if someone could point me in the right direction I would appreciate it. Attached is the output from the modified SingleDIO C# sample.

LabJack Support
labjack support's picture
Currently we do not have a

Currently we do not have a DIO-EF C# example, but your calls could look something like this for configuration (default clock settings):

//--- Code start ---

//Configure frequency in on FIO0
LJM.eWriteName(handle, "DIO_EF_CLOCK0_ENABLE", 1);
LJM.eWriteName(handle, "DIO0_EF_ENABLE", 0);
LJM.eWriteName(handle, "DIO0_EF_INDEX", 3);
LJM.eWriteName(handle, "DIO0_EF_OPTIONS", 0);
LJM.eWriteName(handle, "DIO0_EF_ENABLE", 1);

//Read value
double value = 0;
LJM.eReadName(handle, "DIO0_EF_READ_A_F", ref value);
Console.WriteLine(value.ToString("0.############"));

//--- Code end ---

Keep in mind that with DIO#_EF_READ_A_F you are reading the period in seconds (decimal value) which will be a value under 1 for a frequency above 1 Hz, so make sure you are not rounding your decimal value too much. For an integer value, read with DIO0_EF_READ_A which is the the period in ticks.

gigabyte323
gigabyte323's picture
What would be the "ref value"

What would be the "ref value" in this line of code  ?

LJM.eReadName(handle, "DIO0_EF_READ_A_F", ref value);

LabJack Support
labjack support's picture
The value is the value read

The value is the value read from DIO0_EF_READ_A_F. The meaning depends on the DIO_EF used, but as described previously in this thread and in our DIO_EF documentation, DIO0_EF_READ_A_F returns the period in seconds for the frequency input feature.