/Designs/Measuring_instruments/AWS01B/SW/PIC16F887/i2c_wind_sensor/main.c
0,0 → 1,74
#include "main.h"
#use i2c(Slave,Fast,sda=PIN_B1,scl=PIN_B4,force_hw,address=0xA2) // Motor 2
 
#define H1 PIN_A1
#define L1 PIN_A2
#define H2 PIN_A3
#define L2 PIN_A4
 
signed int8 command; // rozsah +-127
 
#INT_SSP
void ssp_interupt ()
{
BYTE incoming, state;
 
output_a(0); // vypnuti vsech budicu
 
state = i2c_isr_state();
 
if(state < 0x80) //Master is sending data
{
command = i2c_read();
}
 
if(state == 0x80) //Master is requesting data
{
i2c_write(command);
}
}
 
 
void main()
{
int8 speed;
 
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_timer_0(RTCC_INTERNAL);setup_wdt(WDT_144MS);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
setup_oscillator(OSC_8MHZ|OSC_INTRC);
 
enable_interrupts(GLOBAL);
enable_interrupts(INT_SSP);
 
command=-128; // zastaveni po resetu
 
while(true)
{
 
if (command==-128) // prikaz na odpojeni mustku nebo chybna hodnota
{
output_a(0); // volnobeh
continue;
};
 
speed=command+127; // posunuti 0 pro zaporna cisla
 
output_a(0b10010); // vpred
delay_us(speed);
output_a(0); // vypnuti vsech budicu
delay_us(1);
restart_wdt();
output_a(0b01100); // vzad
delay_us(254-speed);
output_a(0); // vypnuti vsech budicu
delay_us(1);
}
}
 
 
 
/Designs/Measuring_instruments/AWS01B/SW/PIC16F887/i2c_wind_sensor/main.h
0,0 → 1,18
#include <16F88.h>
#device adc=8
 
#FUSES WDT //No Watch Dog Timer
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES PUT //Power Up Timer
#FUSES MCLR //Master Clear pin enabled
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOFCMEN //Fail-safe clock monitor disabled
#FUSES NOIESO //Internal External Switch Over mode disabled
 
#use delay(clock=8000000)
 
/Designs/Measuring_instruments/AWS01B/SW/PIC16F887/i2c_wind_sensor/main.pjt
0,0 → 1,40
[PROJECT]
Target=motor.HEX
Development_Mode=
Processor=0x688F
ToolSuite=CCS
 
[Directories]
Include=C:\Program Files\PICC\devices\;C:\Program Files\PICC\Dr
Library=
LinkerScript=
 
[Target Data]
FileList=C:\dokumenty\svn\Kaklik\roboti\Robotour\SW\motor\motor.c
BuildTool=C-COMPILER
OptionString=+FM
AdditionalOptionString=
BuildRequired=1
 
[motor.c]
Type=4
Path=
FileList=
BuildTool=
OptionString=
AdditionalOptionString=
 
[mru-list]
1=motor.c
 
[Windows]
0=0000 motor.c 0 0 796 451 3 0
 
[Opened Files]
1=D:\svn\svnrobozor\roboti\Robotour\SW\motor\motor.c
2=C:\Program Files\PICC\devices\16F88.h
3=
4=
[Units]
Count=1
1=C:\dokumenty\svn\Kaklik\roboti\Robotour\SW\motor\motor.c (main)
/Designs/Measuring_instruments/AWS01B/SW/Python/AWS_read.py
36,6 → 36,7
{"name": "barometer", "type": "altimet01" , "channel": 0, },
{"name": "hum_temp", "type": "sht25" , "channel": 1, },
# {"name": "wind_direction", "type": "mag01" , "channel": 1, },
{"name": "thermometer", "type": "lts01" , "channel": 2, },
],
},
# {"name": "barometer2", "type": "altimet01" , "channel": 6, },
49,6 → 50,7
barometer = cfg.get_device("barometer")
hum_temp = cfg.get_device("hum_temp")
#wind_direction = cfg.get_device("wind_direction")
thermometer = cfg.get_device("thermometer")
time.sleep(0.5)
 
#### Data Logging ###################################################
63,10 → 65,12
(t1, p1) = barometer.get_tp()
hum_temp.route()
t2 = hum_temp.get_temp()
t3 = thermometer.get_temp()
h1 = hum_temp.get_hum()
 
sys.stdout.write(" Temperature: %.2f Pressure: %d TempSHT: %.2f HumSHT: %.1f " % (t1, p1, t2, h1,))
f.write("%d\t%.2f\t%d\t%.2f\t%.1f\n" % (time.time(),t1, p1, t2, h1,))
sys.stdout.write(" Temperature: %.2f Pressure: %d TempSHT: %.2f HumSHT: %.1f TempLTS: %.2f" % (t1, p1, t2, h1, t3))
f.write("%d\t%.2f\t%d\t%.2f\t%.1f\t%.2f\n" % (time.time(),t1, p1, t2, h1, t3))
sys.stdout.flush()
time.sleep(10)
except KeyboardInterrupt: