I had been researching Python scripting and whilst this is possible I don't have the time, patience or inclination to learn another programming language - there is only so much room in my head for information! Perhaps I will learn Python in the future and being aware of it and it's function will probably serve me well.

I was browsing through you tube and google looking for programs which graph serial data automatically from comma separated values. I specifically made sure that the data sent out to the serial port from the arduino was comma separated...it makes it easy to import into a spreadsheet program and graph. I would like to be able to do that real time as well.

It describes a java applet which has been written to graph serial data directly from the arduino - just what I was looking for! The video itself explains how to use it quite simply so I won't bother. Sufficed to say all one needs to do is select the appropriate COM port and baud rate and then complete the form with the required information and units and the graph will be displayed.

Once everything is installed I would watch the video and learn how to use the applet. The help button is quite useful! Here are the results:

Here is another screenshot:

Which is very close to the example image given when this project was first specified:

As this part of the project is almost complete, I'm going to move on to the next section which was to measure the pressure output from the ventilator using one of my pressure sensor breakout boards - not too hard to add hopefully. After that it's develop a EMG measurement circuit.

Along the way I think it might be useful to add a microSD card to log the data received along with a real time clock and finally use bluetooth communications to provide wireless serial communications. It's also time to consider powering the system - I'm looking at using 18650 lithium cells and a suitable charging circuit with protection. After than design an enclosure and add some LEDS to show function and this project can be marked complete! Not too far now!!!!

Monday, 8 May 2017

In order to perform a little more testing on the Spirometer device I have designed a venturi tube which can be 3D printed. It is possibly the most ugly and square shaped device ever to be designed but it will 3D print perfectly and because I designed it - I know the internal dimensions. It was designed in the free version of google sketchup and assuming it works well I will share the design files.

I'm going to 3D print this tomorrow but in the mean time lets repeat the calculations to calculate the areas of the first and second sections (The internal tube sections).

In order to make the measurements using the arduino we need the areas calculating for A1 and A2. The formula we are applying in total is:

The dimensions of A1 can be calculated using:

or

Next A2 can be calculated in the same way:

or

Lets now attempt to calculate Q, the Volumetric flow rate. Lets use a value of 320 for P1 and 200 for P2:

Simplifying gives:

And for the second thinner section:

Simplifying gives:

Both values come in almost exactly the same - close enough for my requirements. Good to know the mathematics works out!

From that as before the velocity of flow can then be calculated using:

Just for completeness lets use the value for A2 also:

We can now check all is correct as:

This actually computes to:

Which is really good - as we set the values for P1 and P2 to be 320 and 200 Pa to begin with! The really small error is probably due to rounding errors creeping in with my calculations. Not of significant importance in this case.

Here is a picture of the tube printed and displayed connected to the mask:

The venturi tube connected to a face mask

We can now use the values for A1 and A2 in the arduino code with the newly printed venturi tube. Hopefully the accuracy will be much improved.

Here is the new code - same as before but updated with the new constants for the venturi tube.

I have added to the setup function to provide an initial average. This zeros the sensorValue so that there are no issues with negative numbers during the calculation stage. It is always a good idea to zero things before performing calculations. I have also reduced the number of variables needed.

If people wish to use this code they will need to download the Average.H library from here:

About Me

I'm an electronics engineer and uber geek from the UK. I live in the North West of England in Manchester. I mostly spend my time working in electronics and developing custom electronic solutions to problems as well as a few fun projects. I do a lot of development using microcontrollers - particularly using the arduino