I particularly enjoy shopping in the supermarket on the weekend. In the grocery section, there are samples of various food products that range from tuna spread to white coffee. While I enjoy hopping from one sample station to another, my 5 year old son shamelessly always asks for a second helping.
Sampling in electronics carries a different meaning than leisurely eating a variety of snacks. In an embedded system, digital input signals play an important role in telling the system what is the next course of action. I realized how important digital input sampling is when a vehicle parking machine that I was servicing decided to slam down the automatic barrier on a luxury car before it passes through. This is how you can use digital input sampling to avoid having to deal with these sorts of scenarios.
So what is digital sampling? The first signal sampling concept that I picked up in my college days is the Nyquist Sampling Theorem, where a bandlimited signal can be reconstructed when it is sampled by at least twice its original frequency. In my design, I find this approach helpful, not in reconstructing waveforms but in eliminating my systems from behaving erratically.
Theoretically, digital signals are translated to logic 1 and 0. In an embedded system, they are often represented by a voltage value. If a microcontroller operates at 3.3V, logic 1 will be 3.3V and logic 0 will be at 0V. On paper, this logic level looks like a perfect horizontal line that runs continuously until the logic state changes. In reality, these signals are often punctuated by electrical noises that cause a sudden spike or drop in voltage level.
In an auto payment parking system, there are automatic barriers at the entrance and exit in a designated parking area. Drivers usually access these areas by retrieving a ticket from the machines or by flashing a proximity card. The parking machines that guard the entrance and exit are equipped with vehicle detectors. These detectors use logic levels to indicate the presence of a vehicle in its sensing area.
In the case where the automatic barrier came down on the luxury car, the system falsely detected a negative signal from the entrance detector when the vehicle was passing through. It closed the barrier while the vehicle was under it. When this incident repeated itself on a few different sites, I requested to look into the firmware for the machines. I realized, in horror, that the decision to close the barrier was being made by evaluating a single instance of the vehicle detector’s signal.
The last thing you want is for the automatic barrier to slam on your car, just because it falsely believes your car has passed through.
Generally, digital input sampling for embedded systems involves capturing the value of a signal at a specific interval and storing it in a cyclic buffer. A cyclic buffer is a method of buffering in microcontrollers. A value is stored as a variable array in the Static Random Access Memory (SRAM) and when it reaches its end, it overwrites at the beginning. Depending on the application, the number of samples could vary between 5 to 10, with a sampling period of 1 millisecond.
Using this method, the microcontroller has more than one value to base its next action in its logic algorithm. In the case of electrical noises in the vehicle detector, the microcontroller may get one false value reading out of 10 samples, and prevent closing the automatic barrier before the car passes through. In critical applications, the programmer can make even stricter requirements for evaluating samples. This is done by requiring all of the samples to have the same logic before proceeding with the algorithm.
Implementing digital sampling in firmware is easy, and they stabilize the system effectively.
In my situation with the parking system, I made a quick fix to the firmware that incorporated this straightforward sampling method. That way the problematic parking system couldn’t inflict more damage on other vehicles, When the updated firmware was deployed, the parking machines stopped closing the barrier unpredictably. Of course, it goes without saying that digital input sampling for embedded systems within the firmware can be less effective if the PCB itself was not properly designed with signal integrity in mind.
When you need to access an easy-to-use PCB layout tool that includes everything needed to build high-quality manufacturable circuit boards, look no further than CircuitMaker. In addition to easy-to-use PCB design software, all CircuitMaker users have access to a personal workspace on the Altium 365 platform. You can upload and store your design data in the cloud, and you can easily view your projects via your web browser in a secure platform.
Start using CircuitMaker today and stay tuned for the new CircuitMaker Pro from Altium.