Interface and Application Programming


Task: | write an application that interfaces with an input &/or output device that you made

I took this exercise as an opportunity to test a transmit and receive capacitance sensor. Commercially such sensors are used to measure fuel for example; at different fuel levels; different values of capacitance are measured. It is highly popular as sensors can placed outside of containing material; without losing accuracy and remaining clean. (More about the sensor in Week 11)

The set up consists of the following aparatus. i.e Sensor; container with copper sticker that connects to tx;rx ; something to measure the liquid (to get a more precise reading) and your ftdi cable that plugs via usb into the computer.



Continueing from week 11. I ensured everything works and was in check ( making sure to have c file and python file in one folder and command type command 'python hello.txrx.45.py COM4' in command line depending on COM in device manager). After trying to understand the code of the sensor made by Neil this language was converted into processing code. i.e declaring intigers of binary; detecting com port and setting rules to read a 10bit sensor from 8bit. The rest was about reading othercodes and manipulating them for my project.

import controlp5 class into processing libraries(go in preferences/sketchbook location) and use the code below. In the serial at the bottom of the processing file code you will see the changing value of sensor. It is important to map those values accordingly.map(value, start1, stop1, start2, stop2) where start1 is the minimum value of the sensor(empty); stop1 is the maximum(full) value of the sensor; start2 is the minimum amount of liquid ml and stop2 is the maximum. You can change various parameters such as the red marker value (in this case set to 3)

Note: I also modified the java script for the knob class for controlp5- and replaced input name 'value' instead of what was written before so that it would tally with the input name of the sensor.



These were the results:

1. pipe with changing amount of water

2. tx rx sensor

2. resulting gauge which goes red if there is a value of less that 3ml.



Results worked really well and accurately. The slower the process of physical change in liquid; (which is usually the case for reading a gauge) the more accurate the sensor is real time.


|Brief MIT

|Lecture Neil Gershelfeld

|Download all files from repository

Copyright © Joe Galea 2016