Shop OBEX P1 Docs P2 Docs Learn Events
Radio Controlled Clock with Basic Stamp — Parallax Forums

Radio Controlled Clock with Basic Stamp

ShmuelShmuel Posts: 14
edited 2006-08-01 00:05 in BASIC Stamp
Hi,

I'm trying to make a Radio Controlled Clock such as the 15 dollar ones you can buy from Walmart or anywhere else. These clocks set themselves from the atomic clock radio signal broadcast from Boulder, CO.

Of the ICs available to do the decoding, I made the unfortunate decision to choose C-Max Groups CME8000 Bus. This product has a terrible datasheet. Though the CME8000 IC may operate differently, the bus product uses asynchronous serial transmission.

A·post on another website list the error check algorithm as

<quote>
mike50 said...
By running the CME8000-BUS demo program and tracing the serial port data, I was able to determine the CRC algorithm.

The CRC used is a 16-bit CRC using the CCITT polynomial. That is x^16 + x^12 + x^5 + 1. The initial value is 0x0000, not the 0xFFFF usually used with this algorithm. The data is fed MSB (most significant bit) first.

As an example, one of the requests sent by the demo program was the following string:

0x02 0x59 0x08 0x84 0x99 0xEA 0x21 0x03

which breaks down as:

0x02 STX
0x59 address of CME8000-BUS module
0x08 number of bytes in packet
0x84 command = RD_RX_STATE
0x99 address of sender
0xEA21 CRC
0x03 ETX

The CRC is computed over 0x59, 0x08, 0x84, 0x99
</quote>

How can this be implemented on a BS2px? Is this something I would set through the SERIN command? Do I have to write software routines to perform the asynchronous transfer? Where would I place the values as given above?

Thanks in advance. I appreciate your help as this is quite a technical and specific posting.

Shmuel

Comments

  • Philip GamblinPhilip Gamblin Posts: 202
    edited 2005-12-05 07:13
    If you have the Pbasic Editor. Open the Help section. Take a look at SERIN, SEROUT, DEBUGIN, and DEBUG. It takes some thought, but it is probably much simpler than you think.
  • SPENCESPENCE Posts: 204
    edited 2005-12-05 08:22
    Shmuel.

    I AM NOT SHOUTING. I HAVE BEEN ABLE TO READ AND TYPE ALL CAPS MUCH EASIER FOR OVER 55 YEARS.

    THE ONLY CHIP RECEIVER FOR WWVB I HAVE BEEN ABE TO GOOGLE OUT WAS THE TEMIC U4224B BUT HAVING TROUBLE TRACKING THAT ONE DOWN.

    WHAT RECEIVER AND DECODER CHIPS HAVE YOU BEEN ABLE TO FIND. URL'S ETC?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    73
    SPENCE
    K4KEP
  • ShmuelShmuel Posts: 14
    edited 2005-12-05 14:23
    Philip,
    Not doubting you but are you saying this from having done something similar with an asynchronous communication or you're just assuming?

    Spence,
    It's the CME8000-Bus from C-maxgroup. Digikey sells it.

    Shmuel
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-12-05 15:21
    Shmuel -

    The following parameters have been extracted from the CME8000-Bus data sheet:

    I/O Specifications
    • TTL interface
    • Half-duplex
    • Asynchronous
    • 9600 baud, no parity, 1 start bit, 8 data bits, 1 stop bit

    Output signal voltages (Rx and Tx): +12 VDC, -12 VDC

    Based on that information, this is indeed an ordinary RS-232 interface, and the PBASIC Commands SERIN (RS-232 Input) and SEROUT (RS-232 Output) are the appropriate commands as Philip suggested. You will need to set the baudmode appropriately, to include all of the characteristics noted in the I/O Specifications above.

    All of the information required to access this module is contained in the CME8000-Bus datasheet, as provided on the C-Maxgroup web site.

    Regards,

    Bruce Bates
  • ShmuelShmuel Posts: 14
    edited 2005-12-05 15:43
    Would you connect the CME8000-Bus to the BS2 as shown on page three of the datasheet? I.e. with the PNP transistors and Schmitt inverting trigger? Or would you connect the CME8000's Rx and Tx pins directly to the BS2 pins? If so, what would you do with the Ready pin?
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-12-05 16:25
    Schmuel -

    The Stamp is a sufficiently robust device that the interface can be direct, with only the inclusion of a 22K ohm resistor on the line which is used for the SERIN command. This can be any of the pin ports, 0-15, as all are RS-232 capable. Alternatively, if you want to "perfect" the interface, one can use any commerical line driver chip, such as the Maxim MAX-232 (or equivalent). I'm no expert on analog circuitry, so I'd prefer not to comment on the interface suggested by the data sheet, although it's probably fine to use. The MAX-232 is just easier and quicker, and is self-contained.

    The READY line will be brought to a separate pin port, again with an appropriate inline resistor, jsut for safety's sake. You will merely check (poll) this pin to check when to actually communicate with the CME8000 module. The following might represent a typical routine to do that. I have arbitraruily assigned pin port 0 for RX, pin port 1 for TX, and pin port 2 for the READY line:

    {$STAMP BS-2}
    {$PBASIC 2.5}

    'Assign Pin Ports:

    RX_pin PIN 0
    TX_pin PIN 1
    RDY_pin PIN 2

    'Assign data areas

    D1 var byte
    D2 var byte
    D3 var byte
    D4 var byte
    D5 var byte
    D6 var byte
    D7 var byte
    D8 var byte

    'Assign Constants
    Ready con 1
    NOT_Ready con 0

    baudmode con 84 'Set to 9600 baud, 8 bits, no parity, 1 stop bit, TRUE

    Input_Loop:

    If RDY_pin = NOT_Ready then go to Input_Loop

    SERIN RX_pin, baudmode, (D1, D2, D3, D4, D5, D6, D7, D8) 'Arbitrarily 8 data fields

    . . . ETC.

    Regards,

    Bruce Bates
  • SPENCESPENCE Posts: 204
    edited 2005-12-05 17:33
    Bruce.

    I don't read and understand the data sheets as well as i once did. Do any of the models/versions of the cme8000 work with out the crc?

    Just plain raw data.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    73
    spence
    k4kep
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-12-05 19:19
    Hi SPENCE -

    I can't honestly answer your question, since I only looked at the one data sheet which applies to the specific module that this gentleman is using. I have attached it for your perusal.

    Personally, I don't see the CRC calculation as anything but a small hassle, in the overall scheme of things. You only need a few PBASIC instructions to either generate a CRC or to verify one.

    Here is an excellent applications note and subroutine·by Jon Williams on just that subject, from an earlier Stamp Forum posting (below). We'll have to check with Jon to verify what I am about to say, but I believe this generates a CRC-16 (16 bits). Here is the archived message:

    - - - - - - Stamp Forum message follows - - - - -

    This subject has come up a couple times, and was recently on the Javelin
    Stamp list as well. Here's a bit of code I used in a Stamp-to-PC
    program:

    Calc_CRC:

    crc = (crc & $FF00) | (aByte ^ (crc & $FF))
    FOR idx = 0 TO 7
    ··IF (crc.BIT0 = 0) THEN
    ·· ·crc = crc >> 1
    · ELSE
    ··· crc = (crc >> 1) ^ $A001
    ENDIF

    NEXT

    RETURN

    The crc value is initialized to $0000 before looping through the bytes
    in the package, sending them one at a time to the Calc_CRC routine.
    I'll post the other demo in the file section as that algorithm was
    described and provided with a small packet and expected CRC (and yes,
    the PBASIC implementation works).

    -- Jon Williams

    - - - - - End of Stamp Forum message - - - - - -

    Please ignore the reference above·to "files area", since this archived message came from the·former Stamp Forum when it was on Yahoo Groups. Presently there is no "files area" on this Stamp Forum <sigh>.

    Regards,

    Bruce Bates
  • SPENCESPENCE Posts: 204
    edited 2005-12-05 20:03
    FOUND A WHOLE PAGE OF DOWNLOADS PERTAINING TO THAT CHIP

    http://www.c-maxgroup.com/downloads/search.php?search=CME8000

    ALSO FOUNFD THIS WHICH SEEMS TO INDICATE A SPECIAL PRESET FOR CRC


    mike50



    Joined: 29 Nov 2005
    Posts: 4


    Posted: Thu Dec 01, 2005 4:22 am Post subject:
    By running the CME8000-BUS demo program and tracing the serial port data, I was able to determine the CRC algorithm.

    The CRC used is a 16-bit CRC using the CCITT polynomial. That is x^16 + x^12 + x^5 + 1. The initial value is 0x0000, not the 0xFFFF usually used with this algorithm. The data is fed MSB (most significant bit) first.

    As an example, one of the requests sent by the demo program was the following string:

    0x02 0x59 0x08 0x84 0x99 0xEA 0x21 0x03

    which breaks down as:

    0x02 STX
    0x59 address of CME8000-BUS module
    0x08 number of bytes in packet
    0x84 command = RD_RX_STATE
    0x99 address of sender
    0xEA21 CRC
    0x03 ETX

    The CRC is computed over 0x59, 0x08, 0x84, 0x99

    Mike

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    73
    SPENCE
    K4KEP
  • ShmuelShmuel Posts: 14
    edited 2005-12-07 02:36
    Bruce,

    Thanks so much for the helpful replies. I still wondering though, where in the datasheet you see that the CME8000-Bus uses RS-232 voltages. I only see that it says TTL interface and on the first page it says 2.7 to 5.o volts.

    Obviously, TTL only would make my life easier. But my hesitance now is that if I assume it's 12/-12V and include a 22Kohm resistor, and it winds up being TTL, I could lose a good portion of the voltage over the resistor. (I didn't do the calculations but I think it wouldn't hit the 1.4V threshold). Obviously I don't want to assume it is TTL, not include a resistor, and blow the board.

    I don't have an oscilloscope and my multimeter is so basic it can't capture the peak value (which would anyway be influenced by start and stop bits), but I'll try getting the device to output·steady high values·and see if I can see anything (5 vs. 12) with my multimeter.

    Shmuel
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-12-07 04:22
    Scmuel -

    RS-232C by definition requires mark and space voltages of +12 VDC and -12 VDC. Anything other than that is not truly RS-232, regardless of whether it works or not.

    Beyond that, however, on Page 1 of the CME8000-BUS Application Note, it directly specifies +12 VDC, and -12 VDC. I have attached the applications note for your perusal.

    Regards,

    Bruce Bates
  • ShmuelShmuel Posts: 14
    edited 2006-07-31 22:19
    Has anyone found a suitable substitute to the CME8000?

    Shmuel
  • HarborHarbor Posts: 73
    edited 2006-08-01 00:05
    shmuel said...
    Has anyone found a suitable substitute to the CME8000?
    Not a direct substitute getting HF time transmissions, and I went through this search last month. Someone here found it on Digikey for me, though I hadn't spotted it myself. (Used the wrong keywords to search obviously.)

    The functional counterpart is an inexpensive GPS, like the Garmin eTrex, for hikers. I had already ordered that when I learned about the CME8000. So I·ended up with both and a plan to compare their effectiveness.

    I agree about the 'specs' on the CME being terribly difficult to read. I used to get paid for reading that sort of thing and figuring out where the author screwed up. I almost sent it back to Digikey with a note offering to·use the part only if the manufacturer paid me to·re-write the docs. Then I got stubborn.·Once I buckled down and forced the protocol analyst part of my brain to come out of retirement, I realized the designers were shooting for a multi-host networking protocol based on the comm stack we use for the Internet and ethernet. It's positively quaint in their concern for our being able to understand the packetizing scheme and so forth. Not because the design is wrong, but because we simply don't do such things in software very often these days. X.25 is just a chip for all love, and no longer·a development sub-project embedded in everything that ties more than three computers together.

    Once you cut through all that, and quit cussing them for not using a simple synchronous serial interface on two pins, you find you really don't need a development project. Their protocol is serious overkill unless you really want to use a few CME8000 units on a custom serial bus that you string through an office building to distribute redundant time signals to a building full of computers. [noparse][[/noparse]I will come out of retirement to consult for any firm considering this. The revenue ought to keep me quite comfortable until I fade away somewhere in my second century. IRIG-B lives!] But the parts you actually need for one Stamp tied to one CME are pretty trivial.

    For now, I just plan to figure out by hand the bit-level coding of a half dozen packets, including their CRC which won't change because these request packets don't involve dynamic data that I'm sending to the CME. I will put those in EEPROM as constants to be transmitted whenever I want the time from the CME. On the returning packets, my code will ignore all the protocol Smile and just extract the time data. Since you are likely to have this unit within ten meters of a single Basic Stamp (if not ten centimeters) you don't need an error-correcting scheme, let alone a CDMA networking protocol.

    In a week or two, I'll be starting my prototype of that section of my current project, and I'll compare the use of the GPS with the CME8000. I'll publish my solution and my design notes if anyone else still cares.
Sign In or Register to comment.