Measuring Volume of a plastic bottle using Ultrasonic Sensor?

I am working on a thesis as a requirement in my university. My project is a smart trash bin which takes in plastic bottles for recycling. When a user deposits a plastic bottle, the user will be rewarded with incentives based on the volume of the bottle. The dimension of the container is 40cm x 20 cm. I am using HC SR04 Ultrasonic Sensor for this project.

Currently I'm having trouble with the module I'm working with, the volume measurement module. I have made the module by putting 4 ultrasonic sensors on an enclosed container. When the user deposits a bottle, the 2 width-side sensors will measure the distance between itself and the bottle and subtract that measured distance from the total width of the container which gets me the approximate diameter. The 2 length-side sensors will also measure the distance between itself and the bottle and subtract that measured distance from the total height of the container to get me the height of the bottle. I then use the gathered values to calculate the volume by using the circular cylinder formula πr²h. I did not use the ultrasonic library for me to be able to get double type values. See attached image for reference:

x - (x1+x2) will give me the diameter while y - (y1+y2) will give me the height.

My problem is that the values vary by where I put the bottle due to its different shape. The values of the sensors also jump to unrealistic values like over 100cm which is greater than the dimensions of my container. Are there any accurate method to measure volume of PET bottles? Thank you

Code can be viewed HERE

Screenshot_20191106-194553_Trebuchet.png

If the ultrasonic sensors are working inside a container then I suspect there will be lots of echoes to confuse them.

To my mind measuring the weight would be much simpler.

...R

Thank you for your reply,

Yes, the ultrasonic sensors are inside a wooden container with no ceiling. Will fully enclosing the container improve the accuracy of the sensors? Also, how would I get the volume of the bottle by getting its weight?

Are you trying to use all the ultrasonic sensors at the same time?

I would imagine that you have to use them one at a time, and sequentially with the others inoperative so that they don't interfere with each other.

rexendz:
Will fully enclosing the container improve the accuracy of the sensors?

I think it would make things worse. Removing the enclosure would improve things.

Also, how would I get the volume of the bottle by getting its weight?

I had in mind that the reward would be by weight rather than volume.

...R

PET volume is (most often) proportional with base diameter. So why not measure only the maximum diameter of the bottle?

One cant measure the volume anyway using sensor alone, because the bottle shape varies.

Another option is to align the bottle to a reference line, using a motor and then measure bottle shade dimension using a photocells array.

===

I fully agree with @Robin2 - weight is better choice.

JohnLincoln:
Are you trying to use all the ultrasonic sensors at the same time?

I would imagine that you have to use them one at a time, and sequentially with the others inoperative so that they don't interfere with each other.

I have programmed the volume measurement by having the sensors get a distance one at a time by an interval of 100 microseconds. To those who would like to see the actual code, you can view it here

falexandru:
PET volume is (most often) proportional with base diameter. So why not measure only the maximum diameter of the bottle?

One cant measure the volume anyway using sensor alone, because the bottle shape varies.

Another option is to align the bottle to a reference line, using a motor and then measure bottle shade dimension using a photocells array.

===

I fully agree with @Robin2 - weight is better choice.

Thank you for your suggestions,
Yes it's hard to get the volume of PET as I'm only using the cylindrical volume formula as my base model and in that formula, radius increases exponentially by a factor of 2 which means small changes in radius yields to large change in volume.

In your last suggestion, is it getting the area of the shadow of the bottle? Anyways, I've been thinking of using a camera module with opencv library instead of distance sensors as a last resort (which is expensive).

Are you going to accept crushed or distorted bottles for recycling?

Paul

Paul_KD7HB:
Are you going to accept crushed or distorted bottles for recycling?

Paul

No, the bottle should at least be intact with minimum distortion and there must be no liquid inside the bottle for depositing.

Just to rewind this, so your thinking of having some sort of smart bin with a loading door, measurement chamber, ejection system into an (compactor, slicer, melter) then into the actual waste bin and a payment/reward system for size of bottle?

Have you actually dumped the contents of a “plastic bottle only” bin and examined just how much other stuff people cram through that little round hole?

rexendz:
No, the bottle should at least be intact with minimum distortion and there must be no liquid inside the bottle for depositing.

So, in other words, you are trusting people for this. Good luck.

Paul

Slumpert:
Just to rewind this, so your thinking of having some sort of smart bin with a loading door, measurement chamber, ejection system into an (compactor, slicer, melter) then into the actual waste bin and a payment/reward system for size of bottle?

Have you actually dumped the contents of a “plastic bottle only” bin and examined just how much other stuff people cram through that little round hole?

Actually, the other module that we will be designing is the plastic detection module and I saw videos on youtube demonstrating how this is possible.

Paul_KD7HB:
So, in other words, you are trusting people for this. Good luck.

Paul

This project will be implemented in university grounds and only people from the school can access this device. The device will only be powered when the user scans his/her RFID-enabled school ID that is why I am confident no student will try to vandalize/destroy the device and if they do, there will be ID scan logs. The ID scanning is also to reward the user with incentives. There will be a sign indicating that this device only accepts undistorted/uncrushed bottles if it comes to that.

I am not thinking of vandalizing the machine. I am thinking like a university student and trying to figure out how to get more credits from the machine. Perhaps putting a string around the bottle neck and pulling it out of the machine after the credit and before it goes into a bin. Oregon had that problem with the original automatic soda can deposit return machines.

Paul

Perhaps we are a simple problem solving people, but in Aus, we pay 10c at the purchase point.
When a bagful of empties clutters up the garage, we take them to a recycle centre where people there handle everything.
For reasons of WHS , we do not even exit the vehicle .
Empties are counted and 10c each is returned.
Any disallowed items are rejected, automatically.

I saw this type of machine at work in real life past week. It accepts only intact PET, 0.5 L to 2.5 L only.

Roughley 0.01 USD cents per bottle. It is fun to see how the bottle is rotated and swallowed by the machine :-).

Sensors are V shape profiles that wrap around the bottle which is horizontally placed - as far as I can see in the "mouth" of the machine.

There are a number of add-ons available to make this solution marketable.

100 microseconds may be too little time to let echos die down from one sensor before triggering the next. You may need to wait longer between pings, depending on the character of the chamber.

The construction of the inner part of the chamber will have a large effect on the strength and duration of the echoing. A hard smooth surface will reflect much more than a rough "soft" surface. Look into anechoic chambers.

I haven't looked closely at them (yet, just building up a collection) but the "return and earn" machines scan the barcode of the bottle or can to know what it is! :grinning:

Here you may find attached the feeding mouth of the industrial PET refunding machine.

PET machine .doc (62.5 KB)

falexandru:
Here you may find attached the feeding mouth of the industrial PET refunding machine.

Care to post that as a usable image? :roll_eyes:

@Paul_B

I took only 2 pics - this is the best one :-).

There is also a limitation in the file size to post.

Next time I will pass by the Wonder Machine I will take more photos and post them.