Blockset described on this wiki is deprecated since 2012.

For Model Based Design (MBD), use the free MPLAB Device Blocks for Simulink, tool from Microchip.
Updated Rapid Control Prototyping (RCP) custom projects are published at: https://lubin.kerhuel.eu.

DsPIC Block/Input Capture

From http://www.kerhuel.eu/wiki - Simulink device driver Blockset for dsPIC / PIC24 / PIC32 Microcontrollers --[[User:LubinKerhuel|LubinKerhuel]] 12:40, 3 September 2009 (UTC)
Jump to navigation Jump to search
Block Input Capture

The Input Capture (IC) block allow to get values from any kind of PWM data. Either Up, Down or both value can be captured. For each channel captured, a timer is automatically choosen and set to get the maximum resolution. Timer configuration is based on the max pulse duration you are to measure.


Dialog Box Parameters

Input Capture Dialog

Interrupt Priority

Interrupt is declenche on rising and/or falling edge. The measure is then calculated and saved. The interrupt priority will not affect the accuracy of the measure because timers are read in hardware. Interrupt priority can affect measure on fast consecutive event.

Input Channels

Specify Input Capture channel(s) (IC) starting from 1. Specify multiple channels as a vector. This will also set the number of output for the block

Channels Input Type

Select for each channel which king of data you want to extract.

  • 1 : is to get the High pulse duration
  • 2 : is to get the Low pulse duration
  • 3 : is to get both High and low pulse duration
  • 4 : is to get the periode using rising edge
  • 8 : is to get the periode using falling edge
  • 5 : is to get both High pulse duration and periode using rising edge
  • 10 : is to get both Down pulse duration and periode using falling edge

The value of the vector reffere to corresponding channel defined in "Input Channels".

Max/Channels

Define max time in secondes of the largest event tu be measure by the respective channel. Safety margin in %

Add a margin to the max time defined previously. This margin time allow to avoid provided the event is larger than the max attempted value.

ValMax / Channel Variable Name

This Variable will be evaluated in the workspace and allow you to scale the data.The ValMax is the max value that will be given by an event of the duration defined in Max/Channels. This value does not take into account the Safety margin.

Result Byte Resolution

This is the log2 of the ValMax Variables for each channels.

Timer

This is the timer that is used with the corresponding channel. It is set automatically. The timer prescaler are defined in the Master block.

Changed Detected on

Add a boolean outputs to the block. This output take the value 1 if a changed has occured since last block execution. The output can be set to 1 either at rising edge, falling edge or both edges.

Sample Time

-1 mean inherited

Status

Information if error encountred.


<comments \>