LDC1000 sensor values

General discussion on Libstock website & codes posted on this website.
Author
Message
frank.malik
Posts: 96
Joined: 09 Apr 2021 20:37

Re: LDC1000 sensor values

#16 Post by frank.malik » 19 Nov 2022 18:05

Hello ndavis,

surely this is your right. I would be really interested in the outcome of this story.
Kind regards
Frank

Fusion for STM32 v8, STM32F407ZG@168MHz, 4" TFT capacitive
mikromedia 3, PIC32MZ2048EFH100@200MHz, 3" TFT capacitive
NECTO Studio 3.0.0, mikroC AI for ARM/PIC32, mikroSDK v.2.7.2

ndavis
Posts: 19
Joined: 01 Nov 2022 19:29

Re: LDC1000 sensor values

#17 Post by ndavis » 28 Nov 2022 16:30

Hi

I’ve received a new board and obtained basically the same results. It doesn’t detect any conductive material near the sensor coil. It only outputs 0 or -1 to the UART. I’m not sure what else to try.

Edit:
I tried removing the UART all together and run the code in debugger to the point where it prints the values so I can see what it would print in the expressions window. It is output the 65535 proximity value like before, so that isn’t the cause of the issue.

frank.malik
Posts: 96
Joined: 09 Apr 2021 20:37

Re: LDC1000 sensor values

#18 Post by frank.malik » 29 Nov 2022 09:44

Hi ndavis,

that's a pity.

Would you mind sharing your latest code with us?
I'm wondering if there is something in the initialization of the LDC1000, which will give only the two results,
as the hardware seems to be not the issue anymore.
Kind regards
Frank

Fusion for STM32 v8, STM32F407ZG@168MHz, 4" TFT capacitive
mikromedia 3, PIC32MZ2048EFH100@200MHz, 3" TFT capacitive
NECTO Studio 3.0.0, mikroC AI for ARM/PIC32, mikroSDK v.2.7.2

frank.malik
Posts: 96
Joined: 09 Apr 2021 20:37

Re: LDC1000 sensor values

#19 Post by frank.malik » 29 Nov 2022 10:41

Hi ndavis,

looking at some other code, probably the power mode setting has an influence.
It was described that power mode register should be set to "0" ( stand-by ) for writing the configuration,
setting this register back to "1" afterwards.

However, I have seen one example where also the reading from the registers is done with this combination:
  • set power mode register to "0"
  • read registers
  • set power mode register to "1"
This leads me to another question. Did you ever tried to read any register e.g., to check that the configuration
has been written correctly? There seems to be also an ID register. Try to read this, too.
Kind regards
Frank

Fusion for STM32 v8, STM32F407ZG@168MHz, 4" TFT capacitive
mikromedia 3, PIC32MZ2048EFH100@200MHz, 3" TFT capacitive
NECTO Studio 3.0.0, mikroC AI for ARM/PIC32, mikroSDK v.2.7.2

frank.malik
Posts: 96
Joined: 09 Apr 2021 20:37

Re: LDC1000 sensor values

#20 Post by frank.malik » 29 Nov 2022 11:01

Hi,

making a second thought and reading the datasheet, I think this sentence is not correct
looking at some other code, probably the power mode setting has an influence.
Can you read any other register correctly?
Kind regards
Frank

Fusion for STM32 v8, STM32F407ZG@168MHz, 4" TFT capacitive
mikromedia 3, PIC32MZ2048EFH100@200MHz, 3" TFT capacitive
NECTO Studio 3.0.0, mikroC AI for ARM/PIC32, mikroSDK v.2.7.2

ndavis
Posts: 19
Joined: 01 Nov 2022 19:29

Re: LDC1000 sensor values

#21 Post by ndavis » 29 Nov 2022 16:54

The only change to the code I a reverted back to the original code downloaded from the package library in Necto Studio.

Is this what you're referring too? The initialization cfg? When I first run the debugging it goes into the init loop to set these variables. Then the program goes into the application_task and the cfg variables cannot be read.

During the init loop, I was able to read expressions for: cfg, log_cfg, ldc1000 see attachements

MIKROBUS_1 shows "can not evaluate expression"
Attachments
ldc1000 init 1.JPG
ldc1000 init 1.JPG (83.61 KiB) Viewed 969 times
ldc1000 init.JPG
ldc1000 init.JPG (79.58 KiB) Viewed 969 times
ldc1000 init 2.JPG
ldc1000 init 2.JPG (87.06 KiB) Viewed 969 times

frank.malik
Posts: 96
Joined: 09 Apr 2021 20:37

Re: LDC1000 sensor values

#22 Post by frank.malik » 29 Nov 2022 18:19

Hi,

thanks for the information. I understand the issue with the "can not evaluate expression".
Typically it happens, if the variable is not, not yet or not anymore defined. The scope of the variable
is very important.
I think you can't display a type definition like ldc1000_cfg_t, but you can display the variable that
uses this type e.g., cfg.

Have you ever tried to read any register on your own? The library for the LDC1000 offers the ldc1000_readData function.
I suggest to read the ID register or similar. Any register that has definitely something different to 0x00 or 0xFF.
Still I can imagine a hardware issue somewhere else in the SDO path
Kind regards
Frank

Fusion for STM32 v8, STM32F407ZG@168MHz, 4" TFT capacitive
mikromedia 3, PIC32MZ2048EFH100@200MHz, 3" TFT capacitive
NECTO Studio 3.0.0, mikroC AI for ARM/PIC32, mikroSDK v.2.7.2

ndavis
Posts: 19
Joined: 01 Nov 2022 19:29

Re: LDC1000 sensor values

#23 Post by ndavis » 29 Nov 2022 19:31

Thank you for your help, this is all new to me. I've done some work in basic electronics but nothing to this scale. Looking through the library, I do not see this function ldc1000_readData that I got from the Necto Studios Package search.

Searching on Libstock, I see two sets of code:
mikroSDK Library: 2.0.0.0 - https://libstock.mikroe.com/projects/vi ... 1000-click
mikroSDK Library: 1.0.0.0 - https://libstock.mikroe.com/projects/vi ... 1000-click

The one I have is the 2.0 but I do see this function in the 1.0 library. I am unable to open up this 1.0 Library. The code I am getting from the Necto Studio is the 2.0 version. I don't see any differences between the two

Is there another way to read the registry? I think it might be ldc1000_read_byte? If so, how would you code this to read a registry of interest?

ldc1000.h library code ~~~~~~~~

/*
* MikroSDK - MikroE Software Development Kit
* Copyright© 2020 MikroElektronika d.o.o.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
* OR OTHER DEALINGS IN THE SOFTWARE.
*/

/*!
* \file
*
* \brief This file contains API for LDC 1000 Click driver.
*
* \addtogroup ldc1000 LDC 1000 Click Driver
* @{
*/
// ----------------------------------------------------------------------------

#ifndef LDC1000_H
#define LDC1000_H

#include "drv_digital_in.h"
#include "drv_spi_master.h"
#include "math.h"

// -------------------------------------------------------------- PUBLIC MACROS
/**
* \defgroup macros Macros
* \{
*/

/**
* \defgroup map_mikrobus MikroBUS
* \{
*/

#define LDC1000_MAP_MIKROBUS( cfg, mikrobus ) \
cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
/** \} */

/**
* \defgroup error_code Error Code
* \{
*/
#define LDC1000_RETVAL uint8_t

#define LDC1000_OK 0x00
#define LDC1000_INIT_ERROR 0xFF
/** \} */

/**
* \defgroup register_map Register Map
* \{
*/
#define LDC1000_CMD_ID 0x00
#define LDC1000_CMD_RPMAX 0x01
#define LDC1000_CMD_RPMIN 0x02
#define LDC1000_CMD_SENSORFREQ 0x03
#define LDC1000_CMD_LDCCONFIG 0x04
#define LDC1000_CMD_CLKCONFIG 0x05
#define LDC1000_CMD_THRESHILSB 0x06
#define LDC1000_CMD_THRESHIMSB 0x07
#define LDC1000_CMD_THRESLOLSB 0x08
#define LDC1000_CMD_THRESLOMSB 0x09
#define LDC1000_CMD_INTCONFIG 0x0A
#define LDC1000_CMD_PWRCONFIG 0x0B
#define LDC1000_CMD_STATUS 0x20
#define LDC1000_CMD_PROXLSB 0x21
#define LDC1000_CMD_PROXMSB 0x22
#define LDC1000_CMD_FREQCTRLSB 0x23
#define LDC1000_CMD_FREQCTRMID 0x24
#define LDC1000_CMD_FREQCTRMSB 0x25
/** \} */

/**
* \defgroup constants Constants
* \{
*/
#define LDC1000_RPMAX_38_785K 0x11
#define LDC1000_RPMIN_2_39K 0x3B
#define LDC1000_SENSORFREQ_N217_F20 0xD9
#define LDC1000_LDCCONFIG_A2V_T6144 0x0F
#define LDC1000_CLKCONFIG_EC_ET_ENABLE 0x02
#define LDC1000_PWRCONFIG_ACTIVE_MODE 0x01
#define LDC1000_CMD_SPI_READ 0x80
#define LDC1000_SENSITIVITY 100
/** \} */

/** \} */ // End group macro
// --------------------------------------------------------------- PUBLIC TYPES
/**
* \defgroup type Types
* \{
*/

/**
* @brief Click ctx object definition.
*/
typedef struct
{
digital_out_t cs;

// Input pins

digital_in_t int_pin;

// Modules

spi_master_t spi;
pin_name_t chip_select;

} ldc1000_t;

/**
* @brief Click configuration structure definition.
*/
typedef struct
{
// Communication gpio pins

pin_name_t miso;
pin_name_t mosi;
pin_name_t sck;
pin_name_t cs;

// Additional gpio pins

pin_name_t int_pin;

// static variable

uint32_t spi_speed;
uint8_t spi_mode;
spi_master_chip_select_polarity_t cs_polarity;

} ldc1000_cfg_t;

/** \} */ // End types group
// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS

/**
* \defgroup public_function Public function
* \{
*/
#ifdef __cplusplus
extern "C"{
#endif

/**
* @brief Config Object Initialization function.
*
* @param cfg Click configuration structure.
*
* @description This function initializes click configuration structure to init state.
* @note All used pins will be set to unconnected state.
*/
void ldc1000_cfg_setup ( ldc1000_cfg_t *cfg );

/**
* @brief Initialization function.
* @param ldc1000 Click object.
* @param cfg Click configuration structure.
*
* @description This function initializes all necessary pins and peripherals used for this click.
*/
LDC1000_RETVAL ldc1000_init ( ldc1000_t *ctx, ldc1000_cfg_t *cfg );

/**
* @brief Click Default Configuration function.
*
* @param ctx Click object.
*
* @description This function executes default configuration for LDC 1000 click.
*/
void ldc1000_default_cfg ( ldc1000_t *ctx );

/**
* @brief Byte write function.
*
* @param ctx Click object.
* @param address Register address.
* @param input_data Data byte.
*
* @description This function writes 1 byte of data to the specified register address.
*/
void ldc1000_write_byte ( ldc1000_t *ctx, uint8_t address, uint8_t input_data );

/**
* @brief Byte read function.
*
* @param ctx Click object.
* @param address Register address.
*
* @description This function reads 1 byte of data from the specified register address.
*/
uint8_t ldc1000_read_byte ( ldc1000_t *ctx, uint8_t address );

/**
* @brief Get proximity data function.
*
* @param ctx Click object.
*
* @description This function reads the proximity data.
*/
uint16_t ldc1000_get_proximity_data ( ldc1000_t *ctx );

/**
* @brief Get inductance data function.
*
* @param ctx Click object.
*
* @description This function reads the inductance data.
*/
float ldc1000_get_inductance_data ( ldc1000_t *ctx );

/**
* @brief Get interrupt pin input function.
*
* @param ctx Click object.
*
* @description This function reads the input voltage from the INT pin.
*/
uint8_t ldc1000_get_int_input ( ldc1000_t *ctx );

#ifdef __cplusplus
}
#endif
#endif // _LDC1000_H_

/** \} */ // End public_function group
/// \} // End click Driver group
/*! @} */
// ------------------------------------------------------------------------- END
~~~~~~~~~~~~~~~~~~~~~~~~

frank.malik
Posts: 96
Joined: 09 Apr 2021 20:37

Re: LDC1000 sensor values

#24 Post by frank.malik » 29 Nov 2022 20:20

Hi,

I think the function is now ldc1000_read_byte, sorry for the cunfusion.

Unfortunately, I don't have this particular board. Therefore I would simply estimated that this code,
placed in the application_task section, should work.

Code: Select all


    volatile uint8_t device_id ;

    device_id = ldc1000_read_byte( &ldc1000, LDC1000_CMD_ID);


Please let me know what you get.
Kind regards
Frank

Fusion for STM32 v8, STM32F407ZG@168MHz, 4" TFT capacitive
mikromedia 3, PIC32MZ2048EFH100@200MHz, 3" TFT capacitive
NECTO Studio 3.0.0, mikroC AI for ARM/PIC32, mikroSDK v.2.7.2

ndavis
Posts: 19
Joined: 01 Nov 2022 19:29

Re: LDC1000 sensor values

#25 Post by ndavis » 29 Nov 2022 21:12

It is outputting 255 to the debugging window, see attached. Changing this to hex, its 0XFF with the code you wrote. I tried changing the variable in the function to LDC1000_CMD_STATUS and it outputted the same thing.

Then when I go to the next line, it becomes inaccessible.
Attachments
ldc1000_3.jpg
ldc1000_3.jpg (81.45 KiB) Viewed 959 times

frank.malik
Posts: 96
Joined: 09 Apr 2021 20:37

Re: LDC1000 sensor values

#26 Post by frank.malik » 29 Nov 2022 21:19

Hi,

my first guess: hardware problem on the SPI interface.
This could be everything, including
  • no clock
  • no SDI connection between board and MCU
  • no SDO connection between board and MCU
  • CS not working properly ( polarity, timing etc )
Do you have the chance to measure the timing of the SPI signals, like with an digital storage oscilloscope?
Kind regards
Frank

Fusion for STM32 v8, STM32F407ZG@168MHz, 4" TFT capacitive
mikromedia 3, PIC32MZ2048EFH100@200MHz, 3" TFT capacitive
NECTO Studio 3.0.0, mikroC AI for ARM/PIC32, mikroSDK v.2.7.2

AntiMember
Posts: 135
Joined: 02 Jan 2020 19:00

Re: LDC1000 sensor values

#27 Post by AntiMember » 29 Nov 2022 22:25

Sorry for the intrusion.
Define a variable as global. To see everywhere in the project.
Remove the module and connect with a jumper MOSI and MISO.
Check in the test program.

ndavis
Posts: 19
Joined: 01 Nov 2022 19:29

Re: LDC1000 sensor values

#28 Post by ndavis » 29 Nov 2022 22:58

I do not have a oscilloscope.

For defining a global variable, I'm not 100% sure how to do this. I assume I would create the variable outside of the loops in code but how to define it. Are you saying to make the volatile uint8_t device_id a global variable or something else? I placed a jumper wire between the MISO and MOSI as described with the code as is (no global variable) and its shows 0X00 for the device ID.


So I was curious to see what the ID would be no jumper or LDC click board and it prints out 0X00.

I placed the LDC1000 click board back into the MikroBUS and I have it now printing the ID as 0X00. Is this the correct value for the ID?

frank.malik
Posts: 96
Joined: 09 Apr 2021 20:37

Re: LDC1000 sensor values

#29 Post by frank.malik » 30 Nov 2022 14:26

Hi ndavis,

I think the idea from AntiMember is a very good approach, if you have no access to an oscilloscope.
If the "0x00" is good or bad is difficult to say, in this case.

The device ID should be something like "0x80" or "0x84" according to the datasheet. In this sense, "0x00" is not correct.
However, the dummy byte, send to the device when reading from it, is also "0x00". So, do we see an open SDO line or
do we see the dummy byte?

Have you the chance to connect any other SPI device to the bus and try to access this one?
Do you have another platform to verify the operation of the LDC1000 Click Board, like Arduino or another Sparkfun board?
Kind regards
Frank

Fusion for STM32 v8, STM32F407ZG@168MHz, 4" TFT capacitive
mikromedia 3, PIC32MZ2048EFH100@200MHz, 3" TFT capacitive
NECTO Studio 3.0.0, mikroC AI for ARM/PIC32, mikroSDK v.2.7.2

ndavis
Posts: 19
Joined: 01 Nov 2022 19:29

Re: LDC1000 sensor values

#30 Post by ndavis » 30 Nov 2022 17:16

Looking at the LDC1000 spec sheet I see this statement: "The LDC1000 is designed to operate from an analog supply range of 4.75 V to 5.25 V and digital I/O supply
range of 1.8 V to 5.25 V."

When I'm using the TJAG connection and measure the voltage at the MikroBus 5V connection, I'm getting 3.03V. Using the Microbus onboard USBC power, I get 4.93V at this connection and 3.3V at the other. Measuring the power coming off of the UART Serial Board, I'm getting 3.3V. I'm going to try getting another USBC to power the the clickboard from the MicroBus and see if that fixes the issue. I'm guessing that the LDC isn't getting powered.

Post Reply

Return to “Libstock Discussion”