Hello everyone, I am a mechanical engineering student working on a project that involves an ultrasonic sensor that is used to detect the amount of gas that flows through an enclosed tube. After a certain volume of gas has flowed through the tube, a pulse is emitted and the number of pulses emitted is kept track of.
i.e: 1 pulse = 10 cubic feet of gas; if the pulse counter is at 6 then ~60 cubic ft of gas has been consumed
Unfortunately, I had zero prior knowledge of Arduino programming before this project and am trying to learn what I can in the limited amount of time I have. I’ve looked through a few example sketches surrounding pulse counters but they are a bit confusing(at least to me). I’m not asking for someone to do the sketch for me but if you could point me in the right direction I would grateful.
- Our team has decided to use HC-SR04 ultrasonic sensors.
- Arduino UNO or MEGA microcontroller
My attempt at pseudo-code:
// Q = volume of gas used
// T = time
// V = velocity of gas(constant)
// A = cross-sectional area of tube(constant)
Q = V * A * T //as time elapses, Q value will increase
P = 0 //pulse counter starts at 0
if Q >= 10
P = P + 1
T = 0 //resets time and Q to 0
Hopefully my pseudo-code is understandable and reasonable. If you have a better suggestion, please feel free to let me know! Until then, I’ll keep on researching.