Ain | Top

Ain Analog Inputs Since R2019b Library: embeddedCreatorLib ( Dafulai Electronics) / Ain Description This block will do Analog to Digital Conversion.. Notes: PIC32 Arm platform does not support this block. You should use "emCustomCBlock" to implement your ADC Parameters Please double click this block to open parameters dialog below (when platform is PIC24/Dspic30/Dspic33): Let us explain parameters.
• | Peripheral Analog Device Number: — drop list (1 or 2). It is ADC Peripheral Number of Micro-controller.
• | Analog Inputs Qty — drop list from 1 to 16 which is total analog input quantities.
• | Analog Channel Qty — One ADC Peripheral has multiple channels which are able to sample at the same time or individually at different time. This parameter will set up channel QTY for this ADC Peripheral.
• | block output Data Format for Analog — radio selection button for analog output data format. It can be one of "unsigned Raw Data"/"16 bits signed integer Data"/"32 bits float". Please pay attention, it is not the "Data format" in IDE GUI configuration. You must choose "unsigned integer" (maybe 10 bits, or 12 bits or 16 bits according to ADC Peripheral) in IDE GUI configuration (It is MCC for Microchip PIC24/Dspic30/Dspic33)
• | Scale ( Value/bit) — integer or fraction or float type of vector. Length of vector is equal to "Analog Inputs Qty". Every item of vector denotes "physical unit value per bit" for each related analog input. For example, [2 1/3] denotes "Ain1 physical Value = Ain1 ADC raw value x 2, and Ain2 physical Value = Ain2 ADC raw value x 1 / 3 ". If your parameter "block output Data Format for Analog" is "16 bits signed integer Data", we propose you use fraction type of Scale instead of float type of Scale because all calculations will be integer. It will decrease CPU time specially for Micro-controller without hardware FPU.
• | Offset (Raw Data when value is 0) — integer type of vector. Length of vector is equal to "Analog Inputs Qty". Every item of vector is ADC raw data value when physical value is zero for each related analog input.
• | ADC start and handle method — radio selection button for ADC start (SOC signnal) and handle method. It can be one of "Manually by software"/"Other Peripheral triggered SOC and ADC interrupt Enabled"/"Other Peripheral triggered SOC and DMA Enabled" . For "PIC24/Dspic30/Dspic33" and "PIC18", you cannot select "Other Peripheral triggered SOC and DMA Enabled". When you select "Manually by software" , ADC interrupt is disabled. If you select "Other Peripheral triggered SOC and ADC interrupt Enabled", all blocks, which are inside the same sample period as this block, will be called inside ADC interrupt ISR. And "this sample time for these blocks" cannot decide "actual sample period", "Actual sample period for these blocks" is decided by "ADC interrupt". So please use IDE to configure and create One ADC interrupt when all Analog inputs A/D conversions finish.
• | Simultaneously Sampling — logical type of scalar. It only makes sense when multiple channel S&Hs or ADC Cores. It means all channels are sampled at the same time in one SOC signal (Start SOC signal). So you just like taking a picture shot to all channels Analog inputs.
• | ADC minimum sampling time in ns — integer type of scalar. It denotes minimum sampling time for any analog input in unit nano-seconds. Minimum number you can input is 10. You must match the parameter value in micro-controller ADC data sheet.
• | Sample time in sec (-1 for inherited): — Sample time for this block. It is the same meaning as general Simulink block .
Notes: 1 Please configure Analog Peripheral. All settings must be done in IDE GUI configuration (It is MCC for Microchip Micro-controller). And it must match this block settings, otherwise unexpected result will occur. 2 For DsPic33EP, you must make sure creating one ADC interrupt when all Analog inputs complete conversion if you enable ADC Interrupt. 3 When you use ADC Interrupt, all input/output data from other periods blocks to interrupt Blocks, must use RateTransition block which has -1 as output sample time (inherit). These periodical blocks which connect interrupt block must has 1 to 10 times or 15 times or 20 times or 25 times or 30 times or 40 times or 50 times or 60 times or 70 times or 90 times or 100 times or 200 times or 300 times base sample time. 4 When you use ADC Interrupt, it will call Ain block and blocks which connect Ain block with sample time=-1 (inherit) once when all analogs complete conversion. Ports Input None Outport
• | Ain — Scalar or Vector. Data type is set by parameter "block output Data Format for Analog" (uint16/int16/single) . Vector length is equal to parameter "Analog Inputs Qty"