├── Freqeunzen.xlsx ├── README.md ├── VTXFirmware └── VTXFirmware.ino └── datasheet.pdf /Freqeunzen.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloidnerux/VTXFirmware/6b7c5370319c8d7a39a4c45374da462661b898d6/Freqeunzen.xlsx -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # VTXFirmware 2 | An arduino sketch to control a RTC6705 analog video transmitter 3 | 4 | I calculated the register values for the corresponding frequencies, but the excel sheet to calculate them is in the repository. The sketch can't do much, but it is a start for everyone seeking a C fundation for their project. 5 | 6 | I use the "standard" boscam module that is SPI ready 7 | * PB3 - MOSI 8 | * PB5 - SCK 9 | * PC1 - CS 10 | 11 | On PC0 is a button to controll the channel selection 12 | 13 | Also there are 3 mosfets connected to the PWM pins of the atmega to controll LED stripes according to the channel selection 14 | -------------------------------------------------------------------------------- /VTXFirmware/VTXFirmware.ino: -------------------------------------------------------------------------------- 1 | // inslude the SPI library: 2 | #include 3 | 4 | //PB3 - MOSI 5 | //PB4 - MISO 6 | //PB5 - SCK 7 | //PC1 - CS 8 | 9 | //PC0 - Button 10 | 11 | //PC4 - SDA 12 | //PC5 - SCL 13 | 14 | //PD0 - RxD 15 | //PD1 - TxD 16 | 17 | //PD3 - VTX On/Off 18 | //PD6 - OC0A - RED PWM OUT 19 | //PB1 - OC1A - GREEN PWM OUT 20 | //PB2 - OC1B - BLUE PWM OUT 21 | 22 | #define SCK (1<<5) 23 | #define MISO (1<<4) 24 | #define MOSI (1<<3) 25 | 26 | #define VTX (1<<3) 27 | #define BUTTON (1<<0) 28 | #define CS (1<<1) 29 | 30 | // set pin 10 as the slave select for the digital pot: 31 | const int slaveSelectPin = 10; 32 | 33 | //Write 25-Bit to teh RTC6705 34 | //4-address bits 35 | //1-read write bit 36 | //20-bit payload LSB 37 | //D20..D0 -> A0 A1 A2 A3 RW D0 D1 D2...D20 38 | void SoftSPISend(uint8_t address, uint8_t upper, uint16_t lower) 39 | { 40 | PORTB &= ~SCK; //Clear sck 41 | PORTB &= ~MOSI; 42 | PORTC &= ~CS; 43 | //Send address bits 44 | for(uint8_t i = 0; i < 4; i++) 45 | { 46 | PORTB |= (address & (1 << i))?(MOSI):(0); 47 | asm("NOP"); 48 | asm("NOP"); 49 | PORTB |= SCK; 50 | delayMicroseconds(2); 51 | PORTB &= ~SCK; 52 | asm("NOP"); 53 | asm("NOP"); 54 | PORTB &= ~MOSI; 55 | asm("NOP"); 56 | asm("NOP"); 57 | } 58 | asm("NOP"); 59 | asm("NOP"); 60 | //Send R/W bit 61 | PORTB |= MOSI; 62 | asm("NOP"); 63 | asm("NOP"); 64 | PORTB |= SCK; 65 | delayMicroseconds(2); 66 | PORTB &= ~SCK; 67 | asm("NOP"); 68 | asm("NOP"); 69 | PORTB &= ~MOSI; 70 | asm("NOP"); 71 | asm("NOP"); 72 | asm("NOP"); 73 | asm("NOP"); 74 | for(uint8_t i = 0; i < 16; i++) 75 | { 76 | PORTB |= (lower & (1 << i))?(MOSI):(0); 77 | asm("NOP"); 78 | asm("NOP"); 79 | PORTB |= SCK; 80 | delayMicroseconds(2); 81 | PORTB &= ~SCK; 82 | asm("NOP"); 83 | asm("NOP"); 84 | PORTB &= ~MOSI; 85 | asm("NOP"); 86 | asm("NOP"); 87 | } 88 | asm("NOP"); 89 | asm("NOP"); 90 | for(uint8_t i = 0; i < 4; i++) 91 | { 92 | PORTB |= (upper & (1 << i))?(MOSI):(0); 93 | asm("NOP"); 94 | asm("NOP"); 95 | PORTB |= SCK; 96 | delayMicroseconds(2); 97 | PORTB &= ~SCK; 98 | asm("NOP"); 99 | asm("NOP"); 100 | PORTB &= ~MOSI; 101 | asm("NOP"); 102 | asm("NOP"); 103 | } 104 | PORTB &= ~SCK; 105 | PORTB &= ~MOSI; 106 | PORTC |= CS; 107 | } 108 | 109 | uint8_t inputStream = 0; 110 | uint8_t state = 0; 111 | uint8_t channel = 0; 112 | 113 | enum STATES 114 | { 115 | STATE_IDLE=0, 116 | STATE_FS, 117 | STATE_RB, 118 | STATE_VTXOFF 119 | }; 120 | //We can omit the upper 4 bits of the 20-bit dataword of reg1 as it is always 0100 121 | uint16_t fatshark[] = {0x610c,0x6500,0x68b4,0x6ca8,0x709c,0x7490,0x7884,0x7c38}; 122 | uint16_t raceband[] = {0x510a,0x5827,0x5f84,0x66a1,0x6dbe,0x751b,0x7c38,0x8395}; 123 | 124 | uint8_t colors[8][3] = {{0, 0xff, 0},{0, 0, 0xff},{0xff, 0xff, 0},{0xff, 0, 0xff},{0, 0xff, 0xff},{0xff, 0xff, 0xff},{0x0f, 0xf0, 0xff},{0xff, 0, 0}}; 125 | 126 | 127 | void setup() { 128 | // set the slaveSelectPin as an output: 129 | pinMode(A0, INPUT_PULLUP); 130 | PORTB = 0; 131 | 132 | DDRB = (1 << 1) | (1 << 2) | (1 << 3) | (1 << 5); //Set MOSI, SCK, PWM Green and PWM Blue as outputs 133 | DDRC = CS; //Set CS as output 134 | PORTC = (1 << 0) | CS; //Pull-Up for the button 135 | DDRD = (1 << 3) | (1 << 1) | (1 << 6); //Set VTXOnOff and TxD as outputs, RED PWM 136 | 137 | //PORTD |= (1 << 3); //Shut-down the VTX 138 | PORTD &= ~(1 << 3); //Enable the VTX 139 | 140 | TCCR0A = (1 << COM0A1) | (1 << WGM01) | (1 << WGM00); //Fast PWM; non inverting 141 | TCCR0B = (1 << CS01) | (1 << CS00); //Clk/64 142 | OCR0A = 0; 143 | 144 | TCCR1A = (1 << COM1A1) | (1 << COM1B1) | (1 << WGM10); //8-bit fast pwm 145 | TCCR1B = (1 << WGM12) | (1 << CS11) | (1 << CS10); //CLk 64 146 | OCR1A = 0; 147 | OCR1B = 0; 148 | 149 | SoftSPISend(0x00, 0, 400); 150 | SoftSPISend(0x01, 4, fatshark[0]); 151 | OCR0A = colors[0][0]; 152 | OCR1A = colors[0][1]; 153 | OCR1B = colors[0][2]; 154 | } 155 | //The R-Register is kept at 400, that gives 40kHz selection 156 | //The output frequency can be calculated by Frf = 2*(64*N+A)*(F_osc/R) 157 | //uint16_t channelFatsharkN[8] = {2242, 2250, 2257, 2265, 2273, 2281, 2289, 2296}; 158 | //uint8_t channelFatsharkA[8] = {12, 0, 52, 40, 28, 16, 4, 56}; 159 | //uint16_t channelRacebandN[8] = {2220, 2224, 2239, 2253, 2267, 2282, 2296, 2311}; 160 | //uint8_t channelRacebandA[8] = {45, 39, 4, 33, 62, 27, 56, 21}; 161 | 162 | 163 | 164 | #define MASK 0xFF 165 | #define BUTTON_DOWN 0xF0 166 | 167 | void loop() { 168 | inputStream <<= 1; 169 | inputStream |= (PINC & BUTTON)?(1):(0); 170 | if((inputStream & MASK) == BUTTON_DOWN) //Button down 171 | { 172 | channel++; 173 | if(channel > 8) 174 | { 175 | channel = 0; 176 | } 177 | //SoftSPISend(0x00, 0, 400); 178 | SoftSPISend(0x01, 4, fatshark[channel]); 179 | OCR0A = colors[channel][0]; 180 | OCR1A = colors[channel][1]; 181 | OCR1B = colors[channel][2]; 182 | } 183 | delay(50); 184 | } 185 | 186 | -------------------------------------------------------------------------------- /datasheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloidnerux/VTXFirmware/6b7c5370319c8d7a39a4c45374da462661b898d6/datasheet.pdf --------------------------------------------------------------------------------