• Setting up for the first trial runs

    Scott Clandinin08/10/2017 at 04:12 0 comments

    With the code mostly complete, I can try actually running this at night and seeing how much water is remaining when the alarm goes off. The water usually doesn't run out during a 6-7 hour of sleep, so I'll need to fill it up half-way or so to ensure the water will run dry.

    The hanger is the main input for this device. While on the hanger, the device sits waiting for an input, but once removed from the hanger, the measurements begin. Calibration and alarm test can only be done with the mask on the hanger.

    The hanger is very hacked together. I will eventually find a better, more elegant way to implement this. The push button was chosen through Digikey's search system with priority on the amount of force required to depress the button. The mask is quite light, so the button needed to be very sensitive. 

    Unfortunately, the button was too short for the rounded edge of the hanger, so I had to improvise in the meanwhile. That is in fact paper super glue onto the button head to add some height.

    It's not pretty, but it works. Which is a good tagline for the first iteration of the design.

  • Testing the Scale

    Scott Clandinin08/08/2017 at 04:00 0 comments

    Calibration

    Five measurements are taken per weight measurement and averaged. No effort is made to put these resulting value in units of weight since I am working off percent remaining. These calibration values will be placed in EEPROM so calibration doesn't need to be done every time the device loses power.

    Moving Average

    As seen above, a new measurement value takes the place of the first value, and the oldest value is pushed out of the calculation. Every cycle the result is compared to the alarm weight to determine whether or not to sound the alarm.

  • High Level Flow Chart

    Scott Clandinin08/06/2017 at 20:34 0 comments


    Every measurement of weight is done by taking 5 measurements in 50ms increments, and taking the average of them. At any instance the weight is not exactly the same, so this helps dampen out outlier measurements.

    The alarm weight is calculated by: 

    ((full_weight - empty_weight) * alarm_percent) + empty_weight;

    This allows the device to monitor the weight as a function of percent remaining, rather than pre-defined weight.

    The weight to be compared to the alarm weight is the result of a 10 measurement moving average to get a stable value that will dampen out any outlying measurements. At any given time, this weight is the result of 50 separate measurements. When a new measurement is made, it adds it to the calculation, and pushes out the oldest measurement. 

    As long as the hanger is not in use, and the weight doesn't reach the alarm value, the device will keep making measurements. Weight calibrations can only be made while the mask is on the hanger. The user will be notified by a success or error sound based on whether or not calibration values properly set upon taking the mask off of the hanger. If the full weight is less than the empty weight in calibration, an error sound will play.

  • Hooking it all up

    Scott Clandinin08/06/2017 at 04:26 0 comments

    Now that the general enclosure/scale was complete, the next step is building the inputs/outputs into the design, and soldering it all up.

    The two buttons are for calibrating the empty and full water reservoir weights. I chose to semi-hide these to limit the chance of accidentally resetting calibration. The screw terminal is for connecting and disconnecting the mask hanger signal (the jumper was to simulate button press).

    The rails on the top were an afterthought to ensure that the CPAP machine would not move around and would be level.

    Soldering

    Power jack and switch.

    The board consists of an Arduino Nano and the load cell amplifier.

    Revised block diagram showing connections to microcontroller.

    Not the prettiest standoffs but it works.

    Hardware complete!

  • Building the Scale

    Scott Clandinin07/25/2017 at 04:21 0 comments

    There were some slight changes to the design from the original drawings. Mainly just bringing the speaker to the top rather than the side, and bringing the scale surface off-center to make the acknowledge button and speaker more prominent. As well as hiding the calibration buttons more as they won't need to be used as much.

    I did another test of the scale as shown above. More to come on the enclosure later. 

  • First Testing and Designing

    Scott Clandinin07/24/2017 at 05:01 0 comments

    I ordered a 5kg load sensor and HX711 amplifier board that came with it. This amplifier takes in the wheatstone bridge input and outputs the scaled value through a serial pin. I used the Q2HX711 Arduino library to do the work of interfacing with this amplifier.

    I won't be doing any scaling to proper weights with this as I am basing the calculations off of percentage of water remaining rather than comparing to any preset weight values. This way I won't need to worry about zeroing the scale or drifting results.

    Designing the Scale

    I will be making this out of wood as it needs to be fairly rigid to hold the weight of the CPAP machine. Below are rough sketches of what I am planning for the scale.

    The load bar is set up as shown above so that a moment of force will be exerted on one side of the bar to create strain which can be related to weight.

    There was some experimenting and trail and error before looking at the datasheet for the load sensor and realizing that the screw holes were for metric screws rather than imperial screws. It seems obvious now, but prior to this I had not considered imperial and metric screws incompatible. 

  • Processing the Data

    Scott Clandinin04/29/2017 at 16:29 0 comments

    The calibration for this will be pretty easy. Simply placing the empty humidifier reservoir on the base and hitting the calibrate button will measure the lowest weight of the design. This will be stored in non-volatile memory. The same will be done with the reservoir full.

    When the mask is off the hanger, data recording will begin. A measurement will be taken approximately every 30 seconds. Once the first 10 measurements have been taking. A moving average calculation will be make with every new measurement. If this moving average value represents only 10-20% of the water left, the alarm will trigger.

    Hitting the alarm acknowledge button will cause the device to wait 5 minutes and being taking measurements again. Hanging up the mask on the hanger will put the device back into inactive mode. Either way, 10 measurements will always be taken before moving average calculation begins.

    And here is a block diagram just for fun.

  • The idea

    Scott Clandinin04/17/2017 at 04:16 0 comments

    As a CPAP machine is a totally enclosed and airtight device, the best way to monitor the water level (I believe) is to monitor the weight of the entire machine over time. By knowing the weight of the machine with no water and with full water, I can have an alarm go off when the water level is say 10% of the difference between the max and min.

    Components of the idea:

    1. Base

    - a flat box housing all components including the load sensor

    2. Calibration Buttons

    - two small buttons would be on the back of the base. One is to be pressed to get a measurement of the CPAP machine with no water. The other would be pressed to get a measurement of the CPAP with full water. These values would be stored in non-volatile EEPROM.

    3. Speaker

    - used for waking the user up when water is low

    4. Alarm Acknowledge Button

    - a larger button the user can press to reset the measurement routine and stop the alarm

    5. Hanger (with Tactile Button)

    - this is a custom made hanger with a tactile button that will be activated when the mask strap is hanging on it. This will tell the micro to not bother with any measurements. This ensures that while the mask is not being used, no measurements will be made (and therefore no false positives on the alarm).

    Next project log will cover the logic behind how it will work.