Difference between revisions of "BeagleBoard/GSoC/BeagleBoneSonicAnemometerBasicWeatherStation"

From eLinux.org
Jump to: navigation, search
(Remote Connectivity)
 
(95 intermediate revisions by the same user not shown)
Line 5: Line 5:
 
=[[BeagleBoard/GSoC/ProposalTemplate|ProposalTemplate]] =
 
=[[BeagleBoard/GSoC/ProposalTemplate|ProposalTemplate]] =
  
''Student'': Manas Mangaonkar <br>
+
Working prototype sonic anemometer using BeagleBone, high speed DAC (eg, PRUDAQ), and ultrasonic sensors. Analyze methods for accuracy/sensitivity (eg, time-of-flight vs. phase difference) and implement "best" method. Use PRUs for independent real-time control of ultrasonics.
 +
 
 +
''Student'': <br>
 
''Mentors'': Stephanie Lockwood-Childs, Steve Arnold<br>
 
''Mentors'': Stephanie Lockwood-Childs, Steve Arnold<br>
''Code'': https://github.com/Pac23/Gsoc_SonicAnemometerBasicWeatherStation<br>
 
 
''Wiki'': http://elinux.org/BeagleBoard/GSoC/ProposalTemplate<br>
 
''Wiki'': http://elinux.org/BeagleBoard/GSoC/ProposalTemplate<br>
  
Line 22: Line 23:
  
 
=Proposal=
 
=Proposal=
I have completed the tast required as described on the ideas page, and created a pull request, as listed [https://github.com/jadonk/gsoc-application/pull/104 here]
+
I have completed the test required as described on the ideas page, and created a pull request, as listed  
  
 
==About Me==
 
==About Me==
''IRC'': Pac23 || Pac23xyz <br>
 
''Github'': [https://github.com/Pac2 Pac23] <br>
 
''School'': [https://ves.ac.in/vesit/ vesit] Which is a campus of and falls under [http://mu.ac.in/portal/ University of Mumbai] <br>
 
 
''Country'': [https://en.wikipedia.org/wiki/India India]<br>
 
''Country'': [https://en.wikipedia.org/wiki/India India]<br>
 
''Primary language'': English,Hindi<br>
 
''Primary language'': English,Hindi<br>
''Typical work hours'': 9:30 - 23:00 IST [https://www.worldtimebuddy.com/?qm=1&lid=2643743,1275339,5128581,5391959&h=2643743&date=2018-3-4&sln=4-18.5 GMT/EST/PST to Ist Adjusted Time]<br>
 
''Previous GSoC participation'': First GSoc Participation, i am excited to be a part of gsoc,since contributing to open source means a lot to me and gsoc will be an special achievement. I got interested in IoT as a teenager,the fact that i could control things to do stuff for me with a single click of a button remotely over the internet or Lan was fascinating and makes life somewhat comfortable.Remotely controlled Air conditioners are a good example of the later,on a hot summer day by the time one reaches home the room is already cooled to perfection since the user activated it before leaving work/school.
 
  
 
==Sonic Anemometer / Basic Weather Station==
 
==Sonic Anemometer / Basic Weather Station==
Line 42: Line 38:
 
Anemometer's are used world wide by Meterologists,Researchers and Scientists to calculate Three Dimensional Windspeed and turbulence. Sonic Anemometers are however utilised since they aren't affected by their operational environmental Conditions.  
 
Anemometer's are used world wide by Meterologists,Researchers and Scientists to calculate Three Dimensional Windspeed and turbulence. Sonic Anemometers are however utilised since they aren't affected by their operational environmental Conditions.  
  
I am not going to harp too much on the anemometer part since that was achieved last year with in depth coverage of how it functions [[GSoC2017_sonic_anemometer_proposal|Here]]  rather would focus on the whole weather station package.
+
I am not going to harp too much on the anemometer part since that was achieved last year with in depth coverage of how it functions [[GSoC2017_sonic_anemometer_proposal|Here]]  rather would focus on the whole weather station package and software end of it,making it functional and user friendly is a important aspect of a working station.
  
 
Sonic Anemometers and other weather station devices cost a lot since majority of them are commercially manufactured. What i plan to implement is on a beagleboard using a single python module to control all of the senors to collect the data from not just the anemometer but also the temperature,pressure,rain and humidity sensor.  
 
Sonic Anemometers and other weather station devices cost a lot since majority of them are commercially manufactured. What i plan to implement is on a beagleboard using a single python module to control all of the senors to collect the data from not just the anemometer but also the temperature,pressure,rain and humidity sensor.  
  
 
From a practical perspective a meteorologist/researcher should be able to deploy the station remotely and get data via the internet,and only access it to change the battery bank/pack maybe even run it on solar(Something that can be done with efficient and large enough panels).
 
From a practical perspective a meteorologist/researcher should be able to deploy the station remotely and get data via the internet,and only access it to change the battery bank/pack maybe even run it on solar(Something that can be done with efficient and large enough panels).
 +
 +
 +
 +
=== Principle of Sonic Anemometer ===
 +
 +
When wind flows in the same direction as sound,the velocity  of sound increases and when in opposite direction it reduces.Along a axis two transducers are placed,Time of flight is calculate in both directions.These transducers act alternately as transmitters and receivers.Time of flight is measured.
 +
 +
For proper measurement the anemometer should have atleast 2 axis.In a 2D anemometer the time taken for ultrasonic pulse of sound to travel from North Transducer to south transducer.Similarly times are compared between west to east.
 +
   
 +
                    [[File:Twodim.png|thumb|2D axis]]
 +
 +
The speed of sound is calculated is independent of factors such as temperatures. Using this device wind speed as well as temperature can be calculated.Even though temperature calculation is not the most accurate and a dedicated sensor must be used.
 +
 +
the speed of sound and the air speed along the axis of the transducers as follows:
 +
 +
T = L/(c+v)
 +
 +
Where T is time, L is the distance between transducers, c is the speed of sound, and v is the air speed along the transducer axis.
 +
 +
The speed of sound in air is dependant on temperature, pressure and suspended contaminants such as dust and fog. In order to obtain the air speed between the transducers, each transducer alternates as transmitter and receiver so that pulses travel in both directions between them. The air speed is calculated from the pulse times in each direction as follows:
 +
 +
v = 0.5L(1/t1-1/t2)
 +
 +
The speed of sound, from which an estimate of air temperature may be derived may be calculated from the pulse times as follows:
 +
 +
c = 0.5L(1/t1+1/t2)
 +
 +
By arranging three pairs of transducers on three different axis, three dimensional wind speed and hence direction and wind angle is obtained.
  
 
===Requirement Analysis===
 
===Requirement Analysis===
Line 54: Line 78:
 
* PRUDAQ/ADC having rate higher than 400ksps per channel(1/2)  
 
* PRUDAQ/ADC having rate higher than 400ksps per channel(1/2)  
 
* Transducers(40Khz,Waterproof)(4)
 
* Transducers(40Khz,Waterproof)(4)
* BMP680 Temperature Humidity,pressure and Gas sensor
+
* MCP9808 High prescision Temperature sensor
 +
* Breadboard
 +
* JumperCables
  
 +
As you may see there are some sensors that overlap each other's functionality and there's a valid reason for that below.
 +
 
DAQ are the Data Acquisition devices which are used to acquire data from sensors and acts as a bridge between sensors and host computer.
 
DAQ are the Data Acquisition devices which are used to acquire data from sensors and acts as a bridge between sensors and host computer.
  
 
PRUDAQ is a fully open source 40MSPS Data Acquisition (DAQ) cape for the BeagleBone Black or Green designed by Jason Holt and his team at Google Research with a software collaboration from the BeagleLogic creator, Kumar Abhishek(one of the mentors this year).PRUDAQ was created to address a need not currently addressed by the market for a portable and low-cost DAQ system that doesn't compromise on performance.
 
PRUDAQ is a fully open source 40MSPS Data Acquisition (DAQ) cape for the BeagleBone Black or Green designed by Jason Holt and his team at Google Research with a software collaboration from the BeagleLogic creator, Kumar Abhishek(one of the mentors this year).PRUDAQ was created to address a need not currently addressed by the market for a portable and low-cost DAQ system that doesn't compromise on performance.
 
Since linux is non-preemptive Os it can't be used for realtime measurements,instead the built in PRU would be used for realtime measurements
 
  
The BMP680 sensor will be used to measure the air pressure,temperature,humidity and gas since the final aim is to build a complete weather station.The sensor combines all of the small specific application sensors into a single package that roughly costs the same as all the senors individually.Given its small footprint it would be easy to manage manage it the only downside being loosing the modularity offered by individual sensors.Humidity and temperature Sensors can be found for cheaper but they often dont offer the reliability and precision.
+
After looking into the previous years code and the work done it was determined that as of now temperature is taken through LM-35 using PRU and PRUDAQ,This year i plan to use the MCP9808 from microchip instead even though it will require me to rewrite some code but that wont take too long(a day Max) nothing more than that,since the sensor offers additional modularity which the LM-35 does not offer and since a working proper prototype is to be achieved this approach seems the best to me.
 +
 
 +
Since linux is non-preemptive Os it can't be used for realtime measurements,instead the built in PRU would be used for realtime measurements.It can be programmed with assembly instructions and hence can be customised as per our requirements and can transfer information with user space programs.The PRU1 for reading the data from ADC and transfer sampled data to BBB host system, however during the reading and transferring , it downsamples the data. Following diagram illustrates the data flow.PRU0 Switches input channels for higher sampling.
 +
 
 +
Since work would be done upon previous years code as of now the 2D axis program provides result every 2s.The 2D anemometer works but has a buffer time since the actual output can be achieved at 0.800s but the buffer exists for future 3 axis additions.This will be changed so that faster results are achieved.
 +
 
 +
Another change is to change the pru assembly code so that control PWM with pru and collect samples only around the time, when wave was sent over the axis,although i only plan on changing this after rest of the sensors and remote config module has been tested and working.
 +
 
 +
I did discuss with the last years contributor and other than changing some typos the circuit as of now works fine.
 +
 
 +
                                                      [[File:Circuit.png|400px]]
 +
 
 +
 
 +
The MCP9808 comes with user-programmable registers that provide flexibility for temperature sensing applications. The registers allow user-selectable settings such as Shutdown or Low-Power modes and the specification of temperature Alert window limits and critical output limits. When the temperature changes beyond the specified boundary limits, the MCP9808 outputs an Alert signal. The user has the option of setting the Alert output signal polarity as an active-low or active-high comparator output for thermostat operation, or as a temperature Alert interrupt output for microprocessor-based systems. The Alert output can also be configured as a critical temperature output only. The MCP9808 has some ready to deploy python libraries so that makes it even better and quicker to implement. This also is cheaper than the DHTXX sensors which are not precise.
 +
 
 +
=== Reusing Older Code and time constraints ===
 +
 
 +
As mentioned above the anemometer part is working and rewriting code for it would be a waste of time,energy and money.I have looked into older code and as of now the only place that things need to be changed are in the process.py file where the temperature accusation and passing functionality will be changed a bit.Rest of the files wont be touched in the repo,only newer code will be added to it for data accusation from other sensors.
 +
 
 +
Since rebuilding the 3 axis physical anemometer in a portable package will consume a lot of time,i plan on starting to build it as soon as i get my acceptance mail from google.I do have ready acess to a metal workshop in my college and the instructor there is knowledgeable and cooperative so building the anemometer wont take time. Most of the gsoc official period would be dedicated to the software side of things.My workstation,testing station and other stuff is already setup since i usually tinker around with things.
 +
 
 +
===Timeline:===
 +
 
 +
== Final Goals: ==
 +
 
 +
A Working Weather station prototype that can be deployed quickly in any environmental condition. The weather station shall be able to gather Wind speed,Air pressure,temperature,humidity,gas detection(methane for global warming) and whatever the user decides to add to it further.The station shall be capable of sending the data to a remote server and the user shall be able to access the data from multiple machines.This isn't the actual final goal but rather a gsoc 2018 goal. 
 +
 
 +
=== Future Goals ===
 +
 
 +
More complex web based interface that has more functionality,user groups.This can be sold as a commercial kit,with the front end software being opensource and free to download.
 +
 
 +
* switching modes of sensors from tx to rx and rx to tx.This has been listed as a future goal even in 2017 to find TOF for both directions along a axis, in that way we obtain more accurate wind speed and sound speed but after lot of research it has been concluded that it would require hardware redesign,writing assembly code from scratch for a certain chip from TI and another manufacturer.As far as gsoc goes this won't fit into the timeline without disturbing other things.
 +
 
 +
== Experience and Approach ==
 +
 
 +
As a part of my graduation program of Computer Science Engineering,i am familiar with the concepts of physics and chemistry that would be involved in the project.
 +
 
 +
As far as software skills are concerned. I am proficient in C,Python and C++.I usually program in c and python since my college curriculum is completely based on programming in C and i use python for all of my personal projects.Having worked with various frameworks like django,flask and various api's i think i do have the knowledge required for implementing a remote connectivity module.  
 +
 
 +
 
 +
== Benefit ==
 +
 
 +
The weather station shall be beneficial to students,teachers and researchers who are currently plagued by the cost of commercial hardware available.Even if researchers with large amount of funds do have acess to equipment they still have to spend more money to retrieve it after deployment.Where as given the cost,size and portability of this project it can be airdropped,used and forgotten about.Transporting,storing it would be easy on aircraft's,ships that already have limited space and often researchers have to sacrifice supplies for equipment.Can also be strapped to drones to be deployed since the weight is negligible.  
 +
 
  
===Remote Connectivity===
+
What community members speak -
  
Since the station should be deployed remotely,data transfer back to the main server is a very important aspect.Cellular usb modem/satellite internet can be used to beam the data back.
+
    Great project for the Aspiring Weather Scientist.
 +
                            Michael Welling(m_w)
  
The raw data shall be logged to a json file,at a set interval defined by the user the data shall then be beamed over to the server module.The user shall then choose the factors to automatically generate the graphs using matplotlib. Each individual station having its own setting. The front end module shall be a user friendly gui.
+
    A working/documented FOSS implementation would be a huge
 +
    plus for both the open source and weather communities.
 +
                              Steve Arnold(nerdboy)
  
A stretch goal shall be to add functionality to individually configure/calibrate all of the sensors remotely.
+
and the best one award goes to...
  
===Contingency===
+
    I'll be tempted to build one!
What will you do if you get stuck on your project and your mentor isn’t around?
+
          Jonathan Cameron(jic23)
  
===Benefit===
+
***Mentors!!! please add your Quote here.***
If successfully completed, what will its impact be on the BeagleBoard.org community? Include quotes from BeagleBoard.org community members who can be found on http://beagleboard.org/discuss and http://bbb.io/gsocchat.
 
  
 
===Suggestions===
 
===Suggestions===
 
Is there anything else we should have asked you?
 
Is there anything else we should have asked you?

Latest revision as of 11:48, 10 September 2020


ProposalTemplate

Working prototype sonic anemometer using BeagleBone, high speed DAC (eg, PRUDAQ), and ultrasonic sensors. Analyze methods for accuracy/sensitivity (eg, time-of-flight vs. phase difference) and implement "best" method. Use PRUs for independent real-time control of ultrasonics.

Student:
Mentors: Stephanie Lockwood-Childs, Steve Arnold
Wiki: http://elinux.org/BeagleBoard/GSoC/ProposalTemplate

Status

This Proposal for Sonic Anemometer was accepted in Gsoc 2016,but the chosen ADC proved to be inefficient for sampling at high frequency.

In 2017 again the project was accepted and PRUDAQ was used which solved the sampling and creating trigger for ultrasonic pulse problems.

However Since the final idea is to have a working prototype of a basic weather station with every possible thing ranging from Humidity,temperature to air speed and maybe even pressure.

I discuss what all i plan to implement below.

Proposal

I have completed the test required as described on the ideas page, and created a pull request, as listed

About Me

Country: India
Primary language: English,Hindi

Sonic Anemometer / Basic Weather Station

Project name: BeagleBone Sonic Anemometer / Basic Weather Station

Description

Get the Anemometer/Basic weather station prototype working,by implementing the best methods to counter operational Environment Disturbances.

Sonic AnemoMeter / Basic Weather station

Anemometer's are used world wide by Meterologists,Researchers and Scientists to calculate Three Dimensional Windspeed and turbulence. Sonic Anemometers are however utilised since they aren't affected by their operational environmental Conditions.

I am not going to harp too much on the anemometer part since that was achieved last year with in depth coverage of how it functions Here rather would focus on the whole weather station package and software end of it,making it functional and user friendly is a important aspect of a working station.

Sonic Anemometers and other weather station devices cost a lot since majority of them are commercially manufactured. What i plan to implement is on a beagleboard using a single python module to control all of the senors to collect the data from not just the anemometer but also the temperature,pressure,rain and humidity sensor.

From a practical perspective a meteorologist/researcher should be able to deploy the station remotely and get data via the internet,and only access it to change the battery bank/pack maybe even run it on solar(Something that can be done with efficient and large enough panels).


Principle of Sonic Anemometer

When wind flows in the same direction as sound,the velocity of sound increases and when in opposite direction it reduces.Along a axis two transducers are placed,Time of flight is calculate in both directions.These transducers act alternately as transmitters and receivers.Time of flight is measured.

For proper measurement the anemometer should have atleast 2 axis.In a 2D anemometer the time taken for ultrasonic pulse of sound to travel from North Transducer to south transducer.Similarly times are compared between west to east.

2D axis

The speed of sound is calculated is independent of factors such as temperatures. Using this device wind speed as well as temperature can be calculated.Even though temperature calculation is not the most accurate and a dedicated sensor must be used.

the speed of sound and the air speed along the axis of the transducers as follows:

T = L/(c+v)

Where T is time, L is the distance between transducers, c is the speed of sound, and v is the air speed along the transducer axis.

The speed of sound in air is dependant on temperature, pressure and suspended contaminants such as dust and fog. In order to obtain the air speed between the transducers, each transducer alternates as transmitter and receiver so that pulses travel in both directions between them. The air speed is calculated from the pulse times in each direction as follows:

v = 0.5L(1/t1-1/t2)

The speed of sound, from which an estimate of air temperature may be derived may be calculated from the pulse times as follows:

c = 0.5L(1/t1+1/t2)

By arranging three pairs of transducers on three different axis, three dimensional wind speed and hence direction and wind angle is obtained.

Requirement Analysis

Following hardware could be used to start with:-

  • Beaglebone Black/Green(1)
  • PRUDAQ/ADC having rate higher than 400ksps per channel(1/2)
  • Transducers(40Khz,Waterproof)(4)
  • MCP9808 High prescision Temperature sensor
  • Breadboard
  • JumperCables

As you may see there are some sensors that overlap each other's functionality and there's a valid reason for that below.

DAQ are the Data Acquisition devices which are used to acquire data from sensors and acts as a bridge between sensors and host computer.

PRUDAQ is a fully open source 40MSPS Data Acquisition (DAQ) cape for the BeagleBone Black or Green designed by Jason Holt and his team at Google Research with a software collaboration from the BeagleLogic creator, Kumar Abhishek(one of the mentors this year).PRUDAQ was created to address a need not currently addressed by the market for a portable and low-cost DAQ system that doesn't compromise on performance.

After looking into the previous years code and the work done it was determined that as of now temperature is taken through LM-35 using PRU and PRUDAQ,This year i plan to use the MCP9808 from microchip instead even though it will require me to rewrite some code but that wont take too long(a day Max) nothing more than that,since the sensor offers additional modularity which the LM-35 does not offer and since a working proper prototype is to be achieved this approach seems the best to me.

Since linux is non-preemptive Os it can't be used for realtime measurements,instead the built in PRU would be used for realtime measurements.It can be programmed with assembly instructions and hence can be customised as per our requirements and can transfer information with user space programs.The PRU1 for reading the data from ADC and transfer sampled data to BBB host system, however during the reading and transferring , it downsamples the data. Following diagram illustrates the data flow.PRU0 Switches input channels for higher sampling.

Since work would be done upon previous years code as of now the 2D axis program provides result every 2s.The 2D anemometer works but has a buffer time since the actual output can be achieved at 0.800s but the buffer exists for future 3 axis additions.This will be changed so that faster results are achieved.

Another change is to change the pru assembly code so that control PWM with pru and collect samples only around the time, when wave was sent over the axis,although i only plan on changing this after rest of the sensors and remote config module has been tested and working.

I did discuss with the last years contributor and other than changing some typos the circuit as of now works fine.

                                                      Circuit.png 


The MCP9808 comes with user-programmable registers that provide flexibility for temperature sensing applications. The registers allow user-selectable settings such as Shutdown or Low-Power modes and the specification of temperature Alert window limits and critical output limits. When the temperature changes beyond the specified boundary limits, the MCP9808 outputs an Alert signal. The user has the option of setting the Alert output signal polarity as an active-low or active-high comparator output for thermostat operation, or as a temperature Alert interrupt output for microprocessor-based systems. The Alert output can also be configured as a critical temperature output only. The MCP9808 has some ready to deploy python libraries so that makes it even better and quicker to implement. This also is cheaper than the DHTXX sensors which are not precise.

Reusing Older Code and time constraints

As mentioned above the anemometer part is working and rewriting code for it would be a waste of time,energy and money.I have looked into older code and as of now the only place that things need to be changed are in the process.py file where the temperature accusation and passing functionality will be changed a bit.Rest of the files wont be touched in the repo,only newer code will be added to it for data accusation from other sensors.

Since rebuilding the 3 axis physical anemometer in a portable package will consume a lot of time,i plan on starting to build it as soon as i get my acceptance mail from google.I do have ready acess to a metal workshop in my college and the instructor there is knowledgeable and cooperative so building the anemometer wont take time. Most of the gsoc official period would be dedicated to the software side of things.My workstation,testing station and other stuff is already setup since i usually tinker around with things.

Timeline:

Final Goals:

A Working Weather station prototype that can be deployed quickly in any environmental condition. The weather station shall be able to gather Wind speed,Air pressure,temperature,humidity,gas detection(methane for global warming) and whatever the user decides to add to it further.The station shall be capable of sending the data to a remote server and the user shall be able to access the data from multiple machines.This isn't the actual final goal but rather a gsoc 2018 goal.

Future Goals

More complex web based interface that has more functionality,user groups.This can be sold as a commercial kit,with the front end software being opensource and free to download.

  • switching modes of sensors from tx to rx and rx to tx.This has been listed as a future goal even in 2017 to find TOF for both directions along a axis, in that way we obtain more accurate wind speed and sound speed but after lot of research it has been concluded that it would require hardware redesign,writing assembly code from scratch for a certain chip from TI and another manufacturer.As far as gsoc goes this won't fit into the timeline without disturbing other things.

Experience and Approach

As a part of my graduation program of Computer Science Engineering,i am familiar with the concepts of physics and chemistry that would be involved in the project.

As far as software skills are concerned. I am proficient in C,Python and C++.I usually program in c and python since my college curriculum is completely based on programming in C and i use python for all of my personal projects.Having worked with various frameworks like django,flask and various api's i think i do have the knowledge required for implementing a remote connectivity module.


Benefit

The weather station shall be beneficial to students,teachers and researchers who are currently plagued by the cost of commercial hardware available.Even if researchers with large amount of funds do have acess to equipment they still have to spend more money to retrieve it after deployment.Where as given the cost,size and portability of this project it can be airdropped,used and forgotten about.Transporting,storing it would be easy on aircraft's,ships that already have limited space and often researchers have to sacrifice supplies for equipment.Can also be strapped to drones to be deployed since the weight is negligible.


What community members speak -

   Great project for the Aspiring Weather Scientist.
                           Michael Welling(m_w) 
   A working/documented FOSS implementation would be a huge
   plus for both the open source and weather communities.
                              Steve Arnold(nerdboy) 

and the best one award goes to...

   I'll be tempted to build one!
         Jonathan Cameron(jic23)
      • Mentors!!! please add your Quote here.***

Suggestions

Is there anything else we should have asked you?