Close

6. Soldering Components With Infineon Version

A project log for Work-holding Robotic Arm for Electronic Workshop

Collaborative Robotic Arm Used as Assistant in an Electronic Workshop And Controlled by Voice Commands and Capsense Technology

guillermo-perez-guillenGuillermo Perez Guillen 07/29/2023 at 23:540 Comments

In this section I will show you how to use the CAPSENSE technology to solder components, and using the PSoC 62S2 WiFi BT Pioneer Kit board. Below I show you the schematic diagram.

Schematic Diagram

Schematic diagram

Schematic diagram

How does it work?

Here we can see the way to hold the PCB board to solder a resistor

Here we can see the way to hold the PCB board to solder a resistor

Moment when I use the soldering iron to solder pins

Moment when I use the soldering iron to solder pins

PSoC 62S2 pinout

PSoC 62S2 pinout

Programming With ModusToolbox

Here I have used the "CAPSENSE_Buttons_and_Slider" example. First select the board in: File - New - ModusToolbox Application

Selecting the model CY8CKIT-062S2-43012

Selecting the model CY8CKIT-062S2-43012

So I changed the application name to Soldering_Components_Using_Capsense as shown below:

Selecting the sample code that served as a model for my project

Selecting the sample code that served as a model for my project

Once the project is created, you have to change the code of the led.c file to:

// AUTHOR: Guillermo Perez Guillen

/*******************************************************************************
* Header files includes
*******************************************************************************/
#include "cybsp.h"
#include "cyhal.h"
#include "led.h"
#include <stdio.h> // added
#include <math.h>

/*******************************************************************************
* Global constants
*******************************************************************************/
#define PWM_LED_FREQ_HZ    (1000000lu)  /* in Hz */
#define GET_DUTY_CYCLE(x)    (100 - x)


/******************************************************************************
 * Servo Macros - added
 *****************************************************************************/

/* PWM Frequency */
#define PWM_FREQUENCY (50u)

/* PWM Duty-cycle */
#define PWM_DUTY_CYCLE_1 (4.58f) //  30 degrees

/*******************************************************************************
* Global constants
*******************************************************************************/
led_state_t led_state_cur = LED_OFF;
cyhal_pwm_t pwm_led;
cyhal_pwm_t servo_1; // added

/*******************************************************************************
* Function Name: update_led_state
********************************************************************************
* Summary:
*  This function updates the LED state, based on the touch input.
*
* Parameter:
*  ledData: the pointer to the LED data structure
*
*******************************************************************************/
void update_led_state(led_data_t *ledData)
{
    if ((led_state_cur == LED_OFF) && (ledData->state == LED_ON))
    {
        cyhal_pwm_start(&pwm_led);
        led_state_cur = LED_ON;
        ledData->brightness = LED_MAX_BRIGHTNESS;
        //printf("brightness high!!!\r\n\n");
    }
    else if ((led_state_cur == LED_ON) && (ledData->state == LED_OFF))
    {
        cyhal_pwm_stop(&pwm_led);
        led_state_cur = LED_OFF;
        ledData->brightness = 0;
        //printf("brightness low!!!\r\n\n");
    }
    else
    {
    }

    if ((LED_ON == led_state_cur) || ((LED_OFF == led_state_cur) && (ledData->brightness > 0)))
    {
        cyhal_pwm_start(&pwm_led);
        uint32_t brightness = (ledData->brightness < LED_MIN_BRIGHTNESS) ? LED_MIN_BRIGHTNESS : ledData->brightness;

        uint32_t servo_control_gripper_1 = brightness;
        uint32_t PWM_DUTY_CYCLE_GRIPPER_1 = 0.00003 * pow(servo_control_gripper_1, 2) + 0.0472 * servo_control_gripper_1 + 3;

        /* Drive the LED with brightness */
        cyhal_pwm_set_duty_cycle(&pwm_led, GET_DUTY_CYCLE(brightness),
                                 PWM_LED_FREQ_HZ);
        cyhal_pwm_set_duty_cycle(&servo_1, PWM_DUTY_CYCLE_GRIPPER_1, PWM_FREQUENCY); // robot gripper
        cyhal_pwm_start(&servo_1); // robot gripper

        led_state_cur = LED_ON;
    }
}

/*******************************************************************************
* Function Name: initialize_led
********************************************************************************
* Summary:
*  Initializes a PWM resource for driving an LED.
*
*******************************************************************************/
cy_rslt_t initialize_led(void)
{
    cy_rslt_t rslt;

    rslt = cyhal_pwm_init(&pwm_led, CYBSP_USER_LED, NULL);
    rslt = cyhal_pwm_init(&servo_1, P7_5, NULL); // added


    if (CY_RSLT_SUCCESS == rslt)
    {
        rslt = cyhal_pwm_set_duty_cycle(&pwm_led,
                                        GET_DUTY_CYCLE(LED_MAX_BRIGHTNESS),
                                        PWM_LED_FREQ_HZ);
        if (CY_RSLT_SUCCESS == rslt)
        {
            rslt = cyhal_pwm_start(&pwm_led);
        }
    }

    if (CY_RSLT_SUCCESS == rslt)
    {
        led_state_cur = LED_ON;
    }
    return rslt;
}

Here I have used as a reference the brightness of the LED, which goes from 0 to 100 and is controlled by the Capsense slider. So, the gripper servo will also move from zero to 100 degrees and will be controlled by Capsense itself, in fact the gripper can't be opened beyond 110 degrees and it's perfect to control it. The formula used as a reference is the one calculated in section 3 of this tutorial.

uint32_t brightness = (ledData->brightness < LED_MIN_BRIGHTNESS) ? LED_MIN_BRIGHTNESS : ledData->brightness;
        uint32_t servo_control_gripper_1 = brightness;
        uint32_t PWM_DUTY_CYCLE_GRIPPER_1 = 0.00003 * pow(servo_control_gripper_1, 2) + 0.0472 * servo_control_gripper_1 + 3;

        /* Drive the LED with brightness */
        cyhal_pwm_set_duty_cycle(&pwm_led, GET_DUTY_CYCLE(brightness),
                                 PWM_LED_FREQ_HZ);
        cyhal_pwm_set_duty_cycle(&servo_1, PWM_DUTY_CYCLE_GRIPPER_1, PWM_FREQUENCY); // robot gripper
        cyhal_pwm_start(&servo_1); // robot gripper

Upload the code to the board with Run - Run Configurations and select Soldering_Components_Using_Capsense Program (KitPro3MiniProg4) as shown below: 

Uploading the executable code to the PSoC 62S2 board

Uploading the executable code to the PSoC 62S2 board

Test

Discussions