MAX11131 library


This C library describes the control of the 16-channel AD converter MAX11131 via SPI with a microcontroller of the MSP430 series. The MSP43F5359 is used as a microcontroller and the IAR Embedded Workbench is used as a development environment.

Downloads

Download ad-wandler-max111xx-lib

Short description MAX11131

The MAX11131 ad converter has write and read commands and can be addressed via SPI. The chip select line signals the start and end of a frame. The MAX11131 offers the possibility to use either 16 channels as single ended or 8 channels differential.

All functions of the library “max11131.c” are explained below:

void MAX11131_SPI_init(void)
Initializes the SPI interface for channel UCA1 of the MSP430F5359
Parameter
Return

 

unsigned char MAX11131_SPI_transmit(unsigned char data)
Send and receive via SPI via channel UCA1 of the MSP430F5359
Parameter data Information to be sent via SPI
Return Information received via SPI

 

unsigned int MAX11131_transmit(unsigned int command)
Sends and receives to and from the MAX11131 via the SPI interface. For the commands, see the Defines and datasheet which start on page 15. Note that a 2 byte command is sent. Depending on the command, an answer can be received. The answer must however be the last command which has been dispatched and will not be the actual shipping
Parameter command Command to be sent to the MAX11131
Return Answer received from the MAX11131

 

MAX11131_bipolar_chanel(char k)
Function should only be used internally. Switch instruction to select the bipolar channel
Parameter k Channel to be selected
Return Returns the corresponding register

 

unsigned int MAX11131_range_chanel(char k)
Function should only be used internally. Switch instruction to select the range channel
Parameter k Channel to be selected
Return Returns the corresponding register

 

 

 

 

unsigned int MAX11131_unipolar_chanel(char k)
Function should only be used internally. Switch instruction to select the unipolar channel
Parameter k Channel to be selected
Return Returns the corresponding register

 

unsigned int MAX11131_csel_chanel(char k)
Function should only be used internally. Switch instruction to select the AD channels
Parameter k Channel to be selected
Return Returns the corresponding register

 

void MAX11131_Echo_aktiv (char status)
Activates the echo function of the MAX11131 for the config registers. Here: Activate echo -> Send new config at time t -> Send again new config at time t + 1 and get as echo of MISO the config from time t if everything has expired correctly.
Parameter status If TRUE, echo is active, but not for FALSE
Return

 

void MAX11131_test (void)
Test the MAX 11131 by sending an echo and then a config, as a result should come 0x8380
Parameter
Return

 

void MAX11131_ADC_conf(void)
The function sets the AD converter. To do this, the user must manipulate the #defines in the header file (see also below). The procedure is taken from the flow chart on page 32; MAX11131 Specifications; Year 2015.

Variable GLOBAL in the header and edit if necessary (TRUE or FALSE)

RefSel = TRUE: Single-Ebded reference; FALSE: Different reference

SoP_FD = TRUE: Pseudo or Single-Ended; FALSE: Full-Differential

SinEnd = TRUE: Single-ended; FALSE: Pseudo-Differential

UniBip = TRUE: Unipolar; FALSE: Bipolar

Ran = TRUE: reference +/- Vref; Reference +/- Vref / 2; Only for bipolar of interest

Num = number of channels, select between 0 to 7

Parameter
Return

 

void MAX11131_init(void)
Initialize the MAX11131 by first configuring it and then reading dummy values
Parameter
Return

 

unsigned int MAX11131_get_ADC_eins(char ch)
AD value from single channel
Parameter ch Channel to be selected
Return Returns the appropriate AD value

 

unsigned int* MAX11131_get_ADC(char start, char end)
Refer to “Figure 12 / Data Sheet Page 33”. Here, there are too many possibilities to handle the function with TRUE / FALSE, like before. I chose the one that was suitable to my project. These are: External Clock, Manual, Channel Selection, No Reset, Power-Mode Normal. The channel / channels have to be selected by “start” and “end”.

!!! If I measure several channels, then note: Now I measure for channel N and get the value of channel N-1 first !!

Parameter start

end

From initial channel to

End channel

Return Returns AD value array

 

unsigned int MAX11131_mean(char ch, int cnt, int pow)
Calculate mean value for the respective channel <ch> with shift-division (time-saving than normal division). Pay attention to the <cnt = multiple of 2> and <pow>.
Parameter ch

cnt

pow

Channel to be averaged

Number of values (must be multiples of 2 -> 2 ^ n)

The power n

Return Returns the mean value

 

Leave a comment

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.