The goal of this application is to design a digital distance sensor with the help of a GreenPAK™ CMIC. The system is designed using the ASM and other components within the GreenPAK to interact with an ultrasonic sensor.  

The system is designed to control a one-shot block, which will generate the trigger pulse with the necessary width for the ultrasonic sensor and classify the returning echo signal (proportional to the distance measured) into 8 distance categories.  

The interface design can be used to drive a digital distance sensor to be used in a wide variety of applications, such as parking assist systems, robotics, warning systems, etc.

Below we described steps needed to understand how the digital distance measurement device has been programmed. However, if you just want to get the result of programming, download GreenPAK software to view the already completed GreenPAK Design File. Plug the GreenPAK Development Kit to your computer and hit the program to design the solution.

Interface with Digital Ultrasonic Sensor

The system designed sends trigger pulses to the ultrasonic sensor every 100 ms. The GreenPAK internal components, together with the ASM, oversee the classification of the returning echo signal from the sensor. The ASM designed uses 8 states (states 0 to 7) to classify the echo from the ultrasonic sensor using the technique of iteratively transitioning through the states as the system waits for the echoed signal. In this way, the further the ASM goes through the states, the fewer LEDs light up. 

As the system keeps measuring every 100 ms (10 times per second) it becomes easy to see the increase or decrease on the distances measured with the sensor.

Ultrasonic Distance Sensor

The sensor to be used on this application is the HC-SR04, which is illustrated with the following Figure 1.

The sensor uses a 5 V source on the leftmost pin and the GND connection on the rightmost pin. It has one input, which is the trigger signal, and one output, which is the echo signal. The GreenPAK generates an appropriate trigger pulse for the sensor (10 us according to the datasheet of the sensor) and measures the corresponding echo pulse signal (proportional to the distance measured) provided by the sensor.

All the logic is set within the GreenPAK using the ASM, delay blocks, counters, oscillators, D flipflops and one-shot components. The components are used to generate the required input trigger pulse for the ultrasonic sensor and classify the returning echo pulse proportional to the distance measured into distance zones as detailed in the following sections. 

The connections needed for the project are shown in Figure 2. 

 The input trigger requested by the sensor is an output generated by the GreenPAK, and the echo output of the sensor is used to measure the distance by the GreenPAK. The internal signals of the system will drive a one-shot component to generate the required pulse to trigger the sensor and the returning echo will be classified, using D flip-flops, logic blocks (LUT and inverter), and a counter block, into the 8 distance zones. The D flip-flops at the end will hold the classification on the output LEDs until the next measure is done (10 measures per second).

Realization with GreenPAK Designer

This design will demonstrate the state machine functionality of the GreenPAK. Since there are eight states within the proposed state machine, the GreenPAK SLG46537 is appropriate for the application. The machine was designed on the GreenPAK Designer software as shown in Figure 3, and the outputs definitions are set on the RAM diagram of Figure 4.

The full diagram of the circuit designed for the application can be seen in Figure 5. The blocks and their functionalities are described after the Figure 5.

As can be seen in Figure 3, Figure 4 and Figure 5, the system is designed to work in sequential-state order to generate a 10 us trigger pulse...

Read more »