ADC Module

This module provides a Service that will read and process the data coming from the ADC on your SOMANET device. Up to 2 clients could retrieve data from the Service through interfaces.

The ADC Service should always run over an IF2 Tile so it can access the ports of your SOMANET Drive module.

../../../../../../_images/adc_concept.jpg

How to use

Important

We assume that you are using SOMANET Base and your app includes the required board support files for your SOMANET device.

  1. First, add all the SOMANET Motor Control Library modules to your app Makefile.

    USED_MODULES = configuration_parameters lib_bldc_torque_control module_adc module_board-support module_utils module_watchdog
    

    Note

    Not all modules will be required, but when using a library it is recommended to include always all the contained modules. This will help solving internal dependency issues.

  2. Include the ADC Service header adc_service.h, adc_7265.h and adc_ad7949.h in your app.

    Note

    In case of using adc_service service of module_adc only add adc_service.h header to your app.

  3. Define the required adc ports in the board-support-package of your Drive module. By default, these ports are defined as SOMANET_DRIVE_ADC_PORTS in board-support-package of your SOMANET device.

  4. Inside your main function, instantiate the interfaces array for the Service-Clients communication (in this case, adc server and adc client).

  5. At your IF2 tile, instantiate the Service.

  6. At whichever other core, now you can perform calls to the ADC Service through the interfaces connected to it.

#include <CoreC2X.bsp>                          //Board Support file for SOMANET Core C2X device
#include <Drive1000-rev-c4.bsp>     //Board Support file for SOMANET Drive module
                                    //(select your board support files according to your device)

#include <adc_service.h> // 2

ADCPorts adc_ports = SOMANET_DRIVE_ADC_PORTS; // 3

int main(void)
{
    interface ADCInterface i_adc[2] // 4

    par
    {
        on tile[APP_TILE]:
        {
                int a, b;
                {a, b} = i_adc.get_channel(CHANNEL_ID);// 6
                                                               // CHANNEL_IDs are defined in the adc_service.h file, and can be used depending on adc type of your module.
        }

        on tile[IF2_TILE]: // 5
        {
            if(!isnull(adc_ports.ad7949_ports.clk))         adc_ad7949_service_demo(adc_ports.ad7949_ports, i_adc);
            else if(!isnull(adc_ports.ad7265_ports.xclk))   adc_ad7265_service_demo(adc_ports.ad7265_ports, i_adc);
        }
    }

    return 0;
}

API

Types

AD7949Ports

Structure type to define the ports to manage the AD7949 ADC chip.

Structure Members:

buffered out port:32 sclk_conv_mosib_mosia

[[Nullable]] 4-bit Port for ADC management

in buffered port:32 data_a

[[Nullable]] 32-bit buffered ADC data port a

in buffered port:32 data_b

[[Nullable]] 32-bit buffered ADC data port b

clock clk

[[Nullable]] Internal XMOS clock.

AD7265Ports

Structure type to define the ports to manage the AD7265 ADC chip.

Structure Members:

in buffered port:32 p32_data

[[Nullable]] Array of 32-bit buffered ADC data ports.

clock xclk

[[Nullable]] Internal XMOS clock.

out port p1_serial_clk

[[Nullable]] Port connecting to external ADC serial clock.

port p1_ready

[[Nullable]] Port used to as ready signal for p32_adc_data ports and ADC chip.

out port p4_mux

[[Nullable]] 4-bit Port used to control multiplexor on ADC chip.

Ad7265ChannelIndex ad7265_channel_index
ADCPorts

Structure type for ports and configuration used by the ADC Service .

Structure Members:

AD7949Ports ad7949_ports

Structure containing ports information about AD7949 chip (if applicable)

AD7265Ports ad7265_ports

Structure containing ports information about AD7265 chip (if applicable)

CurrentSensorsConfig current_sensor_config

Configuration about the current measurement.

Service

void adc_service(ADCPorts &adc_ports, interface ADCInterface server i_adc[2], interface WatchdogInterface client ?i_watchdog, int tile_usec, int operational_mode)

Service providing readings from the ADC chip in your SOMANET device.

Measurements can be sampled on requests through i_adc interfaces.

Parameters:
  • adc_ports – Ports structure defining where to access the ADC chip signals.
  • i_adc[2] – Array of communication interfaces to handle up to 2 different clients.
  • i_watchdog – Interface to communicate with watchdog service
  • tile_usec – Reference clock frequency of IF2 tile (in MHz)
  • operational_mode – Integer type to select between SINGLE_ENDED/FULLY_DIFFERENTIAL modes
Returns:

void

Interface

interface ADCInterface

Interface type to communicate with the ADC Service.

{int, int} g get_channel(unsigned short)

sends the required channel (to be sampled by ADC), and recieves its corresponding analogue input values

Parameters:
  • adc – channel (to be sampled by ADC)
Returns:

two integer values corresponding to the voltage of selected channel

int status(void)

send the status of adc service to the client (ACTIVE/INACTIVE)

Returns:integer value corresponding to ACTIVE/INACTIVE enumeration
{int, int, int, int, int, int, int, int, int, int} g get_all_measurements()

gets all adc measured parameters at once.

In its most complete form, these parameters will be:

Returns:seven integer values including:
void set_protection_limits(int limit_oc, int limit_ov, int limit_uv, int limit_ot, int warning_ot)

Sets the protection/warning limits including:

Parameters:
  • limit_oc – -> high limit for adc output value in adc channels which are connected to current sensors
  • limit_ov – -> high limit for adc output value in adc channels which are connected to dc link
  • limit_uv – -> low limit for adc output value in adc channels which are connected to dc link
  • limit_ot – -> high limit for adc output value in adc channels which are connected to temperature sensor(protection setpoint)
  • warning_ot – -> high limit for adc output value in adc channels which are connected to temperature sensor(warning setpoint)
Returns:

void

void reset_faults()

Resets the fault state in adc service.

Returns:void
{int, int} g get_channel(unsigned short)

sends the required channel (to be sampled by ADC), and recieves its corresponding analogue input values

Parameters:
  • adc – channel (to be sampled by ADC)
Returns:

two integer values corresponding to the voltage of selected channel

int status(void)

send the status of adc service to the client (ACTIVE/INACTIVE)

Returns:integer value corresponding to ACTIVE/INACTIVE enumeration
{int, int, int, int, int, int, int, int, int, int} g get_all_measurements()

gets all adc measured parameters at once.

In its most complete form, these parameters will be:

Returns:seven integer values including:
void set_protection_limits(int limit_oc, int limit_ov, int limit_uv, int limit_ot, int warning_ot)

Sets the protection/warning limits including:

Parameters:
  • limit_oc – -> high limit for adc output value in adc channels which are connected to current sensors
  • limit_ov – -> high limit for adc output value in adc channels which are connected to dc link
  • limit_uv – -> low limit for adc output value in adc channels which are connected to dc link
  • limit_ot – -> high limit for adc output value in adc channels which are connected to temperature sensor(protection setpoint)
  • warning_ot – -> high limit for adc output value in adc channels which are connected to temperature sensor(warning setpoint)
Returns:

void

void reset_faults()

Resets the fault state in adc service.

Returns:void