Projects for geeks

ROV sensor board

15 Nov 2006

One of the best methods to visualize ROV data is to show them as overlay on images from camera.
This project can be used in any ROV. It presents data read from sensors mixed with video signal from camera. It can read data from analog 4-20mA sensors and from I²C chips. Although project assume usage of specific sensors, any I²C or 4-20mA sensors can be used. Only software needs small modifications.

This board is intended to use in solutions where there are no special control box on the surface that is able to process sensor data. For solutions with control panel, it is better to send sensor data via RS485 to the surface and than display it using hardware installed in control box. Generally speaking, if you have RC controller and video monitor this is solution for you.

This project was developed with cooperation of SUBZNZ ROV


  • ATMega8 chip
  • Interface for BOB-3 or BOB-4 video overlay module
  • 3 headers for I²C devices
  • 1 header for 1-Wire bus
  • 3 headers for analog input (5V)
  • 1 header for 4-20mA sensor 12V powered
  • 2 headers for leak sensor
  • ISP header
  • RS485
  • RS232

Warning For C5 and C6 capacitors (next to crystal) use 22pF instead of 22nF.

BOB-3 and BOB-4

Originally project was developed to use BOB-3 OSD module. But in time of development, Decade Engineering began to sell BOB-4 module, making BOB-3 unavailable.

To make it possible to build ROV Sensor Board using BOB-4, a new version of PCB was developed. BOB-4 do not need 12V and uses different commands to display text.

If you want to use BOB-4 module, use files with BOB4 prefix. Files without this prefix are for BOB-3 version. Both versions of projects uses the same components (so there is only one BOM file for both projects) except 3 resistors: R7, R8 and R9. They are not needed for BOB-4.
When writing software you must use different commands to display text for BOB-4 and BOB-3. Any other hardware is the same for both versions, so routines to read compass heading and other sensor data are the same.

Warning I have no access to BOB-4 module. PCB version for BOB-4 was designed only based on Decade Engineering documentation. It was never tested in reality, only BOB-3 PCB was successfully developed and tested.


Default sensors to use with board:

  • 1 × Nuovafima ST09 pressure sensor connected to 4-20mA header with 12V
  • 3 x current sensors ACS750 connected to analog input headers
  • Digital compass CMPS03 connected to I²C header.
  • Digital thermometer and real time clock DS1629 connected to to I²C header
  • GPS located on surface connected to RS485
  • DS18B20 digital thermometers connected to 1-Wire bus


  • RS232 for diagnostic purposes
  • 1 x I²C header for future use
  • ISP for programming
  • 30 pin SIMM header for BOB-3 module
  • Voltage measure


Single layer no SMD elements.
Note To create PCB use attached PDF or Eagle files (those with BOB4 prefix are for BOB-4 module).
It is important to print layout 1:1, you must disable any scaling or similar options in printer setup. You can also generate gerber files from Eagle CAD using attached project files.

Recommended drill sizes:

  • ø0.8mm for all elements
  • ø1mm for headers and 7805
  • ø3mm for mounting points (in the corners)

Writing software – quick step guide

Here is a short description of all interfaces and small example programs. All examples are in BASCOM-AVR. Some of the visible output data is sent to RS232 (9600 8N1 no hardware handshaking).

Be sure to set appropriate fuse bits to use external crystal. By default atmega8 chip uses 1MHz internal oscillator.


Interface can be connected directly to serial port of PC. You must use serial UART routines to send/receive data.
Serial interface lines are connected to PD6 (TX) and PD7 (RX) pins. No hardware handshaking.

$regfile = "M8DEF.DAT"
$crystal = 7372800
Open "comd.6:9600,8,n,1" For Output As #1                   ‘RS232
	print #1, "Hello world"
	wait 1

To see the result, run HyperTerminal program and set transmission parameters to 9600 8N1, handshaking: none.


RS485 interface is connected to hardware UART. It is important to set send/receive mode of MAX485 chip before any communication (it’s half-duplex).
Serial interface lines are connected to PD1 (TX) and PD0 (RX) pins, pin PB0 changes send (1) or receive mode (0).

$regfile = "M8DEF.DAT"
$crystal = 7372800
$baud = 9600
Config Serialin = Buffered , Size = 20
Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Config Print0 = Portb.0 , Mode = Set                        ‘this configue PB0 as mode RS485 switch
Print "THIS IS RS485 TEST"
   Print "RS485 communication works"
   Waitms 500

Check RS485 output to see the results.
If you want to communicate with PC computer you can consider to build simple RS232 to RS485 converter.

BOB modules

BOB-3 or BOB-4 module is used to display text on video screen. Both modules are controlled via serial interface. The only difference is that modules have different command sets.

Serial interface lines are connected to PD5 (TX) and PD4 (RX) pins. That means you must use software UART routines for communication.

$regfile = "M8DEF.DAT"
$crystal = 7372800
Open "comd.5:9600,8,n,1" For Output As #2                   BOB OSD module
print #2, "Hello world!"

Check video to see the results.

Leak sensors

Leak is indiAcated by logic 1 on PD2 for LEAK1 sensor and on PD3 for LEAK2. You must configure PD2 and PD3 ports as inputs (activation of atmega8 internal pull-up resistors is not required).

$regfile = "M8DEF.DAT"
$crystal = 7372800
Open "comd.6:9600,8,n,1" For Output As #1                   ‘RS232
Config Portd.2 = Input
Config Portd.3 = Input
   If Pind.2 = 1 Then Print #1 , "LEAK1: water"
   If Pind.3 = 1 Then Print #1 , "LEAK2: water"
   Waitms 100

Check RS232 output to see the results.

Pressure sensor

Output of pressure sensor is connected to PC3 pin which is ADC3 input. Any sensor with 4-20mA output can be used. Use internal reference voltage for ADC to read sensor output.

The following example displays current value on sensor output. Pressure/depth depends on sensor type you use. For more details how to convert current value to depth you can read Pressure Sensor article.
To see the results check RS232 port and video output of BOB-3. To use this example with BOB-4 replace {C1501 string with appropriate BOB-4 command (moves cursor to 15,1).

$regfile = "M8DEF.DAT"
$crystal = 7372800
Dim Vol1 As Single
Dim Volstr As String * 10
Const Factor = 2.56 / 1023
Const Res = 220000 + 47000
Declare Function Get_pressure_curr() As Single
Config Adc = Single , Prescaler = Auto , Reference = Internal
Open "comd.6:9600,8,n,1" For Output As #1                   ‘RS232 diagnostic output
Open "comd.5:9600,8,n,1" For Output As #2                   BOB OSD module
Print #1 , "This example displays current value from sensor output"
   Vol1 = Get_pressure_curr()
   Volstr = Fusing(vol1 , "##.#")
   Print #1 , "Pressure sensor: " ; Volstr ; "mA"
   Print #2 , "{C1501PRESSURE SENSOR:" ; Volstr ; "mA"      ‘works only for BOB3
   Waitms 500
Function Get_pressure_curr() As Single
   Const Resistor = 120
   Dim C As Word
   Dim Voltage As Single
   Dim Current As Single
   C = Getadc(3)
   Print #1 , "ADC3 (DEPTH): " ; C
   ‘for ST09
   ‘4ma = 0bar
   ‘20ma = 16bar
   Voltage = C * Factor
   Current = Voltage / Resistor
   Get_pressure_curr = Current * 1000                       ‘result in mA
End Function 

Current sensor

There are 3 headers with ADC input pins. Originally were designed to be used with ACS750 chips, but can read any analog value.
The following example reads data from ACS750 chip and converts it to current value, uses AVCC as reference voltage for ADC. Data is sent to RS232 and BOB-3 (BOB-4 needs small change).

$regfile = "M8DEF.DAT"
$crystal = 7372800
Dim V As Word
Dim Vol1 As Single
Dim Vol2 As Single
Dim Volstr As String * 10
Const Factor = 5 / 1023
Declare Function Get_current() As Single
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Open "comd.6:9600,8,n,1" For Output As #1                   ‘RS232 diagnostic output
Open "comd.5:9600,8,n,1" For Output As #2                   ‘BOB3 OSD module
Start Adc
Print #1 , ""
   Vol2 = Get_current()
   Volstr = Fusing(vol2 , "##.##" )
   Print #1 , "Current: " ; Volstr ; "A"
   Print #2 , "{C1002CURRENT: " ; Volstr ; "A" ‘output to bob3
   Wait 1
End                                                         ‘end program
Function Get_current() As Single
   Const V2a = 50 / 2.5
   ‘SL8 header (ADC0)
   V = Getadc(0)
   Print #1 , "ADC (Current): " ; V
   ‘output range from 0 to VCC
   VCC/2 = 0A
   ‘voltage on adc input
   Vol1 = Factor * V
   ‘convert to current
   ‘2.5V = 0A
   ‘0V = -50A
   ‘5V = 50A
   Vol2 = Vol1 - 2.5
   Vol2 = Vol2 * V2a
   Get_current = Vol2
End Function

Power voltage sensor

Power voltage sensor is simple voltage divider connected to PC4 pin which is ADC4 input line.

I²C bus

SDA line is connected to PB1, SCL line is connected to PB2. I²C interface do not use built-in TWI module.
Here is an example that reads heading from CMP03 digital compass. Output is on RS232.

$regfile = "M8DEF.DAT"
$crystal = 7372800
‘I2C config
Config Scl = Portb.2
Config Sda = Portb.1
Dim Cmd As String * 30
Dim Curr_heading As Integer
Dim New_heading As Integer
Dim Message As String * 30
Declare Function Get_heading() As Integer
Declare Function Get_firmware_version() As Byte
Open "comd.6:9600,8,n,1" For Output As #1                   ‘RS232 diagnostic output
Curr_heading = 400
‘main program
Print #1 , "Compass Test"
‘Initialize I2C
‘wait 3secs for compass init (could be about 1s)
Wait 3
Print #1 , "Reading CMPS firmware version…"
Print #1 , "CMPS03 FIRMWARE VERSION: " ; Get_firmware_version()
Print #1 , "Start watching compass…"
   ‘read compass
   New_heading = Get_heading()
   ‘180deg is like 1800
   New_heading = New_heading / 10
   If New_heading <> Curr_heading Then
      Curr_heading = New_heading
      Message = "COMPASS: " + Str(curr_heading)
      Print #1 , Message
   End If
   ‘read compass heading every 500ms
   Waitms 500
End                                                         ‘end program
‘Read firmware version of the compass
Function Get_firmware_version() As Byte
Local Firmware As Byte
Local Cmps_slaveid As Byte
Local Cmps_slaveid_read As Byte
   Cmps_slaveid = &HC0
   Cmps_slaveid_read = Cmps_slaveid + 1
   I2cwbyte Cmps_slaveid
   I2cwbyte 0
   I2cwbyte Cmps_slaveid_read
   I2crbyte Firmware , Nack
   Get_firmware_version = Firmware
End Function
‘read comapss heading
Function Get_heading() As Integer
Local Lob As Byte
Local Hib As Byte
Local Cmps_slaveid As Byte
Local Cmps_slaveid_read As Byte
   Cmps_slaveid = &HC0
   Cmps_slaveid_read = Cmps_slaveid + 1
   I2cwbyte Cmps_slaveid
   I2cwbyte 2
   I2cwbyte Cmps_slaveid_read
   I2crbyte Hib , Ack
   I2crbyte Lob , Nack
   Get_heading = Makeint(lob , Hib)
End Function


Data line is connected to PC5 pin.