4. cr_dsplib Module

robovero.cr_dsplib.iF_RandomNumber(i_Seed)

Returns a random number given an integer i_Seed

Args:

  • i_Seed: integer input

Return:

  • integer
robovero.cr_dsplib.iF_dspl_dotproduct32(pi_x, pi_y, i_VectorLen)

Performs pi_x dot pi_y

Args:

  • pi_x, pi_y: pointers to integer arrays
  • i_VectorLen: length of vectors

Return:

  • integer dot product of pi_x and pi_y
robovero.cr_dsplib.iF_dspl_vectsumofsquares16(psi_x, i_VectorLen)

Calculates the sum of the squares of 32 bit signed elements in pi_x

Args:

  • psi_x: pointer to signed integer array
  • i_VectorLen: length of vector

Return:

  • integer
robovero.cr_dsplib.iF_dspl_vectsumofsquares32(pi_x, i_VectorLen)

Calculates the sum of the squares of 32 bit elements in pi_x

Args:

  • pi_x: pointer to 32 bit integer array
  • i_VectorLen: length of vector

Return:

  • integer
class robovero.cr_dsplib.tS_ResonatorStateCoeff(**kwargs)

Bases: robovero.internals.cstruct

class robovero.cr_dsplib.tS_biquad32_StateCoeff(**kwargs)

Bases: robovero.internals.cstruct

Biquad filter state coefficient class

short int pi_Coeff: ‘2.14’ format fractional values

  • pi_Coeff0: a1
  • pi_Coeff1: a2
  • pi_Coeff2: b0
  • pi_Coeff3: b1
  • pi_Coeff4: b2

short int pi_State[2]: ‘2.14’ format fractional values that can be

zero initialized for the first call but are updated by the routine to

allow repeated calling of the filter with a stream of data

ptr: LPC1769 memory address where structure is stored. Use this in place of the C reference operator (&).

class robovero.cr_dsplib.tS_blockfir32_Coeff(**kwargs)

Bases: robovero.internals.cstruct

class robovero.cr_dsplib.tS_pid_Coeff(**kwargs)

Bases: robovero.internals.cstruct

short int Kp

short int Ki

short int Kd

short int IntegratedError

short int LastError

ptr: LPC1769 memory address where structure is stored. Use this in place of the C reference operator (&).

robovero.cr_dsplib.vF_dspl_biquad32(pi_Output, pi_Input, pS_StateCoeff, i_NSamples)

The biquad is a commonly used 2nd order filter section that can be cascaded to build any order of filter

Args:

  • pi_Output, pi_Input: pointers to integer arrays in ‘4.28’ format fractional values
  • pS_StateCoeff: pointer to tS_biquad32_StateCoeff
  • i_NSamples: integer number of samples
robovero.cr_dsplib.vF_dspl_blockfir32(pi_y, pi_x, pS_Coeff, i_nsamples)
robovero.cr_dsplib.vF_dspl_fftR4b16N1024(psi_Y, psi_x)

Perform Fast Fourier Transform with 1024 data points

Args:

  • psi_x: ptr to short int array. Used for input
  • psi_Y: ptr to short int array. Used for output
robovero.cr_dsplib.vF_dspl_fftR4b16N256(psi_Y, psi_x)

Perform Fast Fourier Transform with 256 data points

Args:

  • psi_x: ptr to short int array. Used for input
  • psi_Y: ptr to short int array. Used for output
robovero.cr_dsplib.vF_dspl_fftR4b16N4096(psi_Y, psi_x)

Perform Fast Fourier Transform with 4096 data points

Args:

  • psi_x: ptr to short int array. Used for input
  • psi_Y: ptr to short int array. Used for output
robovero.cr_dsplib.vF_dspl_fftR4b16N64(psi_Y, psi_x)

Perform Fast Fourier Transform with 64 data points

Args:

  • psi_x: ptr to short int array. Used for input
  • psi_Y: ptr to short int array. Used for output
robovero.cr_dsplib.vF_dspl_pid(si_Error, pS_Coeff)

PID Controller

Args:

  • si_Error(short int)
  • pS_Coeff: pointer to tS_pid_Coeff

Return:

  • Pid(int)
robovero.cr_dsplib.vF_dspl_resonator(psi_Output, pS_ResonatorStateCoeff, i_NSamples)
robovero.cr_dsplib.vF_dspl_vectadd16(psi_z, psi_x, psi_y, i_VectorLen)

Adds two unsigned 16 bit integer vectors

Args:

  • psi_z: psi_x + psi_y
  • psi_x, psi_y, psi_z: pointers to signed integer arrays
  • i_VectorLen: length of vector

NOTE: this function is supposed to be signed, but problems with Python cause it to be unsigned

robovero.cr_dsplib.vF_dspl_vectadd32(pi_z, pi_x, pi_y, i_VectorLen)

Adds two unsigned 32 bit integer vectors and returns in pi_z

Args:

  • pi_z: pi_x + pi_y
  • pi_x, pi_y, pi_z: pointers to 32bit integer arrays
  • i_VectorLen: length of vector
robovero.cr_dsplib.vF_dspl_vectaddconst16(psi_y, psi_x, si_c, i_VectorLen)

Adds a constant integer i_c to each element in vector pi_x and outputs in pi_y

Args:

  • psi_x, psi_y: pointer to signed integer arrays
  • si_c: signed integer
  • i_VectorLen: length of vector
robovero.cr_dsplib.vF_dspl_vectaddconst32(pi_y, pi_x, i_c, i_VectorLen)

Adds a constant integer i_c to each element in vector pi_x and outputs in pi_y

Args:

  • pi_x, pi_y: pointer to 32bit integer arrays
  • i_c: integer
  • i_VectorLen: length of vector
robovero.cr_dsplib.vF_dspl_vectmulconst16(psi_y, psi_x, si_c, i_VectorLen)

Multiplies each element in psi_x by si_c and returns in psi_y

Args:

  • psi_x, psi_y: pointers to signed integer arrays
  • si_c: integer
  • i_VectorLen: length of vector

TODO: deref on psi_y doesn’t work

robovero.cr_dsplib.vF_dspl_vectmulconst32(pi_y, pi_x, i_c, i_VectorLen)

Multiplies each element in pi_x by i_c and returns in pi_y

Args:

  • pi_x, pi_y: pointers to 32 bit integer arrays
  • i_c: integer
  • i_VectorLen: length of vector
robovero.cr_dsplib.vF_dspl_vectmulelement16(psi_z, psi_x, psi_y, i_VectorLen)

Element by element multiplication of unsigned vectors

TODO: Doesn’t work?

Args:

  • pi_x, pi_y: pointers to integer arrays
  • i_VectorLen: length of vector
  • pi_z: result of element by element multiplication
robovero.cr_dsplib.vF_dspl_vectmulelement32(pi_z, pi_x, pi_y, i_VectorLen)

Element by element multiplication of unsigned vectors

TODO: Doesn’t work?

Args:

  • pi_x, pi_y: pointers to integer arrays
  • i_VectorLen: length of vector
  • pi_z: result of element by element multiplication
robovero.cr_dsplib.vF_dspl_vectsub16(psi_z, psi_x, psi_y, i_VectorLen)

Subtracts two unsigned 32 bit integer vectors and returns in psi_z

Args:

  • psi_z: psi_x - psi_y
  • psi_x, psi_y, psi_z: pointers to signed integer arrays
  • i_VectorLen: length of vector

TODO: Find out why using deref on psi_z doesn’t work

robovero.cr_dsplib.vF_dspl_vectsub32(pi_z, pi_x, pi_y, i_VectorLen)

Subtracts two unsigned 32 bit integer vectors and returns in pi_z

Args:

  • pi_z: pi_x - pi_y
  • pi_x, pi_y, pi_z: pointers to 32bit integer arrays
  • i_VectorLen: length of vector