Jump to content

As of July 17, 2015, the LabJack forums here at forums.labjack.com are shut down. New registrations, topics, and replies are disabled. All forums are in a read-only state for archive purposes.

Please visit our current forums at labjack.com/forums to view and make new posts. To post on the current forums, use your labjack.com login account. Your old LabJack forums login credentials have been retired. There are no longer separate logins for labjack.com and LabJack forums.


Counter not counting Labjack FrequencyOutput

Counter FrequencyOutput

  • Please log in to reply
2 replies to this topic

#1 quantorum

  • Members
  • 2 posts

Posted 30 July 2013 - 06:59 AM

My configuration of Labjack UE9

FIO0: FreqOut Mode

FIO1,3: Digital I/O

FIO2: Counter


A fraction of signal comming from FIO0 goes back into FIO2 where this signal should be counted. Unfortunately the attached source code doesn't work - the counter is not counting, each time, when the value is read, the result of reading is 0. I have already checked, if there is some signal comming back to FIO2 and it is.


Procedures are called in the following order: EstablishConnection, SetFrequency, Timer1Timer, Timer1Timer,...

Is it possible, that problem lies in ClockDivisor, which is common for both - FIO0 and FIO2?


procedure TForm1.EstablishConnection;
  pch: PAnsiChar;
 pch := '';
 OpenLabJack(LJ_dtUE9, LJ_ctETHERNET, pch, 0, lngHandle);

 // FIO0 - FreqOut
 AddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chTIMER_COUNTER_PIN_OFFSET, 0, 0, 0);
 AddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chNUMBER_TIMERS_ENABLED, 1, 0, 0);
 AddRequest(lngHandle, LJ_ioPUT_TIMER_MODE, 0, LJ_tmFREQOUT, 0, 0);

 // FIO2 - Counter 
 AddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chTIMER_COUNTER_PIN_OFFSET, 2, 0, 0);
 AddRequest(lngHandle, LJ_ioPUT_COUNTER_ENABLE, 0, 1, 0, 0);
 AddRequest(lngHandle, LJ_ioPUT_COUNTER_RESET, 0, 0, 0, 0);

 // FIO1, FIO3 reserved for Digital I/O

procedure TForm1.SetFrequency;
// Setting FIO0: (ClockBase, Divisor, TimerValue calculated to match requested frequency)
 AddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chTIMER_CLOCK_BASE, ClockBase, 0, 0);
 AddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chTIMER_CLOCK_DIVISOR, Divisor, 0, 0);
 AddRequest(lngHandle, LJ_ioPUT_TIMER_VALUE, 0, TimerValue, 0, 0);


// Periodical reading data from Counter
procedure TForm1.Timer1Timer(Sender: TObject);
  value: Double;
 eGet(lngHandle, LJ_ioGET_COUNTER, 0, value, 0);
 Label1.Caption := FloatToStr(value);


#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 30 July 2013 - 09:09 AM

Timer-Counter-Pin-Offset is not supported on the UE9:







What language are you using?  Does it have some sort of automatic error handling, because I don't see any error checking & handling in your code:


    - After ever function call to our UD driver you should check for a nonzero return value.

    - After your GoOne you need to do some sort of GetResult calls to check for errors.

#3 quantorum

  • Members
  • 2 posts

Posted 01 August 2013 - 09:04 AM

Thanks for your help. Removing Timer-Counter-Pin-Offset from my code and reconfiguring connection to

  • FIO0: FreqOut Mode
  • FIO1: Counter
  • FIO2,3: Digital I/O

worked perfectly. Code I posted, is written in Delphi - after your notice, I've began to use error handling also...

Also tagged with one or more of these keywords: Counter, FrequencyOutput

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users