15 January 2018

(SOLVED) Cypress PSOC5LP Failure to Format sprintf Floats

The default behaviour of Creator 4.1 is to skip processing of floating point variables for ARM based processors.  This is due to the newlib-nano library from ARM and Creator project build settings.  If you do not need to format floats then the default settings will save valuable flash space.  However, this gotcha is likely to trip the unsuspecting as good code will not perform as expected.

To following demonstration code does not perform as expected:

#include "project.h"
#include <stdio.h>
int main(void)
{
    CyGlobalIntEnable; /* Enable global interrupts. */

    float num = 12.35;
    char msg[20];

    for(;;)
    {
        sprintf(msg,"Test:%f",num);
    }
}

Adding a breakpoint and running the code with a local variable watch results in the msg char array is inspected:


This would result in an output of: "Test:" followed by a NULL '\000' if the string were transmitted.  This is not is expected or wanted.

The Solution

Some reconfiguartion is needed.  The Linker settings can be found under Project > Build Settings:


Change the Use newlib-nano Float Formating to TRUE.

To account for this change the size of the heap needs to increase.  The heap size can be set within the System tab under Design Wide Resources in the Project tree:


Increase Heap size to 0x200 bytes.

Re-build the project and the output of sprintf is now as expected:



I hope this resolves any difficulties you may be experiencing.  Enjoy!

PS. If your code doesn't appear to be working make sure you are using floating point arithmetic and using constants in their floating point form: 10.0, 1.5, 0.35 etc.

08 January 2018

Footwear Scanning for Threats and Contraband

The risk of terrorist attacks in airports and aeroplanes has led to changes in security screening.  Measures have included limiting the quantities of liquids allowed through security and since the shoe bomber in 2001, passengers must remove shoes during security screening.  This is to enable staff to search shoes using x-rayshoes along with other belongings for concealed threats.  This is inconvenient and slows down the flow of punters into the duty-free area - a profitable area for the airport.


Foot scanner in  March 2013

An alternative approach is to use an Ultra Wide Band (UWB) Microwave Footwear Scanner to detect threats concealed within shoes while they are still worn. A prototype system has been developed and tested which demonstrates an ability to detect concealed metal and dielectric (potentially explosive) objects.

I designed and built the chassis, firmware interface and wrote the Matlab functions to provide simple control of the apparatus.

The first mechanically scanned prototype looked like this:


The idea was to make a single line scan of the foowear along the centreline.

This was replaced with a multi-shoe scanning version using CoreXY configuration and firmware based on Teacup.




The approach above uses active illumination of the shoe through the white nylon plate and measures the optical depth of the shoe in a raster pattern, or any user defined pattern.  Since the optical depth of boundaries is a function of the refractive index of the transmission material peculiarities can be identified.  This is made even easier when soles contain a significant proportion of air.


Shoes 

Many shoes were scanned and some were even damaged to conceal simulated threats in the pursuit of science.  Thank you to my lovely wife and friends!





Scanning the shoe and comparing it with the unmodified version gives the following images, data processed in Matlab:



Various threat simulants were tested. The image on the left-hand side shows the hollowed-out pink sandal filled with plasticine and without on the right.  The effect of the added material in the heel is clearly visible on the left image. 


Adding shrapnel to the mix produces a stronger return signal.  

The range of shoes was broad with trainers, running shoes, business shoes etc.  Here are pictures of some of them:


















Alternative passive mm-wave

Another approach is to use passive mm-wave imaging of footwear to measure the natural blackbody radiation emitted from the sole of the foot.  Concealed objects would show up as differences in the image enabling their detection.  All that is required is a passive mm-wave imager, for example, those from ThruVision and some signal processing.


Publications