time-nuts@lists.febo.com

Discussion of precise time and frequency measurement

View all threads

TruePosition on an Arduino

BH
Ben Hall
Sat, May 13, 2017 7:15 PM

Good afternoon all,

I've not had any luck getting the Arduino source code and libraries from
the PackRat guys.  Another listmember reported to me this morning that
he'd tried loading the hex file, but had no luck getting it to work.

I've been wanting to dive more into Arduino...so I figured I'd write my
own interface program.  The last software class I took was FORTRAN...and
then I did a little BASIC, so this C code stuff is all new to me and
it's been a real learning experience.

And I'm sure that a real program would probably look at my code and just
shake his or her head.  :(

Thankfully...I've found some really good example code on the web.  The
serial input engine is lifted from here pretty much intact:

http://jhaskellsblog.blogspot.com/2011/05/serial-comm-fundamentals-on-arduino.html

And is working perfectly as best I can tell.  The serial port on the
TruePosition is going right into the serial port (pins 1 and 2) on the
Uno thru a resistor level-shifter on the TX port (because the arduino is
5 volts...the trueposition is 3.3v...but the 3.3V TX is being read by
the 5V arduino w/o any problems.)  Using the hardware port is non-ideal,
as I've got to remove the jumpers to the TruePosition in order to upload
code to the Arduino, which also means that I can't use the built-in
Serial Monitor to view what my code is doing.

Thankfully...the software serial library allows you to create serial
ports on other pins...so while the True Position is on the hardware
serial, pin 11 is providing the debugging output.

(I may flip this around where SoftwareSerial is talking to the
TruePositon, and the hardware serial pins get freed up)

The parsing engine is also based on JHaskell's work here:

http://jhaskellsblog.blogspot.com/2011/06/

But is heavily modified with if-then-else string compares as the parsing
depends on what sort of message has been received.  This took a bit of
brain work, as I couldn't get the compare function to work right at first.

Next up...I've got to figure out how to convert GPS seconds into date
and time...then I'll move along to the display and a rudimentary menu
system as I think one part will be time/date/status...and another page
will be GPS satellites...

thanks much and 73,
ben, kd5byb

Good afternoon all, I've not had any luck getting the Arduino source code and libraries from the PackRat guys. Another listmember reported to me this morning that he'd tried loading the hex file, but had no luck getting it to work. I've been wanting to dive more into Arduino...so I figured I'd write my own interface program. The last software class I took was FORTRAN...and then I did a little BASIC, so this C code stuff is all new to me and it's been a real learning experience. And I'm sure that a real program would probably look at my code and just shake his or her head. :( Thankfully...I've found some really good example code on the web. The serial input engine is lifted from here pretty much intact: <http://jhaskellsblog.blogspot.com/2011/05/serial-comm-fundamentals-on-arduino.html> And is working perfectly as best I can tell. The serial port on the TruePosition is going right into the serial port (pins 1 and 2) on the Uno thru a resistor level-shifter on the TX port (because the arduino is 5 volts...the trueposition is 3.3v...but the 3.3V TX is being read by the 5V arduino w/o any problems.) Using the hardware port is non-ideal, as I've got to remove the jumpers to the TruePosition in order to upload code to the Arduino, which also means that I can't use the built-in Serial Monitor to view what my code is doing. Thankfully...the software serial library allows you to create serial ports on other pins...so while the True Position is on the hardware serial, pin 11 is providing the debugging output. (I may flip this around where SoftwareSerial is talking to the TruePositon, and the hardware serial pins get freed up) The parsing engine is also based on JHaskell's work here: <http://jhaskellsblog.blogspot.com/2011/06/> But is heavily modified with if-then-else string compares as the parsing depends on what sort of message has been received. This took a bit of brain work, as I couldn't get the compare function to work right at first. Next up...I've got to figure out how to convert GPS seconds into date and time...then I'll move along to the display and a rudimentary menu system as I think one part will be time/date/status...and another page will be GPS satellites... thanks much and 73, ben, kd5byb
JH
Jim Harman
Sat, May 13, 2017 10:19 PM

On Sat, May 13, 2017 at 3:15 PM, Ben Hall kd5byb@gmail.com wrote:

I've been wanting to dive more into Arduino...so I figured I'd write my
own interface program.  The last software class I took was FORTRAN...and
then I did a little BASIC, so this C code stuff is all new to me and it's
been a real learning experience.

I have done quite a lot of time-related work on the Arduino and here are
some suggestions:

-- Use the Arduino Leonardo or Micro board rather than the Uno. These use
the 32u4 processor rather than the Uno's 328p. The 32u4 has integrated USB
for the programming port, freeing up the hardware serial port to
communicate with a GPS without resorting to resource-intensive bit-banging
or interfering with the programming port. I prefer the Micro because its
pins are on 0.1" centers, making it compatible with a solderless breadboard.

-- For NMEA communication, use Mikal Hart's TinyGPS++ library, available at
http://arduiniana.org/libraries/tinygpsplus/
This handles all the parsing of both standard and non-standard NMEA
messages, You can use this in conjunction with the standard Time library to
convert GPS time to a unix-like date and time structure.

Contact me off-list if you want code examples.

--

--Jim Harman

On Sat, May 13, 2017 at 3:15 PM, Ben Hall <kd5byb@gmail.com> wrote: > I've been wanting to dive more into Arduino...so I figured I'd write my > own interface program. The last software class I took was FORTRAN...and > then I did a little BASIC, so this C code stuff is all new to me and it's > been a real learning experience. > I have done quite a lot of time-related work on the Arduino and here are some suggestions: -- Use the Arduino Leonardo or Micro board rather than the Uno. These use the 32u4 processor rather than the Uno's 328p. The 32u4 has integrated USB for the programming port, freeing up the hardware serial port to communicate with a GPS without resorting to resource-intensive bit-banging or interfering with the programming port. I prefer the Micro because its pins are on 0.1" centers, making it compatible with a solderless breadboard. -- For NMEA communication, use Mikal Hart's TinyGPS++ library, available at http://arduiniana.org/libraries/tinygpsplus/ This handles all the parsing of both standard and non-standard NMEA messages, You can use this in conjunction with the standard Time library to convert GPS time to a unix-like date and time structure. Contact me off-list if you want code examples. -- --Jim Harman
BH
Ben Hall
Sun, May 14, 2017 12:20 AM

Hi Jim and list,

On 5/13/2017 5:19 PM, Jim Harman wrote:

I have done quite a lot of time-related work on the Arduino and here are
some suggestions:

-- Use the Arduino Leonardo or Micro board rather than the Uno. These use
the 32u4 processor rather than the Uno's 328p. The 32u4 has integrated USB

I will look more into this...the Micro is very interesting as being a
module rather than a board like the Uno, it would be more cost-effective
to build the Micro into a project versus the Uno.

I assume that the USB programming port is also the serial.print output
port to the serial monitor window?  That seems to be the case, as the
technical description says:

"Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL
serial data using theATmega32U4 hardware serial capability. Note that on
the Leonardo, the Serial class refers to USB (CDC) communication; for
TTL serial on pins 0 and 1, use the Serial1 class."

-- For NMEA communication, use Mikal Hart's TinyGPS++ library, available at
http://arduiniana.org/libraries/tinygpsplus/

Thank you for the link to this library.  The TruePosition units use
their own communication method rather than NMEA, but the ability to
convert GPS seconds into date/time is very interesting and I will look
into this more.  :)

thanks much,
ben

Hi Jim and list, On 5/13/2017 5:19 PM, Jim Harman wrote: > I have done quite a lot of time-related work on the Arduino and here are > some suggestions: > > -- Use the Arduino Leonardo or Micro board rather than the Uno. These use > the 32u4 processor rather than the Uno's 328p. The 32u4 has integrated USB I will look more into this...the Micro is very interesting as being a module rather than a board like the Uno, it would be more cost-effective to build the Micro into a project versus the Uno. I assume that the USB programming port is also the serial.print output port to the serial monitor window? That seems to be the case, as the technical description says: "Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data using theATmega32U4 hardware serial capability. Note that on the Leonardo, the Serial class refers to USB (CDC) communication; for TTL serial on pins 0 and 1, use the Serial1 class." > -- For NMEA communication, use Mikal Hart's TinyGPS++ library, available at > http://arduiniana.org/libraries/tinygpsplus/ Thank you for the link to this library. The TruePosition units use their own communication method rather than NMEA, but the ability to convert GPS seconds into date/time is very interesting and I will look into this more. :) thanks much, ben
J
jimlux
Sun, May 14, 2017 1:05 AM

On 5/13/17 5:20 PM, Ben Hall wrote:

Hi Jim and list,

On 5/13/2017 5:19 PM, Jim Harman wrote:

I have done quite a lot of time-related work on the Arduino and here are
some suggestions:

-- Use the Arduino Leonardo or Micro board rather than the Uno. These use
the 32u4 processor rather than the Uno's 328p. The 32u4 has integrated
USB

I will look more into this...the Micro is very interesting as being a
module rather than a board like the Uno, it would be more cost-effective
to build the Micro into a project versus the Uno.

I'm a huge fan of the Teensy 3.x series from pjrc. They are Arduino IDE
compatible, run a LOT faster, and are available with pins on 0.1"
centers for protoboards or EZ-hooks.  Hardware UARTs, 2 16 bit ADCs with
differential inputs that can sample together, DMA buffered serial (which
is transparent to you, the user.. you just use the serial class..)

I assume that the USB programming port is also the serial.print output
port to the serial monitor window?  That seems to be the case, as the
technical description says:

Yes..

"Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL
serial data using theATmega32U4 hardware serial capability. Note that on
the Leonardo, the Serial class refers to USB (CDC) communication; for
TTL serial on pins 0 and 1, use the Serial1 class."

Same on the Teensy. There's typically libraries off the shelf for
hardware UART, bit banging UARTs, etc.

On 5/13/17 5:20 PM, Ben Hall wrote: > Hi Jim and list, > > On 5/13/2017 5:19 PM, Jim Harman wrote: >> I have done quite a lot of time-related work on the Arduino and here are >> some suggestions: >> >> -- Use the Arduino Leonardo or Micro board rather than the Uno. These use >> the 32u4 processor rather than the Uno's 328p. The 32u4 has integrated >> USB > > I will look more into this...the Micro is very interesting as being a > module rather than a board like the Uno, it would be more cost-effective > to build the Micro into a project versus the Uno. I'm a huge fan of the Teensy 3.x series from pjrc. They are Arduino IDE compatible, run a LOT faster, and are available with pins on 0.1" centers for protoboards or EZ-hooks. Hardware UARTs, 2 16 bit ADCs with differential inputs that can sample together, DMA buffered serial (which is transparent to you, the user.. you just use the serial class..) > > I assume that the USB programming port is also the serial.print output > port to the serial monitor window? That seems to be the case, as the > technical description says: Yes.. > > "Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL > serial data using theATmega32U4 hardware serial capability. Note that on > the Leonardo, the Serial class refers to USB (CDC) communication; for > TTL serial on pins 0 and 1, use the Serial1 class." Same on the Teensy. There's typically libraries off the shelf for hardware UART, bit banging UARTs, etc. >