1 Reply Latest reply on May 21, 2020 10:30 PM by TakashiM_61

    Let's make the dice of seven eyes with PSoC 6 (M4), the protagonist of the game

    NoTa_4591161

      Hello everyone,

       

      When I was tiding up in my parents' house, I found a logic circuit designed I made 40 years ago. At that time, when video games started to become popular, I was a student and used Logics and tried LED games. Electronic dice can be built with circuits for logic beginners. Since the power supply is 6V and the frequency is low, an astable multivibrator was implemented with CMOS to make a clock, and LS92 is used as a modulo 6 counter and the decoding with LS00 were used to represent the LEDs on the dice. When turned on with the push switch, the dice start. By releasing the switch and turning it off, the designed was made with logic that stop after keeping slows operation for 1.5 seconds.

       

      I introduce how to make this dice game .Oh, this is chance you can definitely enjoy to play this dice game with your kids. There are various ways to play, such as who get the 6's faster, wins if you get big ones, and plays with Sugoroku. Who said Nintendo is better?

      Anyway, to express this in PSoC, I thought that it would be possible to easily control by using HW as it is and performing it with software. Actually, the circuit of modulo 6 counter and decoding has been slightly changed from the design at that time. The Timer component is used for the clock input of modulo 6 counter, and the start, the stop and the speed of the counter are adjusted by S/W.

       

      This example is used PSoC 6 BLE Pioneer Kit CY8CKIT-062-BLE with PSoC Creator. I used PSoC 6 this time, but I think that PSoC 4 can also be used. If I get PSoC 4 kit, I will check it and upload it.

      The block diagram of H/W is as follows.

      1.png

      The clock uses 10KHz for frequency adjustment, and the cycle is changed by S/W. The Compare output of the timer component is used as the input of the modulo 6 counter, the output of that counter is decoded, and the LED lighting pattern is the same as the dice. I decided to use SW2 (GPIO input) to start and stop the dice. The modulo 6 counter and decoding circuit are designed as follows. Seven LEDs are required to represent the dice, but there are LEDs that turn on at the same timing. If four kinds of decoding patterns can be prepared, the die roll can express 1 to 6.

        2.png

      The circuit of the modulo 6 counter and the decoding part is as follows. Pins RED, ORG, BLE are connected to LEDs on board to check the counter.

        3.png

      TTL has the ability to light two LEDs together with one pin, but since PSoC is a 3.3V I/F, it uses two pins to drive two LEDs. The schematic of the LED custom board is shown below.

      4.png

      The board I made is as follows.

      5.png

      The Clock and Timer settings are as follows.

      6.png

      Set Clock to 10KHz. The initial setting of the Timer cycle is 400. Therefore, the clock input of the modulo 6 counter is 25Hz. Compare0 has no problem if the value is within the period. This time it is set to 20.

       

      SW2 is a hardware switch on the kit board. Connected to GPIO on PSOC6 and configured as below.

      7.png

      The default is changed as follow. Remove HW connection check. Drive mode is Resistive Pull Up. Initial drive state is High(1).

      The whole circuit looks like this:

      7_SW2.jpg

       

      The software flow chart is shown below.

      8.png

       

      Timer is set start and rolling dice if SW2 is pushed when variable sw is off (= 0). If SW2 is released when sw is on (= 1), the timer period is set longer and the LED lighting is delayed. It keeps its speed for 1.5 seconds and stops lighting. Please see the attached program for details.

       

      This concludes the general description. In the past, even such simple things were interesting and pleasing. Recent games are very complicated and elaborate, but why don't you play this simple game sometime.

       

      Next time, I'd like to design an improved board using CapSence to work with a gentle touch.

       

       

      Thanks,

      Kenshow