Jump to content
  • 0

MCC172 single channel scan_read C function


dartek

Question

Hello,

I'm evaluating using 2 MCC172 board to perform datalogging from 2 triaxial iepe accelerometers.

Given that every MCC172 has 2 channels and I need to sample x,y and z contribute from each accelerometer, I was looking into getting 3 boards. I'm gonna use C language.

I know that probably it's a dumb question, but I'm finding it hard to understand how C function 

mcc172_a_in_scan_read

does really work.

From my understanding when I want to start a scan I select 

int mcc172_a_in_scan_start(uint8_t address, uint8_t channel_mask, uint32_t samples_per_channel, uint32_t options)

function and I choose which channel i want to scan with the parameter:

uint8_t channel_mask

Now, it is my understanding that this function will create a buffer that I can subsequently access with the "read" function to get the values.

Only thing is that the "read" function does not have a parameter where I can define which channel of one board I want to read:

nt mcc172_a_in_scan_read(uint8_t address, uint16_t * status, int32_t samples_per_channel, double timeout, double * buffer, uint32_t buffer_size_samples, uint32_t * samples_read_per_channel)

I can only select the MCC172 address. Am I missing something or does it mean that in some way the scans from both channels are written into the same buffer? And if so, in which way are they written so that I can retrieve samples from a single channel?

Thanks in advance

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

If there are two channels in the mcc172_a_in_start_scan channel mask, the buffer will contain both channels.  Therefore, the read buffer should be a multiple of the number of channels. The read buffer is a one-dimensional array with interleaved channels.  If you have not already done so, take a look at our continuous_scan and multil_hat_sychronuousl_scan examples.

Link to comment
Share on other sites

  • 0
4 hours ago, JRys said:

If there are two channels in the mcc172_a_in_start_scan channel mask, the buffer will contain both channels.  Therefore, the read buffer should be a multiple of the number of channels. The read buffer is a one-dimensional array with interleaved channels.  If you have not already done so, take a look at our continuous_scan and multil_hat_sychronuousl_scan examples.

I'm looking at both examples, and I can see that both channel on every mcc172 are being used, but I'm not sure if they give info about how ch0 sample and ch1 samples are interleaved into the buffer.

Let's say I want to read 2 channels at 51.2Khz, I'm expecting after 1 second to have 102.400 samples into the read buffer, is that right? How do I know which of the 102.400 samples are from ch0 and which are from channel ch1? Sample 0 to 51200 are from ch0 and from 51201 to 102400 are from ch1? Are they interleaved in a way that sample 1 is from ch0, sample 2 from ch1, sample 3 from ch0, sample 4 from ch1 and so on?

Thanks for your reply

Link to comment
Share on other sites

  • 0

The data returned by mcc172_a_in_scan_read always begins with the first channel in the channel mask. The continuous_scan example sets the driver buffer to hold data for 2 seconds (2 * sample rate * number of channels). To read one second of data at 51.2k Hz, set the read_request_size parameter to 51,200. The function's return variable will let you know if it was successful. If successful, read_buffer will have 102,400 samples, where read_buffer[0] is your first channel. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...