Shop OBEX P1 Docs P2 Docs Learn Events
Difficulty with Pocket Watch B — Parallax Forums

Difficulty with Pocket Watch B

Jeff DegeJeff Dege Posts: 85
edited 2006-03-02 16:01 in General Discussion
I'm trying to get the Pocket Watch B to work with the Javelin, and clearly there's something about the way Uarts work that I don't grasp.

The docs include sample code for the Basic Stamp II. I can run it without a problem.

I converted the code for the Javelin, and it doesn't work. The Uart.receiveByte() calls are returning 0.

Clearly something doesn't work the way I'd expect it to work.

But what?

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-03-01 13:57
    First, you do not need to set uart pins directly.
    Secondly, you need to convert received binary values into readable ascii values
    before appending to the stringbuffer.
    The Format class allows easy appending and converting.
    Try the attached class.

    regards peter
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-03-01 14:07
    I noticed you mistakenly·changed the fields order as used in the basic stamp program.
    I corrected that in the attachement.

    regards peter
  • Jeff DegeJeff Dege Posts: 85
    edited 2006-03-01 15:46
    I'm used to using string concatenation to build strings in Java - which I'm not using on the Javelin because of the lack of garbage collection. I've not used StringBuffers directly very often. I'd not seen the stamp.util.text.* classes - they do provide for a much cleaner way of building formatted strings.

    But I'd not been worried about the formatting of the StringBuffer. I'd been looking at the values placed in the ss, mm, etc. vars, in the debugger, and they'd not been set to anything like reasonable values. In the test program I posted, the receiveByte() call would set each of them to zero. If the output StringBuffer had been formatted correctly, I'd still have had a program displaying incorrect values.

    I'm not at home - I can't try out your code, yet. But the only difference in setup I can see is that you are constructing the Uarts during the static initialization phase, and I'm doing it at the beginning of main(). And that shouldn't make any difference.
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-03-01 16:09
    You also outputted the wrong bytesequence for SetAlarmCommand (a $00 where a $0F
    is specified in BS2 program), maybe that is why it didn't work.
    Try the class and see if it works.
    regards peter
    ·
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-03-01 17:19
  • Jeff DegeJeff Dege Posts: 85
    edited 2006-03-01 19:12
    No, that's not it.

    That's simply the seconds value. In the Basic Stamp code, I was setting the time to 97-06-03 06:30:00 and the alarm to 97-06-03 06:30:15. In the Javelin code, I was setting both time and alarm to 97-06-03 06:30:00. It's simply a cut-and-paste error, and could have nothing to do with why I'm not getting meaningful values out of Uart.receiveByte().

    Ah, well.

    Let it lie until I can get home and play with it.
  • Jeff DegeJeff Dege Posts: 85
    edited 2006-03-02 00:52
    OK.

    I DL'ed your code, and tried it out.

    Nada.

    So I tried out the Basic Stamp, again. (I had both Stamps plugged into different spots on the breadboard - I just moved the Pocket Watch and my programming cable.) And it worked fine.

    So I powered down, pulled the Basic Stamp and plugged the Javelin in its place. And it worked fine.

    For the life of me, I can see no functional difference between the circuit I'd laid out at one end of the breadboard and the circuit I'd laid out at the other. Yet the Javelin+Pocket Watch worked connected to one and not to the other.

    I'm thinking I might have a dead tie point on the breadboard.
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-03-02 02:11
    Try Uart.Inverted for the uarts and see if that works.
    regards peter
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-03-02 02:16
    To be clear, you have ONE circuit,
    and that works with the BS2 but not with the javelin, right?
    regards peter
  • Jeff DegeJeff Dege Posts: 85
    edited 2006-03-02 16:01
    I had plugged both the BS2 and the Javelin into different spots on the breadboard, and built identical circuits around them. I'd plug the Pocket Watch into whichever of the two circuits I was testing with at the moment.

    And the circuit built around the BS2 worked and the circuit built around the Javelin did not.

    I'm just getting started with the Javelin, so when it didn't work I assumed I'd done something wrong in the programming.

    Yesterday, I put the Javelin in the circuit that I had built around the BS2, and there it worked fine. Clearly there was some difference between the two circuits, though looking at them they seemed to be identical.

    In any case, the problem wasn't the code, it was the circuit.
Sign In or Register to comment.