ntpd and gps pps confusion / RS232C, serial, TTL serial - Page 1
Forum section: electronics / general

author: tkamiya
author_rank: Super Contributor
timestamp: September 25, 2020, 07:45:47 am
content: I believe this question is best fit in metrology section, although one can argue computing section is better.... I see this as time-keeping and GPSDO, so here goes.If one is connecting GPS to a host running ntpd and gpsd, it is said that RISING EDGE of the pps should indicate beginning of a new second. From my GPS board, TXD and RXD must go into a level converter board, then to a Com1 port on the computer. That means TTL level 1 (5V) gets converted to RS232C MARK (-12V ish). Voltage for TTL and RS232C are backwards.PPS typically connects to PIN 1 which is CD (Carrier Detect) on 9 pin connectors. Now, If I do the same treatment as above, rising edge of the GPS output will now become a falling edge. What do I do here? Do I maintain the rising edge by inverting, then level converting OR do I just convert the signal level?To make things more complicated, most serial ports on modern computers do not do +/-12V. It's TTL level but it works with regular serial ports. I've used old modem, so I can see they are compatible to a degree. (logic wise, not the signal level)Now I have 3 different signal method and voltage combination.Have anyone thought through this and figured it out?

author: thinkfat
author_rank: Unknown
timestamp: September 25, 2020, 08:05:31 am
content: You need to run the 1PPS output through an inverter first (like, 74HCT04 or 74HCT14), then into the RS232 level converter (MAX3232, I guess).

author: guenthert
author_rank: Frequent Contributor
timestamp: September 25, 2020, 05:38:24 pm
content: Quote from: tkamiya on September 25, 2020, 07:45:47 amThe manual of your GPS receiver should state on which edge the new seconds starts. If the output is open collector / open drain TTL, then I'd expect the falling edge. The jitter on the other edge will be considerably worse (but perhaps not bad enough to matter in the context of NTP).Quote from: tkamiya on September 25, 2020, 07:45:47 amNot sure, if that is typically, but yes, Linux' PPS driver expects it there by default when using a RS-232 device.Quote from: tkamiya on September 25, 2020, 07:45:47 amRegardless of raising or falling, only theleadingedge is relevant.Quote from: tkamiya on September 25, 2020, 07:45:47 amI'd say it's wrong and potentially harmful to say it's TTL level. It might not be +/-12V, but it won't be TTL level (voltages in the range of +/-3V are undefined in the RS232 standard and shouldn't be used). It might be around +/-5V, which TTL devices wouldn't be keen on receiving.Quote from: tkamiya on September 25, 2020, 07:45:47 amYou might also want to consider instead of feeding the TTL<->RS232 level shifted (slow) signal to a PC, feeding the TTL<->3V level shifted signal to a GPPIN on a Raspberry Pi (or other embedded computer) for lower latency.

author: tkamiya
author_rank: Super Contributor
timestamp: September 25, 2020, 05:45:05 pm
content: Thanks! Yes, that's true: LEADING edge, not necessary a rising edge is valid.My concern really is, how is this leading edge perceived by the relieving end. I've read some more... Apparently, logic level for TXD and RXD are reversed: meaning -V for mark and +V for space. But signal pins including DCD are not. That makes my whole question null and void.I should have researched more, but to be honest, there are so many implementation and adaptation of serial RS232C, I could never be sure without really thinking it through and measuring. I was thoroughly confused last night.By the way.... this is not a RasPi project. Host is a intel based low power server running Linux. I purposely made it this way so that swapping it out is easy. I bought 5 of these Dell T-20 barebone units when Dell had them on sale. I have two units as hot stand-by for various uses. It's T-20 with regular Intel CPU (G3220?), not the Xeons. Although not as low as RasPi, power consumptions are really low like 35 watts. (I use a small SSD)

author: notfaded1
author_rank: Frequent Contributor
timestamp: September 25, 2020, 07:04:00 pm
content: Something like this might help:https://www.sparkfun.com/products/449The smallest and easiest to use serial conversion circuit on the market! This board has one purpose in life - to convert RS232 to TTL and vice versa (TX and RX). This will allow a microcontroller to communicate with a computer. Shifter SMD is powered from the target application and can run at any voltage! That's right - power the board at 5V and the unit will convert RS232 to 5V TTL. Power the board at 2.8V and the Shifter board will convert RS232 to 2.8V CMOS TTL. Includes two indicator LEDs for TX and RX. Runs from 300bps up to 115200bps.Bill

author: syau
author_rank: Frequent Contributor
timestamp: September 26, 2020, 08:22:24 am
content: Never an issue as on the receiver side, same conversion happen again, the -ve RS232 will be convert to +ve TTL (or 3.3v logic high) before get process by the comm chip.

author: thinkfat
author_rank: Unknown
timestamp: September 26, 2020, 03:43:08 pm
content: Quote from: tkamiya on September 25, 2020, 05:45:05 pmTTL is not compatible with RS232 signaling levels, not for data, not for control signals. 0V is simply not valid, not for data, not for control. Typical converters have inverting outputs (see the MAX3232 data sheet!), if you want to feed a TTL 1PPS into a DCD input, you need a RS232 line driver and if you want to use one of the usual converter boards (e.g.https://www.pollin.de/p/rs232-ttl-wandler-mit-max3232-810358) , you need an additional inverter on the TTL side.

author: David Hess
author_rank: Super Contributor
timestamp: September 26, 2020, 04:58:04 pm
content: Quote from: tkamiya on September 25, 2020, 07:45:47 amI have dealt with this many times and it is easy; ALL RS-232 LEVEL SHIFTERS ARE INVERTING! ALWAYS! If the outputs from the GPS are logic level and not inverted, THEN THEY ARE NOT FUCKING RS-232! Sometimes companies deceptively write "RS-232 compatible" in their documentation.My solution was to build a discrete non-inverting RS-232 level shifter, but most people would do what thinkfat suggests by adding an inverter before the level shifter.

author: tkamiya
author_rank: Super Contributor
timestamp: September 27, 2020, 04:25:19 pm
content: Got this to work. GPS is CMOS serial.... not even TTL level but reverse logic. TXD and RXD went into level converter/inverter and into RS232C port. Now they are talking to each other. I had one of those all-in-one module already built, so just used that.PPS was different. Naturally, it's a positive going signal. I had to connect directly to RS232C, pin 1 (DCD). I guess voltage was enough to trigger PPS input for kernel NTP, which I'm surprised... I measured 2.5V high.I always have all kinds of issues with serial. It's a non-standard standard.