Project Autus - Automated Plant Chamber
Fork of keypad_test by
Autus
This is the codebase accompanying the project Autus.
Autus is an automated growth chamber for plants.
Features
Control Humidity inside chamber wrt to external humidity. Control Temperature inside chamber. ( Peltier Heaters/Coolers ) Water and shower plants. Control soil humidity. Monitor water tanks level (Load Cell)
Code Base Features
Fixed timing and CRC for DHT-11 Sensor. Fixed OneWire bug for ds18b20
Cyclic Executive Scheduler with Priority. Async IPC framework for PC App over bluetooth
Fake RTC systick, I was having some trouble with the on board rtc.
weight/weight.cpp@57:7ab93ed49b70, 2014-04-14 (annotated)
- Committer:
- umairaftab
- Date:
- Mon Apr 14 19:18:14 2014 +0000
- Revision:
- 57:7ab93ed49b70
- Parent:
- 14:72176f1e4907
Cosmetic Changes, Menus added
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
umairaftab | 14:72176f1e4907 | 1 | #include "mbed.h" |
umairaftab | 14:72176f1e4907 | 2 | #include "weight.h" |
umairaftab | 14:72176f1e4907 | 3 | static const int MAX_DATAPOINTS=500; |
umairaftab | 14:72176f1e4907 | 4 | static const float MAX_ADC_VALUE=65535; |
umairaftab | 14:72176f1e4907 | 5 | |
umairaftab | 14:72176f1e4907 | 6 | unsigned short current_weight_1=0; |
umairaftab | 14:72176f1e4907 | 7 | unsigned int current_weight_1_int=0; |
umairaftab | 14:72176f1e4907 | 8 | unsigned short CMA_weight1=0; |
umairaftab | 14:72176f1e4907 | 9 | unsigned int dead_load=32500; |
umairaftab | 14:72176f1e4907 | 10 | float weight1=0; |
umairaftab | 14:72176f1e4907 | 11 | void read_weight(){ |
umairaftab | 14:72176f1e4907 | 12 | int count =0; |
umairaftab | 14:72176f1e4907 | 13 | while(count<MAX_DATAPOINTS){ |
umairaftab | 14:72176f1e4907 | 14 | |
umairaftab | 14:72176f1e4907 | 15 | current_weight_1 = weight_sense1.read_u16(); |
umairaftab | 14:72176f1e4907 | 16 | |
umairaftab | 14:72176f1e4907 | 17 | CMA_weight1 = (current_weight_1 + (count*CMA_weight1))/(count+1); |
umairaftab | 14:72176f1e4907 | 18 | wait_ms(5); |
umairaftab | 14:72176f1e4907 | 19 | count++; |
umairaftab | 14:72176f1e4907 | 20 | } |
umairaftab | 14:72176f1e4907 | 21 | CMA_weight1=CMA_weight1-dead_load; |
umairaftab | 14:72176f1e4907 | 22 | } |
umairaftab | 14:72176f1e4907 | 23 | |
umairaftab | 14:72176f1e4907 | 24 | void calc_weight(){ |
umairaftab | 14:72176f1e4907 | 25 | weight1 = (float)CMA_weight1/MAX_ADC_VALUE; |
umairaftab | 14:72176f1e4907 | 26 | //printf("%d -> weightsensor=%4.4f\n\r",CMA_weight1,weight1); |
umairaftab | 14:72176f1e4907 | 27 | } |