Quantcast
Channel: Wicked Device Support - Latest posts
Viewing all articles
Browse latest Browse all 651

How best to send RTC time info to DUE board?

$
0
0

Interesting question! Generally speaking it sounds like you want to have to the Due be a master to the Angular Clock board acting as a proxy to the RTC. The easiest way to do that would be to have a serial port on the Due hooked up to a serial on the Angular Clock. It would be even easier if the I2C pins were broken out to header pins, as then you could talk directly to the RTC, but no such luck I'm afraid.

I don't think you can hook the Due's USB to the Angular Clock USB because the Due doesn't have a native USB host port. I could be wrong of course, I'm not super well-versed in the Due. So what I would probably do is write a bit of software for the Angular Clock that uses SoftwareSerial on two pins of your choosing. I wouldn't push too hard on baud rate with SoftwareSerial; 4800 would be an OK choice I think.

Hook up the pin you choose for the SoftwareSerial RX to the TX pin of a Due Hardware Serial port, hook up the pin you choose for the SoftwareSerial TX to the RX pin of the Due Hardware Serial port, and make sure you connect GND on the Angular Clock to GND on the Due, and they should be able to talk back and forth. You probably also want to connect 5V power from the Due to the Angular Clock board, and you can do that through the 6-pin ICSP header (top-most, right-most pin); GND is also on this header (bottom-most, right-most pin) if you wanted to separate "power" signals from "data" signals.

Assuming you're not wanting to drive panel meters, the easiest pins to commandeer for your SoftwareSerial interface are on the 6-pin METERS header. Top (closest to the rotary encoder) to bottom (closest to the 16MHz crystal) these pins (on the left side of the 6-pin header) are:

  • PD5 (top-left) (arduino digital 5)
  • PD6 (middle-left) (arduino digital 6)
  • PB1 (bottom-left) (arduino digital 9)

The 3 pins on the right side of that connector are all GND pins. If you do want to keep the panel meters functioning, the 5x2 header location in the middle of the board brings out all the unused pins from the microcontroller, and you can use this reference to map the "PXn" designations to "arduino digital" designations).

You can probably just modify the stock software for Angular Clock to suit your purposes. Lets say you want to use Arduino Digital 5 for Software Serial RX, and Arduino Digital 6 for Software Serial TX. You'd have to add a SoftwareSerial object to the code (e.g. at this line) like so:

#include <SoftwareSerial.h>
SoftwareSerial mySerial(5, 6); // RX, TX

In setup, around here, you'd need to add code that looks like this:

mySerial.begin(4800);

Then you'd add some code to handle received messages from the Due in loop around here (after tm gets set). Up to you how sophisticated this bit is, but it could be as dumb as, anytime a character is received respond with the time, which would look something like this:

  if (mySerial.available()){
    mySerial.read(); // consume the input

    // respond in whatever format you prefer, 
    // the below is just a "CSV" response of the time
    mySerial.print(tm.Hour);
    mySerial.print(",");
    mySerial.print(tm.Minute);
    mySerial.print(",");
    mySerial.print(tm.Second);
    mySerial.println();
  }

You have to "invent" the format and protocol between the Due and the Angular Clock. The example I give here is just CSV of the hour, minute, and second with a new line termination. There's more available if you want to report it, namely: tm.Year, tm.Month, tm.Day, tm.WDay.

Bear in mind that on the Due side, you need to process the response from the Angular Clock. Hope that helps, let me know if anything needs clarification!


Viewing all articles
Browse latest Browse all 651

Trending Articles