ncguk
Posts: 27
Joined: Fri Mar 07, 2014 10:04 pm

Wiring up and reading 1Hz square wave output from RTC

Wed Jan 14, 2015 12:08 pm

I've scoured Google for a solution to this to no avail.

I'm trying to hook up the 1Hz square wave output of a DS3231 RTC breakout board to GPIO18 (pin 12) of the Pi. As per information on the web I've turned on the wave output (theoretically, using an Arduino sketch) and added a resistor between SQW and VCC. "bcm2708.pps_gpio_pin=18" has been added to /boot/cmdline.txt, "pps-gpio" has been added to /etc/modules and /pps0 shows up in /dev. However, when I run "sudo ppstest /dev/pps0" the only output I receive is "time_pps_fetch() error -1 (Connection timed out)".

I suspect I'm missing something very simple or I've got something drastically wrong. Can anyone shove me in the right direction? Thanks.

User avatar
DougieLawson
Posts: 36576
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Wiring up and reading 1Hz square wave output from RTC

Wed Jan 14, 2015 12:18 pm

https://github.com/raspberrypi/linux/pull/717

Have you missed adding bcm2708.pps_gpio_enable=1 to cmdline?
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

ncguk
Posts: 27
Joined: Fri Mar 07, 2014 10:04 pm

Re: Wiring up and reading 1Hz square wave output from RTC

Wed Jan 14, 2015 1:43 pm

DougieLawson wrote:https://github.com/raspberrypi/linux/pull/717

Have you missed adding bcm2708.pps_gpio_enable=1 to cmdline?
That syntax was changed by the developers at the last minute to what I quote above, a way which has worked successfully for me with GPS 1PPS output, so it's nothing that simple (if only it were).

User avatar
DougieLawson
Posts: 36576
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Wiring up and reading 1Hz square wave output from RTC

Wed Jan 14, 2015 1:54 pm

Do you get any PPS messages in the kernel message log (dmesg command)?

There's a good article on doing this stuff with a GPS receiver here: http://www.satsignal.eu/ntp/Raspberry-Pi-NTP.html
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

ncguk
Posts: 27
Joined: Fri Mar 07, 2014 10:04 pm

Re: Wiring up and reading 1Hz square wave output from RTC

Wed Jan 14, 2015 2:24 pm

DougieLawson wrote:Do you get any PPS messages in the kernel message log (dmesg command)?
dmesg | grep pps shows:

Code: Select all

[    0.000000] Kernel command line: dma.dmachans=0x7f35 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708.boardrev=0x12 bcm2708.serial=0xcd587ca6 smsc95xx.macaddr=B8:27:EB:58:7C:A6 bcm2708_fb.fbswap=1 bcm2708.disk_led_gpio=47 bcm2708.disk_led_active_low=0 sdhci-bcm2708.emmc_clock_freq=250000000 vc_mem.mem_base=0xec00000 vc_mem.mem_size=0x10000000  dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait bcm2708.pps_gpio_pin=18
[    0.029352] bcm2708: GPIO 18 setup as pps-gpio device
[   10.829070] pps_core: LinuxPPS API ver. 1 registered
[   10.830658] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <[email protected]>
[   10.837862] pps pps0: new PPS source pps-gpio.18
[   10.839637] pps pps0: Registered IRQ 188 as PPS source
There's a good article on doing this stuff with a GPS receiver here: http://www.satsignal.eu/ntp/Raspberry-Pi-NTP.html
Thanks for that. I've referred to that page many times while playing about with GPS/PPS and I can get that sort of set-up to work pretty easily. What I'm trying to do the the RTC square wave output is really for tinkering purposes only, and possibly to compare the two.

ncguk
Posts: 27
Joined: Fri Mar 07, 2014 10:04 pm

Re: Wiring up and reading 1Hz square wave output from RTC

Wed Jan 14, 2015 7:50 pm

Never mind – the cause of the problem was operator error. Though I believed I had enable the square wave output in the DS3231 I in fact hadn't.

Using this library: https://github.com/radekw/Arduino/tree/ ... /Chronodot

And this Arduino sketch:

Code: Select all

#include <Wire.h>
#include <Chronodot.h>

// create global chronodot instance
Chronodot chronodot = Chronodot();

void setup() {
  Serial.begin(9600);
}

void loop() {
chronodot.setSQW(1);
}
I was able to correctly enable the square wave output at 1Hz. I have no doubt there is a way to do this with Python on the Pi but in this instance the Arduino saved the day. Well, the second.

Return to “Interfacing (DSI, CSI, I2C, etc.)”