Page 1 of 1

MicroMod FD Analog1 - frequency in on Digital 0-5

Posted: Tue 7. Jul 2026, 14:15
by stefall
Hi,

I have a MicroMod FD Analog1 and program it with VScode which is fine so far. I have now a new application to read a MAF-Sensor with a frequency output
From the MicroModFD manual (page 32) it would be possible to read the f and DC of DIN 0-5 (Frequenz: 0 bis 20 kHz (nur Eingänge 0 bis 5)
Tastverhältnis: 0,0 bis 100,0 % (nur Eingänge 0 bis 5)).

Is this function already fully included in the c code functions? There is a fin.h with header

Code: Select all

fin.h
...
@addtogroup Frequency_In
//! <h3> API Functions for analoge Inputs </h3>
//!
//! The functions can be used to access the analog Inputs.
//!
//! <h3> Targets: </h3>
//! - PCAN-MicroMod FD
--> analog inputs? should be digital?

from the definition:

Code: Select all

#define FIN_COUNT	6

extern fin_config_t fin_config[FIN_COUNT];
would be right of DI 0 - 5.

Is this correct or is there some other function available for the fin on DI?

Thanks
Stefan

Re: MicroMod FD Analog1 - frequency in on Digital 0-5

Posted: Wed 8. Jul 2026, 14:06
by G.Bohlen
Hello,
the code should be completely included, but we have not prepared an example how to use it.
We will create an example and post it here.
If you send us your email address, we can also inform you when the example is ready.
In case you send us your email-address, please sent it to
support.peak(at)hms-networks.com
and add a note to this forum entry.

Regards,
Gunnar Bohlen
HMS-Networks

Re: MicroMod FD Analog1 - frequency in on Digital 0-5

Posted: Fri 10. Jul 2026, 16:33
by sigurd.tullander
Hello,

You can read the frequency and dutycycle of the DIn_X pins with the following code.

First of all, include "fin.h":

Code: Select all

#include "fin.h"
In your startup sequence, configure and initialize the channels for frequency inputs:

Code: Select all

uint8_t channel = 0; // DIn_0
uint8_t enable = 1;
// Frequency input algorithm requires 3 full cycles to determine frequency and duty cycle
uint32_t maximum_period_us = 1000000;
uint32_t timeout = 3 * maximum_period_us;
uint8_t polarity = 0; // low-high
FIN_ConfigureChannel(channel, enable, timeout, polarity);

// !! Must be called after FIN_ConfigureChannel() !!
FIN_Init();
Then, you should periodically call FIN_Server() in your main loop:

Code: Select all

SYSTIME_t next_finserver = SYSTIME_NOW;

while (1) {
    ...
    // server for frequency inputs
    if(SYSTIME_DIFF(next_finserver,SYSTIME_NOW)>10000)	// every 10ms
    {
        next_finserver=SYSTIME_NOW;
        FIN_Server();
    }
    ...
}
Then, you can read the frequency and duty cycle with FIN_Get():

Code: Select all

fin_result_t res;
uint8_t channel = 0; // DIn_0
FIN_Get(channel, &res);
uint16_t frequency_hz = (uint16_t) (1000000 / res.periode);
uint8_t duty_cycle_percent = (uint8_t) (100.0f * res.dutycycle);
I have also prepared a complete example project for the Analog 1 board now, demonstrating how to use both frequency outputs and frequency inputs at the same time, attached as a zip-file. We are planning to include the example in the next PEAK-DevPack release.

Regards,
Sigurd Tullander