Updated ATV Controller

Here is a photo of my new controller board, using a PIC18F452 micro
Background:

The job of a repeater controller is remote access, control and monitoring. Same in many ways to conventional voice repeaters and many of the parts are the same. By going this way means that I was able to provide on going analog access the ATV repeater. If I went to a all digital system this would be a problem, this is the reason I decided on an analog audiovisual switching arrangement.

Introduction:

It is near impossible to buy a ready to go ATV repeater controller. These days ATV is changing with the times and moving into digital technology. This requires a new way of thinking when comes to how you control an ATV repeater. This design uses DTMF with CTSS sub tone to access, in the same way most repeaters controllers do. The good thing about this controller it able to work with more then one receiver and transmitter. It is also cross compatible with the older analog and the newer digital ATV equipment. You can even drive link transmitters by setting up switching configuration on eight by eight AV switcher.

With JP1 set high on startup the software goes into configuration setup mode. By communicating via Hyper terminal you are able to configure the controller. Such as the repeater ID, administer access code, Auto beaconing, type of video switcher used and the receiver configuration. By setting JP2 this turns on or off the CTSS tone control, set on helps eliminate unwanted noise coming in from the control receiver

In case of the Auckland ATV repeater we will need to have the ability switch between eight inputs and eight outputs. So at Digital switch over we can run a four channel DVB multiplex. As well as having more then one repeater input, this could be analog or digital signals. The heart of any ATV repeater is the AV switcher in our case this job is done by a Kramer VS-808 Matrix Switch. My controller communicates via RS-232 port to this switcher. This is the way the RX and beacon mode switching is done.

Features:

1/ Video overlay to display functions, visual feedback.

2/ To turn on and off transmitter and links.

3/ Switch between RX aerials.

4/ To work with more then one sync detector (more then one analog input).

5/ To turn on and off sync detector inputs

6/ To switch between beacon mode and repeat mode.

7/ Remote control of multiple AV inputs and outputs.

8/ To monitor VSWR of transmitter

9/ To be able to monitor temperature

10/ Easy to configure and to setup

ATV Controller circuit


Circuit description:

The Micro-controller I used is a PIC18F452 40 pin dip package, I soon found that the older PIC16F877A Micro-controller did not have sufficient memory to fit all my extra code changers into. With 32kB of memory I have added the comport interface as part of the controller setup and added more on screen information. The 24LC16B EEPROM has two functions one is used to store the hexadecimal values needed to be clock into the STV5730A on screen display and the other is to store the Morse code identification library.

The STV5730A is very important part to play, the main deferences between a standard repeater controller and an ATV controlled is the visual feedback function. It's not the easiest to initialize and get going, there is quite a bit needed to be clock in to set all the registers to begin with. Once this is completed then it's a simple task of sending line and row information to be displayed.

The ULN3003N is used as the relay driver work as a buffer between the Micro-controller and relays. The first four relay outputs are stored in the EEPROM the other two are the TX enable outputs that are automatically turned on at start up. The four remaining relays can be used for remote switching, such as receiver antenna select.

It is also important to be able to loop the control audio channel through from the narrow band FM control receiver. This useful to feed in from ATV chat frequency and relay it out on the Television sound. This output is isolated via two 10k resistors feeding out on the left and right channels.
Repeater block diagram layout

In this block diagram show how the controller is connected to the 8 x 8 Audiovisual switcher. The first three inputs are for analog receivers, this is why they are in line with the sync detectors. These sync detectors are basically PLLs using the NE567 tone decoder that lock to the incoming line frequency of 15.625 kHz, there by changing a logic level on the micro-controller. This could also be configured for any number of inputs up to maxim of three, by connecting the sync detectors to the required inputs. Output one displays the controller information as text in the form of a video overlay. This function is very useful when it come using the DTMF control codes by providing visual feedback.

It is also possible to connect more then one analog transmitter with this configuration up to a number of eight. This could be links of more then one output over a number bands. In diagram I have shown the configuration as a digital multiplex.

Possible future add ons

I am thinking about adding a second RS-232 port to communicate with receiver units. This will provide the ability to change frequency and display signal strength read out. The Mk II FM ATV receiver that I am currently working on will design around a PIC16F876A Microw-controller. This will also have a comport interface, I may re-look at controller code after this project has been completed.

Software layout and code

On start up if JP1 set high then the software will boot up into the configuration setup. This done via Hyper terminal set at 9k6 baud rate.

1/ C?????? Set ID up to six characters long

2/ AM????? Administer user code five digits long

3/ R?= 1 to 3 ??? Receive in, Beacon in and output from 1 to 8

4/ ID1 for on and ID0 for off

5/ IDS?? set ID timer from 1 to 99 minutes

6/ XL0 to set to 808 switcher or XL1 to set for 808xl siwtcher

7/ WD Write data

8/ RD data
Above is a screen shot of the controller setting that were entered via Hyper terminal. With use of the RD command the information echoed back to the PC. If it needs to be updated than make the changers using the interactions list and then WD to write the data back.

Gui interface

Another way to setup the controller is via this Gui interface. As in windows you still can use a Comport port program in Ubuntu Linux. Or if you are like me and you use Linux operating systems you can run this Gui application as well.

This interface sofware is now available for down load from Ubuntu Software center under my callsgin of ZL1WTT
Video overlay display
This is what you would see displayed on your video screen when you use the *5 command via DTMF keypad. I have set the video feeding through the STV5730A to a blue background to make it easer to read the text information. At the top is the repeater identification of ZL1WTT followed the auto timer set 90 minutes, the 1 on the end show you that the identification is set on. Receiver setting show the state of the three sync detectors and the beacon video feeds in and out. Again the 1 on the end show if that input is turn on or the input is switch off. There is six on board relays from this display you tell what state they are in. where you 1 it is on and the 0 is off and the last two the transmitter settings, TX1 and TX2 in this case they are both on. At the bottom of the screen you see the VSWR and the temperature readouts.

DTMF commands

Here is a list of twelve commands all starting with * :


1/ *1 Turn relays on and off 1 to 4 ## to exit, C* to write and B* to read

2/ *2 Switcher mode set for in and out AV matrix ## to exit

3/ *3 Set RX, Beacon and output for repeat mode 01, 02 and 03 to enter

4/ *4 Read and display VSWR

5/ *5 Video overlay page displaying all repeater information

6/ *6 Set ID timer 1 to 99 minutes, D* set to on/off and ## to exit

7/ *7 Control audio pass through

8/ *8 Administer user set RX lock out

9/ *9 Administer user set TX on/off

10/ *A Read and display Analog to Digital levels in 10 bit format

11/ *B ID video overlay

12/ *C Send out Morse ID via sound channels

Micro-controller layout

10 bit Analog to Digital coveter

Voltage standing wave ratio (VSWR) is work out with this formula:
PIC Basic code

The software was written in PIC Basic and compiled into a binary file for programming. A lot of the code came off the Internet, PIC Basic is very well supported and it is quite easy to find. Here is parts of my code, the full program is to large to paste on this web-site.

For this to work I need to convert to something that Micro-controller can understand. Here the code using PIC basic code to calculate out the VSWR.
SWR:   
ADCIN 0, ad1                        
ADCIN 1, ad2
G=SQR ad1: J=SQR ad2
C=(G+J)*1000/(G-L)
GOSUB AtoDcaL 
LCDOUT 254,1     
LCDOUT 254,128 
LCDOUT "SWR value"        
LCDOUT  254,192                                    
LCDOUT DEC D1,".",DEC D2,DEC D3                               
PAUSE 4000
RETURN
' Read channel 0 to ad1
' Read channel 1 to ad2
' Take the Square root
' Move three decimal places
' Workout decimal places
' Clear display
' Start of line one
' Display the decimal value 
' Start of line two
' Display the decimal value
' Wait 4 seconds
AtoDcaL:
D3=C DIG 0   
D2=C DIG 1   
D1=C DIG 2    
RETURN
' Read the position of digit 3
' Read the position of digit 2
' Read the position of digit 1
I have provided three A to D's two can be used to monitor VSWR one is the forwards and the second input is the reflected. The code calculates out the value and then displays the information, this allows for remote monitoring. Another problem is operating temperature of the repeater equipment, this where input three is used. I have connected a Thermistor B57703M from the five volt rail to the input with a 10k resistor to ground. The big problem is the curve of Thermistor and how to offset it with the Micro-controller. I found if I broke down the curve into four parts I could minamise this problem. As per the graph long side the Thermistor is in blue and code is in yellow.

As you can see the tracking range is good from -30 up to 45 degrees Celsius. Not so good above that but a usable indication to what is happening.

Kramer VS-808 Switcher
Setting up Kramer 8 by 8 video switcher. There are two units that will work with this controller one is the older VS-808 and the newer model the VS-808xl they both communicate at 9600 baud rate. The only difference's is the communication protocol between them. The VS-808 uses three bytes and VS-808xl has four bytes as below
Model
Communication protocol
VS-808

Three bytes
                                        | -  Address - |
First byte  | 0 | D | 0 | 0 | 0 | A2 | A1 | A0 |   Address A2 A1 A0 dip switch settable

D=0 for PC to switcher or 1 for reply from switcher


                          | ---- Command ---- |
Second byte  | 1 | * | * | * | * | * | * | * |   Hex 80 + Command ( output number )


                          | -------- Data -------- |
Third byte      | 1 | * | * | * | * | * | * | * |   Hex 80 + Data ( input number )
VS-808xl

Four bytes
                                | ---------- Instruction ---------- |
First byte  | 0 | D | 0 | N5 | N4 | N3 | N2 | N1 | N0 |

D=0 for PC to switcher or 1 for reply from switcher

                                 | ---- Input ---- |
Second byte | 1 | * | * | * | * | * | * | * |  Hex 80 + input number

                                 | --- Output --- |
Third byte     | 1 | * | * | * | * | * | * | * |  Hex 80 + output number

                                 | -- Machine --|
Fourth byte   | 1 | * | * | * | * | * | * | * |  Hex 80 + machine number

ATV Controller Software layout diagram

PIC Basic code
Switcher code

Switch:
LCDOUT 254,128
LCDOUT "Switcher Mode"
D1=0
D2=0
GOSUB GetDtmf
D1=dtmf
GOSUB GetDtmf
D2=dtmf
IF D1=12 AND D2=12 THEN GOSUB BeepK   
IF D1=12 AND D2=12 THEN GOTO Main 
IF D1>8 THEN D1=8                       
IF D2>8 THEN D2=8                      
HSEROUT [0,SW+D2,SW+D1]               
IF D1<>0 AND D2=0 THEN GOSUB All     
IF D1=0 AND D2=0 THEN GOSUB Rset
GOSUB BeepK       
LCDOUT 254,192
PAUSE 1000
GOTO Switch            
                   


' Switcher user section for (Kramer VS-808)                         
' Start of line one
' Display message
' Set digit 1 to 0
' Set digit 2 to 0
' Get DTMF number
' Register D1 = value of first DTMF character
' Get second DTMF character
' Register D2 = value of second DTMF character
' Beep K
' If ## then Main
' Set the max value to 8
' Set the max value to 8
' Data to be sent to RS232 port
' Switcher all out command
' Switcher reset command
' Beep K
' Start of line two
All and Reset

All:
GOSUB BeepK           
LCDOUT 254,192 
LCDOUT "All"
PAUSE 1000
FOR C=1 TO 8
HSEROUT [0,SW+C,SW+D1]
PAUSE 25
NEXT C
RETURN

Rset:
GOSUB BeepK
LCDOUT 254,192
LCDOUT "Reset"
PAUSE 1000
FOR C=1 TO 8
HSEROUT [0,SW+C,SW]
PAUSE 25
NEXT C
RETURN


' Set all outputs to the one input
' Beep K
' Start of line two
' Display message


' Data to be sent to RS232 port




' Reset switcher
' Beep K
' Start of line two
' Display message


' Data to be sent to RS232 port
STV5730A setup code

initSTV:
HIGH Cl :HIGH Do :HIGH EN
PAUSE 250              
wData=$3000 : GOSUB Send
wData=$3000 : GOSUB Send
wData=$00DB : GOSUB Send
wData=$1000 : GOSUB Send
wData=$00CC : GOSUB Send
wData=$1000 : GOSUB Send
wData=$1000 : GOSUB Send
wData=$1B9E : GOSUB Send
wData=$15A1 : GOSUB Send
wData=$183C : GOSUB Send
wData=$00C0 : GOSUB Send
FOR RC=0 TO 10          
wData=$10C4 : GOSUB Send
NEXT RC
CC=0: LC=0 
GOSUB CLS                      
                   


' STV5730A initialize
' Start up data
' 250ms wait
' Send 3000 in Hex
' Send 3000 in Hex
' Send 00DB in Hex
' Send 1000 in Hex
' Init registers (point to register 12)
' Zoom
' Colour
' Control
' Position
' Mode
' Set row attributes
' Rows from 0 to 10


' Set line and row to 0
' Clear video screen
Clear video screen

CLS:
wData=lc*256+CC
GOSUB Send 
wData=$1F0B
GOSUB Send  
CC=CC+1
IF CC>=28 THEN
CC=0
LC=LC+1
ENDIF
IF Lc=11 THEN
RETURN
ELSE
GOTO CLS
ENDIF



' Line and row data
' Send data to STV5730A
' Set character to " "
' Send data to STV5730A

' Max character count of 28
             
         

' Max line count of 11

                     
Serial Communication

Send:        
PAUSE 1      
LOW EN          
GOSUB Serial 
HIGH EN      
HIGH Cl      
HIGH Do      
RETURN

Serial:       
Do=wData.15   
PULSOUT CL,1  
Do=wData.14   
PULSOUT CL,1  
Do=wData.13
PULSOUT CL,1
Do=wData.12
PULSOUT CL,1
Do=wData.11
PULSOUT CL,1
Do=wData.10
PULSOUT CL,1
Do=wData.9
PULSOUT CL,1
Do=wData.8
PULSOUT CL,1
Do=wData.7    
PULSOUT CL,1
Do=wData.6    
PULSOUT CL,1
Do=wData.5
PULSOUT CL,1
Do=wData.4
PULSOUT CL,1
Do=wData.3
PULSOUT CL,1
Do=wData.2
PULSOUT CL,1
Do=wData.1
PULSOUT CL,1
Do=wData.0
PULSOUT CL,1
RETURN


' Send data to STV5730A
' Deylay of 1 mS
' Set chip select low
' Send 16 bit word
' Set chip select pin high
' Set clock pin high
' Set data pin high


' Serial out routine
' Bring Do pin high or low, depending upon bit
' Bring Clock line high and then low
' Same as above
' Same as above
Copyright © 2010 by Grant ZL1WTT  ·  All Rights reserved  ·  E-Mail: [email protected]