3 Replies Latest reply on Sep 16, 2020 11:35 PM by BragadeeshV_41

    Let's make the dice of seven eyes using on PSoC 4 with a proximity sensor,version 2

    NoTa_4591161

      Hi all,

      Through this programing of the dice, I was able to learn various PSoC designs. For more information on designing electronic dice, see the previous posts "PSoC 4 Seven Eyes Dice" and “PSoC 4 Seven Eyes Dice with sound”. This time it is the modified version. From the previous program “Let's make the dice of seven eyes using on PSoC 4 with a proximity sensorthe protagonist of the game”, the decoder part of the circuit is simplified and the PWM part is modified to swap. I will explain the changes here.

      1.png

      The environment used is as follows:

      PSoC Creator 4.3

      CY8CKIT-044

      • 1.  Change of decoding part

      The simplified circuit of the decoding section is as follows. Two inverter logic have been deleted from the previous time.

      1.png 

      • 2.  PWM uses swap function

      The PWM_1 component settings are as follows. Check the Swap of Period.

      2.png

      • 3.  Program changes

      Swap is performed at the timing of the S/W side.

      :
             /* Enable and start PWM block. */
          PWM_2_Start();
      
          for(;;)
          {
              /* Update the baseline of the proximity sensor. */
                    CapSense_UpdateSensorBaseline(CapSense_PROXIMITYSENSOR__PROX);
      
                    /* Scan the proximity sensor. */
                    CapSense_ScanSensor(CapSense_PROXIMITYSENSOR__PROX);
      
              while(CapSense_IsBusy())
                    {
                           /* Put the PSoC 4200M in Sleep power mode while the CapSense is scanning.
                            * The device wakes up using the interrupt generated by CapSense CSD Component
                            * after scanning. */
                    }
      
                    /* Check if proximity sensor is active. */
                    proximity = CapSense_CheckIsSensorActive(CapSense_PROXIMITYSENSOR__PROX);
      
                    if(proximity == ACTIVE)
                    {
                           /* Set the LED at a brightness level corresponding
                            * to the proximity distance. */
                  if(sw==0){
                      PWM_1_WritePeriodBuf(999);
                      PWM_1_WritePeriod(399);
                      PWM_1_WriteCounter(0); 
                      PWM_1_Start();  // Start rolling dice
                      sw=1;
                  }
              }
                    else /* Proximity sensor is inactive. */
                    {
                  if(sw==1){
                      /* Roll dice slowly */
                      PWM_1_TriggerCommand(1, PWM_1_CMD_CAPTURE);
                      CyDelay(1500);  // keep rolling slowly for 1.5sec
                      PWM_1_Stop();// Stop rolling dice                    
                      sw=0;           // sw is off    
                  }
                    }  
          }
                :
      

      When you press SW2 on the Kit board, the dice rotate, and when you speak, it slowly moves down and stops.

       

      Thanks,

      Kenshow