Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 25 → Rev 26

/IR-TX-BL/trunk/V0.03/Doku/IR-Ctrl_Schaltplan.GIF
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/IR-TX-BL/trunk/V0.03/Doku/IR-Ctrl_Schaltplan.GIF
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/IR-TX-BL/trunk/V0.03/Doku/IR-Ctrl_Schaltplan_mitT1.GIF
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/IR-TX-BL/trunk/V0.03/Doku/IR-Ctrl_Schaltplan_mitT1.GIF
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/IR-TX-BL/trunk/V0.03/Doku/IR-Tx_V0_03.hex
0,0 → 1,116
:1000000012C02CC02BC02AC029C03FC027C026C0A8
:1000100026C0B1C023C022C021C020C01FC01EC046
:100020001DC0BDC11BC011241FBECFE5D4E0DEBF83
:10003000CDBF10E0A0E6B0E0E2E1F7E002C005903D
:100040000D92A836B107D9F710E0A8E6B0E001C0DC
:100050001D92AD37B107E1F71BD15AC3D1CF1F9223
:100060000F920FB60F9211248F93809169008F5FCA
:100070008093690080916C008F5F80936C008F91FA
:100080000F900FBE0F901F9018951F920F920FB6F2
:100090000F9211242F933F934F938F939F930EB4FE
:1000A00006FE0CC08EB58F7B8EBD1092690086B5A2
:1000B00097B5909371008093700049C08EB58064AD
:1000C0008EBD26B537B58091690080917000909102
:1000D0007100281B390B30936F0020936E00C9010B
:1000E000895592408750974090F588E0253338072E
:1000F00018F084E398E005C02458334030F484E8D5
:1001000093E090936F0080936E0020916000309197
:100110006100C90143E0880F991F4A95E1F7821BEE
:10012000930B20916E0030916F00820F931F23E09C
:10013000969587952A95E1F790936F0080936E00CE
:10014000909361008093600081E0809368009F91AC
:100150008F914F913F912F910F900FBE0F901F9055
:10016000189589E085BD8CE683BD85E083BF89B79E
:100170008E7F89BF08951F920F920FB60F921124A0
:100180002F938F939F9320916A002230B1F02330F8
:1001900020F4213009F04EC006C02330E9F02430AD
:1001A00009F048C034C085B5806185BD82E0809388
:1001B0006A0010926D008AE90BC085B58F7E85BDFF
:1001C00083E080936A0080916B0086FD03C088EF16
:1001D00082BF35C088EEFCCF85B5806185BD88EFD4
:1001E00082BF80916B00880F80936B0080916D00BF
:1001F0008F5F80936D00873020F482E080936A00E7
:100200001EC084E080936A0010926D0018C085B50E
:100210008F7E85BD8CE382BF90916D00943118F480
:1002200020936A0003C085E080936A009F5F9093EB
:100230006D0005C089B78E7F89BF10926A009F91BB
:100240008F912F910F900FBE0F901F901895982FA0
:1002500080916A008823E1F781E080936A0090939F
:100260006B0088B718BE89B7816089BF08951FBC2D
:1002700082EC8EBD89B7846289BF089529B789B79A
:100280008F7D89BF809160009091610029BF0895A2
:1002900088E084BB15BA80E881BB12BA8EE087BBC8
:1002A00018BA1FBC82EC8EBD89B7846289BF72D038
:1002B00058DF789480916800813009F041C0109235
:1002C000680089B799B79F7D99BF209160003091F0
:1002D000610089BF275D364084F081E4B8DFAB9AC6
:1002E00089B799B79F7D99BF2091600030916100D7
:1002F00089BF23573640A4F7AB9889B799B79F7D3C
:1003000099BF209160003091610089BF225E344026
:10031000BCF4979A80E49BDF10926C0004C080913B
:100320006C00803160F489B799B79F7D99BF2091A7
:1003300060003091610089BF2654354084F397985E
:1003400080917200803419F4979A81DF9798809198
:100350007200813409F0AECF939A79DF9398AACFD7
:100360001F93182F8A3011F48DE0FADF5D9BFECFCA
:100370001CB980E090E01F910895599A88E18AB9EC
:1003800086E880BD89E189B960E070E080EB91E0AA
:100390003ED0089582E682B985EC86BF08951F920B
:1003A0000F920FB60F9211248F939F9381B19927CB
:1003B000887F90708038910599F08138910534F4E8
:1003C0000097C9F080369105C9F40FC0883B9105AC
:1003D00059F0883F910561F0883A910579F404C09D
:1003E00083B18093720001C013B886B7806807C0DC
:1003F00086B7806986BF86B7806986BF85EC86BF71
:100400009F918F910F900FBE0F901F901895EF92B4
:10041000FF920F931F93CF93DF938C017B01892B66
:1004200011F4672BC9F16EE070E081E090E03BD001
:10043000FC01009789F1DC0180E88383E114F10479
:1004400071F0F386E28681E8838380917300909156
:100450007400892B21F4F0937400E093730001156C
:100460001105E1F011870087838182608383809189
:10047000750090917600892B89F4F0937600E093D3
:1004800075008091770090917800892B39F4F09372
:100490007800E093770002C0A0E0B0E0CD01E6E094
:1004A000CDB7DEB726C10F931F93CF93DF93869FFF
:1004B0008001879F100D969F100D1124C8010DD04B
:1004C000EC01009721F0A80160E070E0FFD0CE01C0
:1004D000DF91CF911F910F910895CF93DF93AC01DE
:1004E000029710F442E050E0A0917B00B0917C00B4
:1004F000FD01C0E0D0E020E030E020C080819181AB
:100500008417950769F482819381209719F09B8362
:100510008A8304C090937C0080937B00CF0132C01B
:100520004817590738F42115310519F08217930738
:1005300008F49C01EF010280F381E02D3097F1F681
:100540002115310589F1C901841B950B049708F425
:10055000A901E0E0F0E026C08D919C9111978217EF
:100560009307E9F44817590779F4ED018A819B81D3
:10057000309719F09383828304C090937C0080931A
:100580007B00CD01029649C0841B950BFD01E80F4D
:10059000F91F4193519302978D939C933AC0FD01AB
:1005A000A281B3811097C1F68091790090917A0071
:1005B000892B41F4809164009091650090937A00BA
:1005C00080937900209166003091670021153105F4
:1005D00041F42DB73EB78091620090916300281BD3
:1005E000390BE0917900F0917A002E1B3F0B241714
:1005F000350788F0CA0102962817390760F0CF0145
:10060000840F951F029690937A008093790041930E
:100610005193CF0102C080E090E0DF91CF91089527
:10062000CF93DF93009709F44EC0EC0122971B8211
:100630001A82A0917B00B0917C00109711F140E0EC
:1006400050E001C0DC01AC17BD0700F1BB83AA83F9
:10065000FE0121913191E20FF31FEA17FB0771F4BC
:100660002E5F3F4F8D919C911197820F931F99831D
:100670008883FD01828193819B838A834115510583
:1006800059F4D0937C00C0937B001DC0FD01828192
:100690009381AD010097B1F6FA01D383C283219112
:1006A0003191E20FF31FEC17FD0769F42E5F3F4F06
:1006B00088819981820F931FFA01918380838A81B7
:1006C0009B8193838283DF91CF910895DC0101C0E8
:1006D0006D9341505040E0F708952A883988488842
:1006E0005F846E847D848C849B84AA84B984C8844E
:1006F000DF80EE80FD800C811B81AA81B981CE0F45
:10070000D11D0FB6F894DEBF0FBECDBFED01089529
:02071000FFCF19
:08071200DC0520007D00000061
:00000001FF
/IR-TX-BL/trunk/V0.03/Doku/README.TXT
0,0 → 1,77
Readme zur "PPM2PentaxIR" (geändert 2.12.2007)
 
Auslösen und Zoomen von Pentax Fotokameres per IR, gesteuert durch Servoausgang (PPM)
 
Hardwarebasis für die Entwicklung ist eine unbestückte Holger BL-CTRL V1.0 Platinen.
 
Auf dieser Platinen wurden lediglich folgende Bauteile bestückt.
(Bauteilwerte wie bei original BL Bestückung beibehalten)
 
IC1 ATMEGA8 - A
R3 100
R10 18K
R26 4K7
R27 1K
R33 1K
R32 10
 
C3 100n
C7 100n
C11 100n
C12 10uF/16V
 
LED1 LED0805 Grün
LED2 LED0805 Rot
 
Es läst sich natürlich LED1 und LED2 sowie die zugehörigen Vorwiderstände (R27 und R33) einsparen falls man diese eh nicht verwenden möchte,
zumal Sie eher für Debugzwecke eingesetzt wurden.
 
Das PPM Signal (vom Servoausgang) muss an das PPM Pad der BL Platine (Pin12 ATMEGA)
Masse kann praktisch an einen beliebigen Massepunkt an der BL Platinen. Die Versorgungsspannung geht bei mir einfach direkt an das Ausgangspad
des nicht vorhanden Spannungsreglers (IC2) bzw. an den Anschlusspunkt welcher auf der BL Paltine mit 5V versehen ist.
Da kein Spannungsregler verwendet wird ist strickt darauf zu achten, das keine zu hohen Spannungen für die Versorgung verwendet werden,
die üblichen 4,5 bis 5,x Volt eines Empfänger Ausgangs kann der Amtel gut ab. Besser wäre es natürlich einen Spannungsregler zu verwenden,
dann aber statt des 5V Reglers einen 3.3 Volt Typ. Hier sollte dann jedoch der RC Oscilator des Atmegas geprüft werden, da zu erwarten ist
das die Frequenz nicht mehr besonders gut stimmt (tut sie 5V wohl auch nicht)
 
Die IR Diode (ich habe fast beliebige Typen ausprobiert welche ich im Bestand hatte) wird an Masse und an das Basispad des nicht bestückten T1 angeschlossen.
Hierbei dient R3 nun als Vorwiderstand für die LED, deshalb ist R3 auch der einzige Widerstand welcher gegenüber der original BL Bestückung vom Wert her
geändert ist.
 
Wichtig:
Beim Programieren des ATMegas muß auf die richtigen Fusesettings geachtet werden, der Controller muß mit internem 8Mhz Osc laufen.
Ich habe zum setzen der Fusebits PonyPorg verwendet.
 
Das Programieren des Controller läuft bei mir mit AVRdude unter "Programmers Notepad" aus der WinAVR Installation.
Wird das mitgelieferte "makefile" verwendet so ist dort als Programmer "PonySer auf Com1" ausgewähl, so das man mit einem Sercon Interface direkt
aus WinAvr das Programm auf den ATMega progen kann. (geht nur per echter Seriel Schnittstelle, kein USB zu RS232 Wandler)
 
Die Bedienung ist derzeit relativ einfach. Bei Mittelstellung des Kanals (Knüppel Mittel) passiert nichts, wird der Kanal nun in die eine Richtung
gesteuert so wird eine neue Zoomstufe eingestellt (drei Zoomstuffen gibt es bei der Pentax per IR Steuerung), wird der Kanal in
die andere Richtung gesteuert, so wird ein Bild ausgelöst.
Schaltpunkte sind derzeit fix bei ca. nach oben 1750us und 1250us nach unten jeweils mit einer Hysterese von 100us.
Eine normale Graupneranlage gibt üblicherweise bei Kanal Mittelstellung etwas 1500us aus, mit einem Hub in beide Richtungen von ca. 600us
(bei 100% Servoweg), also 1100us bis 1900us. Somit liegen die Schaltpunkte etwa auf halbem Weg.
Anzumerken ist jedoch, das der Interne RC Oscilator des ATMEGA8 ohne spezielle Kalibrierung nicht besonders genau ist und somit doch ganz
schöne Abweichungen auftretten können. Hiermit verschieben sich dann natürlich auch die Schaltpunkte nach oben oder unten.
 
Es befindet sich sicher noch die ein oder andere Stelle im Code welche man besser machen oder eleganter lösen könnte.
Das ganze ist mein erstes Atmel AVR Project und dann auch noch in C , ich bin eigentlich ein eingefleischter
PIC Assembler Fritze :-) also verzeiht mir den Programmierstiel zumal das ganze innerhalb eines Tages fertig wurde.
 
Wenn jemand gerne andere IR Codes ausgeben lassen möchte und genau weis wie diese ausehen, bzw. ich dies rausfinden kann so bin ich auch gerne
bereits das zu implementieren.
 
 
Viel Spaß beim nachbauen und verbessern.
 
Walter Meyer
30.11.2007
freakware GmbH division south
 
 
 
 
 
 
 
/IR-TX-BL/trunk/V0.03/Doku/fuses.JPG
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/IR-TX-BL/trunk/V0.03/Doku/fuses.JPG
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/IR-TX-BL/trunk/V0.03/IR-Tx.pnproj
0,0 → 1,0
<Project name="IR-Tx"><File path="main.c"></File><File path="main.h"></File><File path="uart.h"></File><File path="uart.c"></File><File path="twislave.c"></File><File path="twislave.h"></File></Project>
/IR-TX-BL/trunk/V0.03/IR-Tx.pnps
0,0 → 1,0
<pd><ViewState><e p="IR-Tx" x="true"></e></ViewState></pd>
/IR-TX-BL/trunk/V0.03/IR-Tx.pnws
0,0 → 1,0
<Workspace><File path="c:\mikrokopter\projects\ir-tx-bl\trunk\v0.03\main.c"></File><Project path="c:\mikrokopter\projects\ir-tx-bl\trunk\v0.03\ir-tx.pnproj"></Project></Workspace>
/IR-TX-BL/trunk/V0.03/IR-Tx_V0_03.hex
0,0 → 1,116
:1000000012C02CC02BC02AC029C03FC027C026C0A8
:1000100026C0B1C023C022C021C020C01FC01EC046
:100020001DC0BDC11BC011241FBECFE5D4E0DEBF83
:10003000CDBF10E0A0E6B0E0E2E1F7E002C005903D
:100040000D92A836B107D9F710E0A8E6B0E001C0DC
:100050001D92AD37B107E1F71BD15AC3D1CF1F9223
:100060000F920FB60F9211248F93809169008F5FCA
:100070008093690080916C008F5F80936C008F91FA
:100080000F900FBE0F901F9018951F920F920FB6F2
:100090000F9211242F933F934F938F939F930EB4FE
:1000A00006FE0CC08EB58F7B8EBD1092690086B5A2
:1000B00097B5909371008093700049C08EB58064AD
:1000C0008EBD26B537B58091690080917000909102
:1000D0007100281B390B30936F0020936E00C9010B
:1000E000895592408750974090F588E0253338072E
:1000F00018F084E398E005C02458334030F484E8D5
:1001000093E090936F0080936E0020916000309197
:100110006100C90143E0880F991F4A95E1F7821BEE
:10012000930B20916E0030916F00820F931F23E09C
:10013000969587952A95E1F790936F0080936E00CE
:10014000909361008093600081E0809368009F91AC
:100150008F914F913F912F910F900FBE0F901F9055
:10016000189589E085BD8CE683BD85E083BF89B79E
:100170008E7F89BF08951F920F920FB60F921124A0
:100180002F938F939F9320916A002230B1F02330F8
:1001900020F4213009F04EC006C02330E9F02430AD
:1001A00009F048C034C085B5806185BD82E0809388
:1001B0006A0010926D008AE90BC085B58F7E85BDFF
:1001C00083E080936A0080916B0086FD03C088EF16
:1001D00082BF35C088EEFCCF85B5806185BD88EFD4
:1001E00082BF80916B00880F80936B0080916D00BF
:1001F0008F5F80936D00873020F482E080936A00E7
:100200001EC084E080936A0010926D0018C085B50E
:100210008F7E85BD8CE382BF90916D00943118F480
:1002200020936A0003C085E080936A009F5F9093EB
:100230006D0005C089B78E7F89BF10926A009F91BB
:100240008F912F910F900FBE0F901F901895982FA0
:1002500080916A008823E1F781E080936A0090939F
:100260006B0088B718BE89B7816089BF08951FBC2D
:1002700082EC8EBD89B7846289BF089529B789B79A
:100280008F7D89BF809160009091610029BF0895A2
:1002900088E084BB15BA80E881BB12BA8EE087BBC8
:1002A00018BA1FBC82EC8EBD89B7846289BF72D038
:1002B00058DF789480916800813009F041C0109235
:1002C000680089B799B79F7D99BF209160003091F0
:1002D000610089BF275D364084F081E4B8DFAB9AC6
:1002E00089B799B79F7D99BF2091600030916100D7
:1002F00089BF23573640A4F7AB9889B799B79F7D3C
:1003000099BF209160003091610089BF225E344026
:10031000BCF4979A80E49BDF10926C0004C080913B
:100320006C00803160F489B799B79F7D99BF2091A7
:1003300060003091610089BF2654354084F397985E
:1003400080917200803419F4979A81DF9798809198
:100350007200813409F0AECF939A79DF9398AACFD7
:100360001F93182F8A3011F48DE0FADF5D9BFECFCA
:100370001CB980E090E01F910895599A88E18AB9EC
:1003800086E880BD89E189B960E070E080EB91E0AA
:100390003ED0089582E682B985EC86BF08951F920B
:1003A0000F920FB60F9211248F939F9381B19927CB
:1003B000887F90708038910599F08138910534F4E8
:1003C0000097C9F080369105C9F40FC0883B9105AC
:1003D00059F0883F910561F0883A910579F404C09D
:1003E00083B18093720001C013B886B7806807C0DC
:1003F00086B7806986BF86B7806986BF85EC86BF71
:100400009F918F910F900FBE0F901F901895EF92B4
:10041000FF920F931F93CF93DF938C017B01892B66
:1004200011F4672BC9F16EE070E081E090E03BD001
:10043000FC01009789F1DC0180E88383E114F10479
:1004400071F0F386E28681E8838380917300909156
:100450007400892B21F4F0937400E093730001156C
:100460001105E1F011870087838182608383809189
:10047000750090917600892B89F4F0937600E093D3
:1004800075008091770090917800892B39F4F09372
:100490007800E093770002C0A0E0B0E0CD01E6E094
:1004A000CDB7DEB726C10F931F93CF93DF93869FFF
:1004B0008001879F100D969F100D1124C8010DD04B
:1004C000EC01009721F0A80160E070E0FFD0CE01C0
:1004D000DF91CF911F910F910895CF93DF93AC01DE
:1004E000029710F442E050E0A0917B00B0917C00B4
:1004F000FD01C0E0D0E020E030E020C080819181AB
:100500008417950769F482819381209719F09B8362
:100510008A8304C090937C0080937B00CF0132C01B
:100520004817590738F42115310519F08217930738
:1005300008F49C01EF010280F381E02D3097F1F681
:100540002115310589F1C901841B950B049708F425
:10055000A901E0E0F0E026C08D919C9111978217EF
:100560009307E9F44817590779F4ED018A819B81D3
:10057000309719F09383828304C090937C0080931A
:100580007B00CD01029649C0841B950BFD01E80F4D
:10059000F91F4193519302978D939C933AC0FD01AB
:1005A000A281B3811097C1F68091790090917A0071
:1005B000892B41F4809164009091650090937A00BA
:1005C00080937900209166003091670021153105F4
:1005D00041F42DB73EB78091620090916300281BD3
:1005E000390BE0917900F0917A002E1B3F0B241714
:1005F000350788F0CA0102962817390760F0CF0145
:10060000840F951F029690937A008093790041930E
:100610005193CF0102C080E090E0DF91CF91089527
:10062000CF93DF93009709F44EC0EC0122971B8211
:100630001A82A0917B00B0917C00109711F140E0EC
:1006400050E001C0DC01AC17BD0700F1BB83AA83F9
:10065000FE0121913191E20FF31FEA17FB0771F4BC
:100660002E5F3F4F8D919C911197820F931F99831D
:100670008883FD01828193819B838A834115510583
:1006800059F4D0937C00C0937B001DC0FD01828192
:100690009381AD010097B1F6FA01D383C283219112
:1006A0003191E20FF31FEC17FD0769F42E5F3F4F06
:1006B00088819981820F931FFA01918380838A81B7
:1006C0009B8193838283DF91CF910895DC0101C0E8
:1006D0006D9341505040E0F708952A883988488842
:1006E0005F846E847D848C849B84AA84B984C8844E
:1006F000DF80EE80FD800C811B81AA81B981CE0F45
:10070000D11D0FB6F894DEBF0FBECDBFED01089529
:02071000FFCF19
:08071200DC0520007D00000061
:00000001FF
/IR-TX-BL/trunk/V0.03/main.c
0,0 → 1,245
//############################################################################
// - PPM2PentaxIR Main
// - ATMEGA8 mit 8MHz
// - Nur für den privaten Gebrauch
// - Keine Garantie auf Fehlerfreiheit
// - Kommerzielle Nutzung nur mit meiner Zustimmung
// - walter Meyer @ www.freakware.de
// - 30.11.2007
// - Make sure Fuses are programmed for internal 8 MHz RC Oscilator
//############################################################################*/
 
#include "main.h"
#include "uart.h"
#include "twislave.h"
 
volatile unsigned int ppm_signal = 1500;
volatile unsigned char ppm_new = 0;
volatile unsigned char TMR1OvF = 0;
volatile unsigned char IRstate = 0;
volatile unsigned char IRdat = 0;
volatile unsigned char TMR65ms = 0;
 
 
 
SIGNAL(SIG_OVERFLOW1)
{
TMR1OvF++;
TMR65ms++;
}
 
 
SIGNAL(SIG_INPUT_CAPTURE1)
{
static unsigned int pos_ICR;
static unsigned int ppm;
if ((TCCR1B & (1<<ICES1)) != 0) //rising edge
{
TCCR1B &= ~(1<<ICES1); //set falling egde
TMR1OvF = 0;
pos_ICR = ICR1;
}
else //falling edge
{
TCCR1B |= (1<<ICES1); //set rising egde
ppm = (ICR1 - pos_ICR + (int) TMR1OvF * 65536);
if ((ppm > 600) && (ppm < 2400))
{
if (ppm > 2100) ppm = 2100;
if (ppm < 900) ppm = 900;
ppm = (ppm_signal * 7 + ppm) / 8;
ppm_signal = ppm;
ppm_new = 1;
}
}
 
}
 
 
 
/*##############################################################################*/
void StartIRModulation(void)
{
//Timer1 Config for generation the 38Khz IR Modulation
TCCR2 = (0<<FOC2)|(0<<WGM20)|(0<<COM21)|(0<<COM20)|
(1<<WGM21) |(0<<CS22) |(0<<CS21) |(1<<CS20);
 
OCR2 = 108; //~38Khz @ 8Mhz
 
//Timer 0 Config for getting right timing for IR Pattern
TCCR0 = (1<<CS02)|(0<<CS01)|(1<<CS00); // clk(@8MHz) / 1024 = 128us / clk (resolution)
TIMSK &= ~(1<<TOIE0); //
 
}
 
 
SIGNAL(SIG_OVERFLOW0)
{
static unsigned char IRbit;
 
switch (IRstate)
{
case 1:
TCCR2 setbit (1<<COM20);
IRstate = 2;
IRbit = 0;
TCNT0 = 255 - (13000 / 128);
break;
case 2:
TCCR2 clrbit (1<<COM20);
IRstate = 3;
if ((IRdat & 0x40) == 0) TCNT0 = 255 - (1000 / 128);
else TCNT0 = 255 - (3000 / 128);
break;
case 3:
TCCR2 setbit (1<<COM20);
TCNT0 = 255 - (1000 / 128);
IRdat = IRdat << 1;
IRbit++;
if (IRbit < 7) IRstate = 2;
else
{
IRstate = 4;
IRbit = 0;
}
break;
case 4:
TCCR2 clrbit (1<<COM20);
TCNT0 = 255 - (25000 / 128);
if (IRbit < 20) IRstate = 4;
else IRstate = 5;
IRbit++;
break;
default:
TIMSK &= ~(1<<TOIE0);
IRstate = 0;
break;
 
}
 
}
 
 
 
 
 
/*##############################################################################*/
void SendIRSignal(unsigned char txbyte)
{
while (IRstate != 0) {} //IR already in action ?, if so, wait
IRstate = 1; //initial State
IRdat = txbyte; //copy IR Data
TIFR &= TOV0; //set TMR0 Int Flag
TIMSK setbit (1<<TOIE0); //Enable TMR0 Int
}
 
 
 
 
 
 
 
/*##############################################################################*/
void StartPPM(void)
{
//global timer1 Config
TCCR1A = (0<<COM1A1)|(0<<COM1A0)|(0<<COM1B1)|(0<<COM1B0)|
(0<<FOC1A) |(0<<FOC1B) |(0<<WGM10) |(0<<WGM11);
TCCR1B = (1<<ICNC1)|(1<<ICES1)|(0<<WGM13)|
(0<<WGM12)|(0<<CS12)|(1<<CS11)|(0<<CS10); //ICP_POS_FLANKE
 
// interrupts
TIMSK |= (1<<TICIE1)|(1<<TOIE1); //ICP_INT_ENABLE and TIMER1_INT_ENABLE
 
}
 
 
int GetPPM(void)
{
//this routines seems to be nesseccary, as reading a 16 bit value
//on a 8 bit machine is not atomic, so if an interrupt apears between reading
//low and high byte of the 16 bit value a wrong result is possible
unsigned char intmask;
unsigned int ppm_temp;
 
intmask = TIMSK; //backup interupt enable bits
TIMSK &= ~(1<<TICIE1); //disable ppm interrupt
ppm_temp = ppm_signal;
TIMSK = intmask; //restore interupt enable bits
return(ppm_temp); //return ppm_signal
 
}
 
 
/*##############################################################################*/
// MAIN
/*##############################################################################*/
int main (void)
{
 
DDRC = (1<<ledred);
PORTC = 0x00;
DDRD = (1<<ledgreen);
PORTD = 0x00;
DDRB = (1<<1)|(1<<2)|(1<<3);
PORTB = 0x00;
 
 
//StartUART();
StartPPM();
StartI2C();
StartIRModulation();
sei();
 
while (1)
{
//printf("%d ",ppm_signal);
if (ppm_new == 1)
{
ppm_new = 0;
if (GetPPM() > 1750)
{
SendIRSignal(ZOOM);
PORTC |= (1<<ledred);
while (GetPPM() > 1650) {}
PORTC &= ~(1<<ledred);
}
if (GetPPM() < 1250)
{
PORTD |= (1<<ledgreen);
SendIRSignal(TRIGGER);
TMR65ms = 0; //reset 65ms Timer
while (GetPPM() < 1350)
{
if (TMR65ms > 15 * 1) break; //about 1 sec. repeat time
}
PORTD &= ~(1<<ledgreen);
}
}
if (I2C_IN == TRIGGER)
{
PORTD |= (1<<ledgreen);
SendIRSignal(TRIGGER);
PORTD &= ~(1<<ledgreen);
}
if (I2C_IN == ZOOM)
{
PORTD |= (1<<ledred);
SendIRSignal(ZOOM);
PORTD &= ~(1<<ledred);
}
}
 
 
}
/IR-TX-BL/trunk/V0.03/main.h
0,0 → 1,31
#ifndef _MAIN_H
#define _MAIN_H
 
 
#define SYSCLK 8000000L
 
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/eeprom.h>
 
 
#define setbit |=
#define clrbit &=~
#define invbit ^=
#define ledred 3 //on Port C
#define ledgreen 7 //on Port D
#define correction -60
 
#define ZOOM 0x41
#define TRIGGER 0x40
 
#endif //_MAIN_H
 
 
 
 
 
/IR-TX-BL/trunk/V0.03/makefile
0,0 → 1,387
#--------------------------------------------------------------------
# MCU name
MCU = atmega8
#-------------------------------------------------------------------
HAUPT_VERSION = 0
NEBEN_VERSION = 03
#-------------------------------------------------------------------
 
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
 
# Target file name (without extension).
TARGET = IR-Tx_V$(HAUPT_VERSION)_$(NEBEN_VERSION)
 
# Optimization level, can be [0, 1, 2, 3, s]. 0 turns off optimization.
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
OPT = s
 
##########################################################################################################
# List C source files here. (C dependencies are automatically generated.)
SRC = main.c uart.c twislave.c
##########################################################################################################
 
# If there is more than one source file, append them above, or modify and
# uncomment the following:
#SRC += foo.c bar.c
 
# You can also wrap lines by appending a backslash to the end of the line:
#SRC += baz.c \
#xyzzy.c
 
 
 
# List Assembler source files here.
# Make them always end in a capital .S. Files ending in a lowercase .s
# will not be considered source files but generated files (assembler
# output from the compiler), and will be deleted upon "make clean"!
# Even though the DOS/Win* filesystem matches both .s and .S the same,
# it will preserve the spelling of the filenames, and gcc itself does
# care about how the name is spelled on its command-line.
ASRC =
 
 
# List any extra directories to look for include files here.
# Each directory must be seperated by a space.
EXTRAINCDIRS =
 
 
# Optional compiler flags.
# -g: generate debugging information (for GDB, or for COFF conversion)
# -O*: optimization level
# -f...: tuning, see gcc manual and avr-libc documentation
# -Wall...: warning level
# -Wa,...: tell GCC to pass this to the assembler.
# -ahlms: create assembler listing
CFLAGS = -g -O$(OPT) \
-funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums \
-Wall -Wstrict-prototypes \
-Wa,-adhlns=$(<:.c=.lst) \
$(patsubst %,-I%,$(EXTRAINCDIRS))
 
 
# Set a "language standard" compiler flag.
# Unremark just one line below to set the language standard to use.
# gnu99 = C99 + GNU extensions. See GCC manual for more information.
#CFLAGS += -std=c89
#CFLAGS += -std=gnu89
#CFLAGS += -std=c99
CFLAGS += -std=gnu99
 
CFLAGS += -DVERSION_HAUPTVERSION=$(HAUPT_VERSION) -DVERSION_NEBENVERSION=$(NEBEN_VERSION)
 
ifeq ($(AVR_CTRL_PLATINE), 1)
CFLAGS += -DAVR_CTRL_PLATINE=$(AVR_CTRL_PLATINE)
endif
 
 
 
# Optional assembler flags.
# -Wa,...: tell GCC to pass this to the assembler.
# -ahlms: create listing
# -gstabs: have the assembler create line number information; note that
# for use in COFF files, additional information about filenames
# and function names needs to be present in the assembler source
# files -- see avr-libc docs [FIXME: not yet described there]
ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
 
 
 
# Optional linker flags.
# -Wl,...: tell GCC to pass this to linker.
# -Map: create map file
# --cref: add cross reference to map file
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
 
 
 
# Additional libraries
 
# Minimalistic printf version
#LDFLAGS += -Wl,-u,vfprintf -lprintf_min
 
# Floating point printf version (requires -lm below)
#LDFLAGS += -Wl,-u,vfprintf -lprintf_flt
 
# -lm = math library
LDFLAGS += -lm
 
 
 
 
# Programming support using avrdude. Settings and variables.
 
# Programming hardware: alf avr910 avrisp bascom bsd
# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
#
# Type: avrdude -c ?
# to get a full listing.
#
 
AVRDUDE_PROGRAMMER = ponyser
#AVRDUDE_PROGRAMMER = stk200
 
#AVRDUDE_PORT = com1 # programmer connected to serial device
AVRDUDE_PORT = com1
 
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
 
AVRDUDE_FLAGS = -F -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
 
# Uncomment the following if you want avrdude's erase cycle counter.
# Note that this counter needs to be initialized first using -Yn,
# see avrdude manual.
#AVRDUDE_ERASE += -y
 
# Uncomment the following if you do /not/ wish a verification to be
# performed after programming the device.
#AVRDUDE_FLAGS += -V -E noreset
 
 
# Increase verbosity level. Please use this when submitting bug
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
# to submit bug reports.
#AVRDUDE_FLAGS += -v -v
 
 
 
 
# ---------------------------------------------------------------------------
 
# Define directories, if needed.
DIRAVR = c:/winavr
DIRAVRBIN = $(DIRAVR)/bin
DIRAVRUTILS = $(DIRAVR)/utils/bin
DIRINC = .
DIRLIB = $(DIRAVR)/avr/lib
 
 
# Define programs and commands.
SHELL = sh
 
CC = avr-gcc
 
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
SIZE = avr-size
 
 
# Programming support using avrdude.
AVRDUDE = avrdude
 
 
REMOVE = rm -f
COPY = cp
 
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
ELFSIZE = $(SIZE) -A $(TARGET).elf
 
 
 
# Define Messages
# English
MSG_ERRORS_NONE = Errors: none
MSG_BEGIN = -------- begin --------
MSG_END = -------- end --------
MSG_SIZE_BEFORE = Size before:
MSG_SIZE_AFTER = Size after:
MSG_COFF = Converting to AVR COFF:
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
MSG_FLASH = Creating load file for Flash:
MSG_EEPROM = Creating load file for EEPROM:
MSG_EXTENDED_LISTING = Creating Extended Listing:
MSG_SYMBOL_TABLE = Creating Symbol Table:
MSG_LINKING = Linking:
MSG_COMPILING = Compiling:
MSG_ASSEMBLING = Assembling:
MSG_CLEANING = Cleaning project:
 
 
 
 
# Define all object files.
OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
 
# Define all listing files.
LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
 
# Combine all necessary flags and optional flags.
# Add target processor to flags.
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
 
 
 
# Default target.
all: begin gccversion sizebefore $(TARGET).elf $(TARGET).hex $(TARGET).eep \
$(TARGET).lss $(TARGET).sym sizeafter finished end
 
 
# Eye candy.
# AVR Studio 3.x does not check make's exit code but relies on
# the following magic strings to be generated by the compile job.
begin:
@echo
@echo $(MSG_BEGIN)
 
finished:
@echo $(MSG_ERRORS_NONE)
 
end:
@echo $(MSG_END)
@echo
 
 
# Display size of file.
sizebefore:
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
 
sizeafter:
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
 
 
 
# Display compiler version information.
gccversion :
@$(CC) --version
 
 
 
 
# Convert ELF to COFF for use in debugging / simulating in
# AVR Studio or VMLAB.
COFFCONVERT=$(OBJCOPY) --debugging \
--change-section-address .data-0x800000 \
--change-section-address .bss-0x800000 \
--change-section-address .noinit-0x800000 \
--change-section-address .eeprom-0x810000
 
 
coff: $(TARGET).elf
@echo
@echo $(MSG_COFF) $(TARGET).cof
$(COFFCONVERT) -O coff-avr $< $(TARGET).cof
 
 
extcoff: $(TARGET).elf
@echo
@echo $(MSG_EXTENDED_COFF) $(TARGET).cof
$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
 
 
 
 
# Program the device.
program: $(TARGET).hex $(TARGET).eep
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
 
 
 
 
# Create final output files (.hex, .eep) from ELF output file.
%.hex: %.elf
@echo
@echo $(MSG_FLASH) $@
$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
 
%.eep: %.elf
@echo
@echo $(MSG_EEPROM) $@
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
 
# Create extended listing file from ELF output file.
%.lss: %.elf
@echo
@echo $(MSG_EXTENDED_LISTING) $@
$(OBJDUMP) -h -S $< > $@
 
# Create a symbol table from ELF output file.
%.sym: %.elf
@echo
@echo $(MSG_SYMBOL_TABLE) $@
avr-nm -n $< > $@
 
 
 
# Link: create ELF output file from object files.
.SECONDARY : $(TARGET).elf
.PRECIOUS : $(OBJ)
%.elf: $(OBJ)
@echo
@echo $(MSG_LINKING) $@
$(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)
 
 
# Compile: create object files from C source files.
%.o : %.c
@echo
@echo $(MSG_COMPILING) $<
$(CC) -c $(ALL_CFLAGS) $< -o $@
 
 
# Compile: create assembler files from C source files.
%.s : %.c
$(CC) -S $(ALL_CFLAGS) $< -o $@
 
 
# Assemble: create object files from assembler source files.
%.o : %.S
@echo
@echo $(MSG_ASSEMBLING) $<
$(CC) -c $(ALL_ASFLAGS) $< -o $@
 
 
 
 
 
 
# Target: clean project.
clean: begin clean_list finished end
 
clean_list :
@echo
@echo $(MSG_CLEANING)
# $(REMOVE) $(TARGET).hex
# $(REMOVE) $(TARGET).eep
# $(REMOVE) $(TARGET).obj
$(REMOVE) $(TARGET).cof
$(REMOVE) $(TARGET).elf
$(REMOVE) $(TARGET).map
$(REMOVE) $(TARGET).obj
$(REMOVE) $(TARGET).a90
$(REMOVE) $(TARGET).sym
$(REMOVE) $(TARGET).lnk
$(REMOVE) $(TARGET).lss
$(REMOVE) $(OBJ)
$(REMOVE) $(LST)
$(REMOVE) $(SRC:.c=.s)
$(REMOVE) $(SRC:.c=.d)
 
 
# Automatically generate C source code dependencies.
# (Code originally taken from the GNU make user manual and modified
# (See README.txt Credits).)
#
# Note that this will work with sh (bash) and sed that is shipped with WinAVR
# (see the SHELL variable defined above).
# This may not work with other shells or other seds.
#
%.d: %.c
set -e; $(CC) -MM $(ALL_CFLAGS) $< \
| sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > $@; \
[ -s $@ ] || rm -f $@
 
 
# Remove the '-' if you want to see the dependency files generated.
-include $(SRC:.c=.d)
 
 
 
# Listing of phony targets.
.PHONY : all begin finish end sizebefore sizeafter gccversion coff extcoff \
clean clean_list program
 
 
 
/IR-TX-BL/trunk/V0.03/twislave.c
0,0 → 1,62
//############################################################################
// - PPM2PentaxIR Uart for Debug only
// - ATMEGA8 mit 8MHz
// - Nur für den privaten Gebrauch
// - Keine Garantie auf Fehlerfreiheit
// - Kommerzielle Nutzung nur mit meiner Zustimmung
// - walter Meyer @ www.freakware.de
//############################################################################*/
#include <avr/io.h>
#include <util/twi.h>
#include "main.h"
#include "twislave.h"
 
unsigned char I2C_IN;
 
 
//############################################################################
//I2C (TWI) Interface Init
void StartI2C(void)
//############################################################################
{
TWAR = 0x62; //I2C client address
TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWIE) | (1<<TWEA);
}
 
//############################################################################
//ISR, die bei einem Ereignis auf dem Bus ausgelöst wird. Im Register TWSR befindet
//sich dann ein Statuscode, anhand dessen die Situation festgestellt werden kann.
SIGNAL (TWI_vect)
//############################################################################
{
switch (TWSR & 0xF8)
{
case SR_SLA_ACK:
TWCR |= (1<<TWINT);
return;
 
case SR_PREV_ACK: //receive
I2C_IN = TWDR;
TWCR |= (1<<TWINT);
return;
 
case SW_SLA_ACK: //send 0x00
TWDR = 0x00;
TWCR |= (1<<TWINT);
return;
 
case SW_DATA_ACK: //send 0x00
TWDR = 0x00;
TWCR |= (1<<TWINT);
return;
 
case TWI_BUS_ERR_2: //bus error / reset bus
TWCR |=(1<<TWSTO) | (1<<TWINT);
 
case TWI_BUS_ERR_1: //bus error / reset bus
TWCR |=(1<<TWSTO) | (1<<TWINT);
}
TWCR =(1<<TWEA) | (1<<TWINT) | (1<<TWEN) | (1<<TWIE); // TWI Reset
}
 
 
/IR-TX-BL/trunk/V0.03/twislave.h
0,0 → 1,31
#ifndef _TWI_SLAVE_H_
#define _TWI_SLAVE_H_
 
extern unsigned char I2C_IN;
 
extern void StartI2C(void);
 
#define TWI_BUS_ERR_1 0x00
#define TWI_BUS_ERR_2 0xF8
 
// Status Slave RX Mode
#define SR_SLA_ACK 0x60
#define SR_LOST_ACK 0x68
#define SR_GEN_CALL_ACK 0x70
#define GEN_LOST_ACK 0x78
#define SR_PREV_ACK 0x80
#define SR_PREV_NACK 0x88
#define GEN_PREV_ACK 0x90
#define GEN_PREV_NACK 0x98
#define STOP_CONDITION 0xA0
#define REPEATED_START 0xA0
 
// Status Slave TX mode
#define SW_SLA_ACK 0xA8
#define SW_LOST_ACK 0xB0
#define SW_DATA_ACK 0xB8
#define SW_DATA_NACK 0xC0
#define SW_LAST_ACK 0xC8
 
#endif
 
/IR-TX-BL/trunk/V0.03/uart.c
0,0 → 1,38
//############################################################################
// - PPM2PentaxIR Uart for Debug only
// - ATMEGA8 mit 8MHz
// - Nur für den privaten Gebrauch
// - Keine Garantie auf Fehlerfreiheit
// - Kommerzielle Nutzung nur mit meiner Zustimmung
// - walter Meyer @ www.freakware.de
//############################################################################*/
 
#include "main.h"
#include "uart.h"
 
void StartUART(void)
{
// UART Double Speed (U2X)
UCSRA |= (1<<U2X);
/* Enable receiver and transmitter, no RX Int, no TX Int */
UCSRB = (1<<RXEN)|(1<<TXEN); // (1<<RXCIE)|(1<<TXCIE)
/* Set frame format: 8data, 1stop bit */
UCSRC = (1<<URSEL)|(1<<UCSZ1)|(1<<UCSZ0);
 
//Teiler wird gesetzt
UBRRL= (SYSCLK / (BAUD_RATE * 8L) -1 );
 
//öffnet einen Kanal für printf (STDOUT)
fdevopen (uart_putchar, NULL);
 
}
 
int uart_putchar (char c)
{
if (c == '\n') uart_putchar('\r');
loop_until_bit_is_set(UCSRA, UDRE);
UDR = c;
return (0);
}
/IR-TX-BL/trunk/V0.03/uart.h
0,0 → 1,11
#ifndef _UART_H
#define _UART_H
 
extern void StartUART (void);
extern int uart_putchar (char c);
 
 
#define BAUD_RATE 38400 //Baud Rate für die Serielle Schnittstelle
 
 
#endif //_UART_H