Go Down

Topic: Asynchronous SeaTalk (Read 20 times) previous topic - next topic

TobyMay

Asynchronous SeaTalk

Hope I've posted in the right place.
Last Monday somebody told me about the Arduino.  By the w.end  had a Relay shield driving motors in response to switches.  Now I'm loosing what hair I have left.

Big project, build a modular control system for a 40' sailing yacht (so that a high level quadriplegic can sail it).
Current step, replicate the PIC based system that controls her existing 20' boat (hence switches and motors).  Built by a guy in Canada some years ago, don't have very much info.
Current problem, getting a Mega to talk to a Raymarine ST4000+ autopilot.

The ST4000+ talks to the world over SeaTalk (see http://www.thomasknauf.de/seatalk.htm).  SeaTalk is a Raymarine proprietary bus. 
11 bits are transmitted for each character:
  1  Start bit (0V)
  8  Data Bits
  1  Command bit
  1  Stop bit (+12V)

Where I am at the moment is reading SeaTalk on Serial 3 and then sending it to Serial Monitor over the USB.  It looks like rubbish. What I want to know is how to set the serial port to 11 bits?  Is there a command or procedure?   How much control can be had over how the serial ports work?

In the Thomas Knauf article there code in C with the line:

_outb(0x3B, PORT+3); /*LCR Stick Parity to 0, Enable Parity, 1 Stop bit, 8 bits/char */

Does Arduino C++ have an equivalent command?

Thanks

Toby

sy kristina

As far as I remember, the Raymarine plug can comminucate on SeaTalk or NMEA. At least on the st1000 tiller pilots.

TobyMay

Kristina

Err...yes, the ST4000+ has NMEA0183. 

Getting the SeaTalk working on this is a stepping stone to getting access to another set up (S1 tiller pilot, C80, ST60 instruments) on another boat.  I want to be able to access the SeaTalk bus, read messages and send messages.  I eventually want to be able to plug any manufacturers equipment into a boat control computer.  Got to start somewhere.

So, how do I set up the serial port?

Toby

Nick Gammon

So far what you have described is absolutely standard RS232 (async serial) communications with 9 data bits (you don't count the start and stop bit).

And from the Atmega spec on page 180 it says:

Code: [Select]
A serial frame is defined to be one character of data bits with synchronization bits (start and stop bits),
and optionally a parity bit for error checking.

The USART accepts all 30 combinations of the following as valid frame formats:

• 1 start bit
• 5, 6, 7, 8, or 9 data bits
• no, even or odd parity bit
• 1 or 2 stop bits


So, you want to configure it for 9 data bits, no parity, and 1 stop bit (and of course the right baud rate).

I don't have a SeaTalk to test it with, so how about showing your test code and we'll take it from there?

TobyMay

Nick

Code is below.

Data sheet I have (2549M-AVR-09/10), "8-Bit AVR Microcontroller with...." is talking about PWM on page 180, so I guess its not the one you are talking about.  Page 215/216 looks like what your talking about but I don't have a clue how to write this into a sketch.


Code: [Select]
/*
  HLOR / Toby May
  Experimental stuff with Arduino Mega and home made hardware interface to SeaTalk.
  Rx only. 
  I.Face is a pair of resistors as a voltage dropper.
  Receives on serial port 3, sends to the main serial (Serial 0) and then to Monitor on a laptop.
  This example for Arduino Mega
  WORK IN PROGRESS - may not work!!!!!
*/

char not_receiver_buf,receiver_buf;

void setup()                                        // initialise both serial ports
  {
    Serial.begin(9600);   
    Serial3.begin(4800);
  }

void loop()
  {                                                 // Continuous data processing loop 
  if((Serial3.available()) > 0)                     // LSR New SeaTalk Data received ?
     {
        receiver_buf=Serial3.read();                // RBR Read SeaTalk Data Byte
        not_receiver_buf=~receiver_buf;             // Invert received character...
        Serial.println(not_receiver_buf, HEX);      // ...and prints it out. 
     }
  }

Go Up