/roboti/istrobot/camerus/SW/876/camerus.c |
---|
0,0 → 1,117 |
#include ".\camerus.h" |
#USE FAST_IO (C) |
// kroutitka |
#define CERVENA 1 // AN1 |
#define CERNA 4 // AN4 |
#define ZELENA 3 // AN3 |
#define MODRA 0 // AN0 |
// I/O |
#define LED PIN_C0 |
#define HREF PIN_C5 |
#define PIX PIN_C6 |
#define SERVO PIN_B7 |
void main() |
{ |
int8 cas; |
int16 offset; |
setup_adc_ports(ALL_ANALOG); |
setup_adc(ADC_CLOCK_INTERNAL); |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
setup_timer_1(T1_DISABLED); |
setup_timer_2(T2_DIV_BY_16,255,1); |
setup_ccp1(CCP_PWM); // RC1 |
setup_ccp2(CCP_PWM); // RC2 |
setup_comparator(NC_NC_NC_NC); |
setup_vref(FALSE); |
set_tris_c(0b11111000); |
output_high(LED); |
i2c_start(); // Reset |
i2c_write(0xC0); |
i2c_write(0x12); |
i2c_write(0x80 | 0x24); |
i2c_stop(); |
i2c_start(); // BW |
i2c_write(0xC0); |
i2c_write(0x28); |
i2c_write(0b01000001); |
i2c_stop(); |
i2c_start(); // Contrast |
i2c_write(0xC0); |
i2c_write(0x05); |
i2c_write(0xFF); |
i2c_stop(); |
i2c_start(); // Brightness |
i2c_write(0xC0); |
i2c_write(0x06); |
i2c_write(0x80); |
i2c_stop(); |
/* |
i2c_start(); // Band Filter |
i2c_write(0xC0); |
i2c_write(0x2D); |
i2c_write(0x04 | 0x03); |
i2c_stop(); |
i2c_start(); // 4-bit, (CLK/4) |
i2c_write(0xC0); |
i2c_write(0x3E); |
i2c_write(0x10 | 0x80); |
i2c_stop(); |
*/ |
i2c_start(); // VSTRT |
i2c_write(0xC0); |
i2c_write(0x19); |
i2c_write(45); |
i2c_stop(); |
i2c_start(); // VEND |
i2c_write(0xC0); |
i2c_write(0x1A); |
i2c_write(45); |
i2c_stop(); |
output_low(LED); |
cas=128; |
while(true) |
{ |
while(!input(HREF)); |
set_timer0(0); |
while(input(HREF)) |
{ |
if(!input(PIX)) |
{ |
cas=get_timer0(); |
break; |
} |
}; |
cas=255-cas; |
set_adc_channel(MODRA); |
Delay_ms(1); |
offset=read_adc(); |
output_high(SERVO); |
delay_us(900); |
delay_us(offset); |
delay_us(cas); |
delay_us(cas); |
delay_us(cas); |
output_LOW(SERVO); |
set_pwm1_duty(cas); |
set_pwm2_duty(255-cas); |
}; |
} |
/roboti/istrobot/camerus/SW/876/camerus.PJT |
---|
0,0 → 1,42 |
[PROJECT] |
Target=camerus.HEX |
Development_Mode= |
Processor=0x876A |
ToolSuite=CCS |
[Directories] |
Include=C:\Program Files\PICC\devices\;C:\Program Files\PICC\Dr |
Library= |
LinkerScript= |
[Target Data] |
FileList=C:\dokumenty\svn\Kaklik\roboti\istrobot\camerus\SW\876\camerus.c |
BuildTool=C-COMPILER |
OptionString=+FM |
AdditionalOptionString= |
BuildRequired=1 |
[camerus.c] |
Type=4 |
Path= |
FileList= |
BuildTool= |
OptionString= |
AdditionalOptionString= |
[mru-list] |
1=camerus.c |
[Windows] |
0=0000 camerus.c 0 0 796 451 3 0 |
[Opened Files] |
1=C:\dokumenty\svn\Kaklik\roboti\istrobot\camerus\SW\876\camerus.c |
2=C:\dokumenty\svn\Kaklik\roboti\istrobot\camerus\SW\876\camerus.lst |
3=C:\dokumenty\svn\Kaklik\roboti\istrobot\camerus\SW\876\camerus.h |
4=C:\Program Files\PICC\devices\16F876A.h |
5= |
6= |
[Units] |
Count=1 |
1=C:\dokumenty\svn\Kaklik\roboti\istrobot\camerus\SW\876\camerus.c (main) |
/roboti/istrobot/camerus/SW/876/camerus.h |
---|
0,0 → 1,16 |
#include <16F876A.h> |
#device adc=8 |
#FUSES NOWDT //No Watch Dog Timer |
#FUSES HS //High speed Osc (> 4mhz) |
#FUSES NOPUT //No Power Up Timer |
#FUSES NOPROTECT //Code not protected from reading |
#FUSES NODEBUG //No Debug mode for ICD |
#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 |
#use delay(clock=20000000) |
#use i2c(Master,Fast,sda=PIN_C4,scl=PIN_C3,force_hw) |
/roboti/istrobot/camerus/SW/876 |
---|
Property changes: |
Added: svn:ignore |
+*.bak |
+*.BAK |
+*.cof |
+*.err |
+*.hex |
+*.lst |
+*.sta |
+*.sym |
+*.tre |
/roboti/istrobot/camerus/SW/873/camerus.PJT |
---|
0,0 → 1,40 |
[PROJECT] |
Target=camerus.HEX |
Development_Mode= |
Processor=0x873F |
ToolSuite=CCS |
[Directories] |
Include=C:\Program Files\PICC\devices\;C:\Program Files\PICC\Dr |
Library= |
LinkerScript= |
[Target Data] |
FileList=C:\dokumenty\svn\Kaklik\roboti\istrobot\camerus\873\camerus.c |
BuildTool=C-COMPILER |
OptionString=+FM |
AdditionalOptionString= |
BuildRequired=1 |
[camerus.c] |
Type=4 |
Path= |
FileList= |
BuildTool= |
OptionString= |
AdditionalOptionString= |
[mru-list] |
1=camerus.c |
[Windows] |
0=0000 camerus.c 0 0 796 451 3 0 |
[Opened Files] |
1=C:\dokumenty\svn\Kaklik\roboti\istrobot\camerus\873\camerus.c |
2= |
3=C:\Program Files\PICC\devices\16F873.h |
4= |
[Units] |
Count=1 |
1=C:\dokumenty\svn\Kaklik\roboti\istrobot\camerus\873\camerus.c (main) |
/roboti/istrobot/camerus/SW/873/camerus.c |
---|
0,0 → 1,66 |
#include ".\camerus.h" |
void main() |
{ |
setup_adc_ports(NO_ANALOGS); |
setup_adc(ADC_OFF); |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
setup_timer_1(T1_DISABLED); |
setup_timer_2(T2_DISABLED,0,1); |
output_high(PIN_C0); |
i2c_start(); // Reset |
i2c_write(0xC0); |
i2c_write(0x12); |
i2c_write(0x80 | 0x24); |
i2c_stop(); |
i2c_start(); // BW |
i2c_write(0xC0); |
i2c_write(0x28); |
i2c_write(0b01000001); |
i2c_stop(); |
i2c_start(); // Contrast |
i2c_write(0xC0); |
i2c_write(0x05); |
i2c_write(0xFF); |
i2c_stop(); |
i2c_start(); // Brightness |
i2c_write(0xC0); |
i2c_write(0x06); |
i2c_write(0x80); |
i2c_stop(); |
/* |
i2c_start(); // Band Filter |
i2c_write(0xC0); |
i2c_write(0x2D); |
i2c_write(0x04 | 0x03); |
i2c_stop(); |
i2c_start(); // 4-bit, (CLK/4) |
i2c_write(0xC0); |
i2c_write(0x3E); |
i2c_write(0x10 | 0x80); |
i2c_stop(); |
*/ |
i2c_start(); // VSTRT |
i2c_write(0xC0); |
i2c_write(0x19); |
i2c_write(45); |
i2c_stop(); |
i2c_start(); // VEND |
i2c_write(0xC0); |
i2c_write(0x1A); |
i2c_write(45); |
i2c_stop(); |
output_low(PIN_C0); |
while(true); |
} |
/roboti/istrobot/camerus/SW/873/camerus.h |
---|
0,0 → 1,16 |
#include <16F873.h> |
#device adc=8 |
#FUSES NOWDT //No Watch Dog Timer |
#FUSES XT //Crystal osc <= 4mhz |
#FUSES NOPUT //No Power Up Timer |
#FUSES NOPROTECT //Code not protected from reading |
#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 |
#use delay(clock=4000000) |
#use i2c(Master,Fast,sda=PIN_C4,scl=PIN_C3,force_HW) |
/roboti/istrobot/camerus/SW/873 |
---|
Property changes: |
Added: svn:ignore |
+*.bak |
+*.BAK |
+*.cof |
+*.err |
+*.hex |
+*.lst |
+*.sta |
+*.sym |
+*.tre |