KVHC100 Compass NMEA to Arduino

OK, I’m a bit of a beginner here so go easy …

I have a fluxgate compass that puts out the vehicle heading in NMEA form (which, I think, is serial) at 1 Hz continuous at 4800 Baud. The sentence output every sec looks like: $HCHDM, abc.d,M*

This message is sent through two wires Data Out (0-5 V) and Ground (there is also a data in and a second data out that goes 5-0 V but I don’t think I need them).

How do I connect this to the Arduino? Can I use the serial TX/RX pins? If so, then what? How do I have the arduino interpret the 0-5V pulses and give me a number (heading) that I can use to provide direction to the vehicle?

I guess I am fuzzy on how the TX/RX pins work and what software/library/? would be used in a sketch to convert the in-signal to a heading variable that I can mess with.

Any help/suggestion/guidance would be most gratefully received.

David

How do I connect this to the Arduino? Can I use the serial TX/RX pins? If so, then what? How do I have the arduino interpret the 0-5V pulses and give me a number (heading) that I can use to provide direction to the vehicle?

You could indeed connect ground to ground and Data out to RX. You might want to look at using NewSoftSerial instead (assuming you don't have an Arduino with multiple hardware serial ports). You'll still need to connect grounds, but data out will have to go to a different pin - whatever you've designated for the soft serial port RX. That way you can read from the compass on the software port and use the hardware one for debugging. As a first step, just read from the compass and send whatever it provides out using Serial commands & view it on the IDE's serial monitor. Worry about parsing the heading out of the NMEA string once you have the first piece working.

You could indeed connect ground to ground and Data out to RX.

...but you may want to check the voltage levels on the serial interface first. Do you have an electrical spec for the serial interface?

Wild,

Many thanks, getting to see the data on the Arduino IDE serial monitor sounds like a great idea. I am using a UNO board.

I need to go away and read up on this, but for encouragement, I'd love to see some data on the serial monitor (I can already see it on a terminal emulator program)

Stupid question #1: Do I need to create a sketch that sets up the communication? Something that involves void setup() { Serial.begin(4800);// setup serial }

void loop() { Serial.println(somethinggoeshere); delay(1000);

Stupid Question #2: I understand the point of the softserial suggestion -- I can use some other pin as the input. But why? Is it because using the TX/RX pins somehow disables the usb connection?

AWOL:

The compass puts out either TTL level RS232 0-5V or, I can use the inverted TTL level RS232 5-0 V

Is this the right input for the Arduino?

Thanks!

David

Don't think I've ever seen RS232 that had only positive swings. Do you have a reference for the spec?

AWOL,

I thinkl its legit. The manual says (I am quoting here): "The RS232-in (RXD) input can accept either true RS232 levels or 0 to +5 V in a standard ASCII format. The TXD provides output data at 0 to +5 V levels. We have found that these levels are directly compatible with most PC and data terminals ... "

I can see the output on a terminal so ... it seems ok.

Sorry if this is outside the bounds of project feasibily but AWOL may be right about 0 to 5 V not . Maybe this compass isn't going to work (directly) with Arduino. I have the TX of the compass wired to the RX pin and the on-board Rx Tx led's are flashing so I think it is seeing a signal from the compass but the serial monitor is showing gobellygook: I get this: +½Ý?£§e«?åë

When I run this:

byte aa; void setup() { Serial.begin(4800); // the module runs at 4800 bps, not 9600! }

void loop() { if (Serial.available()>0) // if there is data coming into the serial line { aa = Serial.read(); // get the byte of data Serial.print(aa, BYTE); // send it to the serial monitor } }

How do I make the 0 to 5 V look more like rs232?

Make sure you have the serial receiver set to 4800 baud too - may be the cause of the garbage.

You don't want rs232 unless you've got external hardware like a max232 converter. RS232 has a logical 1 as a negative voltage, and a 0 as a positive voltage. What you really want is TTL levels. If you can use software serial, a line inversion can be taken care of by the software.

The compass puts out either TTL level RS232 0-5V or, I can use the inverted TTL level RS232 5-0 V

Assuming the baud rate is right, trying the inverted TTL output might be worth a try too.