Shop OBEX P1 Docs P2 Docs Learn Events
SX/B Help example on 3x5 matrix keypad - coding to SEROUT — Parallax Forums

SX/B Help example on 3x5 matrix keypad - coding to SEROUT

T&E EngineerT&E Engineer Posts: 1,396
edited 2007-04-01 16:50 in General Discussion
I have taken the SX/B Help file on the 4x4 keypad and have a working version of it that uses an old Radio Shack 3x5 keypad. When a key is pressed it displays the digit on the 7 segment LED display. All of this was done on my Professional Development board and done fairly easily.

However, I have modified it to TX the character code out (SEROUT) to another SX28 and RX it in (SERIN). After doing a WATCH for the·RX variable I see that it is represented by a:
128 decimal (for a 0),
129 (for a 1),
130 (for a 2),
131 (for a 3),
132 (for a 4),
133 (for a 5),
134 (for a 6),
135 (for a 7),
136 (for a 8),
137 (for a 9),
138 (for a A),
139 (for a B),
140 (for a C),
141 (for a D),
142 (for a E)

I would think that I am sending out ascii characters and Im not sure why the SEROUT wants to start at 128 instead of an ASCII '0' code or something like I would think.

When sending them out:

Main:
  theKey = GETKEY                               ' get a key
  IF theKey < 15 THEN                           ' was a key pressed?
    READ ReMap + theKey, theKey                 ' yes, remap keypad
    READ Digits + theKey, LEDs                  ' output to display
 
    [b]TX_Byte theKey[/b]
 
    DELAY 100
  ENDIF
  GOTO Main
 
 

' ------------------------------------------------------
' Subroutine Code
' ------------------------------------------------------

' Use: TX_BYTE theByte {, repeats}
[b]TX_BYTE:
[/b]  temp3 = __PARAM1                              ' save byte
  IF __PARAMCNT = 1 THEN                        ' check for repeats
    temp4 = 1                                   ' set repeats to 1
  ELSE
    temp4 = __PARAM2                            ' get repeats from user
  ENDIF
      SEROUT Sio, Baud, temp3                    
  RETURN

Then when I receive it with something like this:

Main:

  DataChr = RX_BYTE                             ' wait 

     watch DataChr
     break

Goto Main

RX_BYTE:
  SERIN Sio, Baud, tmpB3       
  RETURN tmpB3

The Watch Datachr shows 128-141.

Is this correct?

Comments

  • BeanBean Posts: 8,129
    edited 2007-03-27 18:51
    You are using the internal oscillator.
    It's not accurate enough for serial communications.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "Educate your children to self-control, to the habit of holding passion and prejudice and evil tendencies subject to an upright and reasoning will, and you have done much to abolish misery from their future and crimes from society"

    Benjamin Franklin
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
  • T&amp;E EngineerT&amp;E Engineer Posts: 1,396
    edited 2007-03-27 18:55
    Your right, I did get the warning about that. However, I did not know it would affect the data being sent out - only the timing of when it would be sent out. Ok - good enough. Tonight I will use a resonator and check it again.

    Oh wait...you can't use a resonator with DEBUG to watch the variable. How do I get arround this?

    Do you have an idea of what I should be seeing (if not 128 and higher)?
  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2007-03-27 19:27
    T&E Engineer,

    A few thoughts come to mind. First, from your stated output it does not look to me like you are experiencing unreliable communication. It seems like you are reliably receiving the same unexpected values for each key. Something seems to be setting your most significant bit to a one adding 128 to the received value. I suspect that your baud mode setting may be at fault. Try "ON” or "T” or “N” and see if one of those fixes it.


    To answer some of your other questions…

    When you use the debugger the SX-Key itself generates the required clock signal. So no resonator should be connected when running the debugger.

    I expect that you should be seeing key values returned in the range of 0 to 14. To confirm this you can run the debugger on the sender and see what key values are being passed to the SEROUT command.

    I hope this helps.

    - Sparks
  • BeanBean Posts: 8,129
    edited 2007-03-27 22:23
    When you do DEBUG the SX-key will generate the 4MHz clock even if you specify OSC4MHZ. And the SX-Key's 4MHz clock is very accurate.
    So the SX that you are using DEBUG has correct timing, the other that is running without the SX-Key does not have correct timing.
    I've seen ALL kinds of problems using the internal oscillator.
    That warning is there for a reason [noparse];)[/noparse]

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "Educate your children to self-control, to the habit of holding passion and prejudice and evil tendencies subject to an upright and reasoning will, and you have done much to abolish misery from their future and crimes from society"

    Benjamin Franklin
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
  • T&amp;E EngineerT&amp;E Engineer Posts: 1,396
    edited 2007-03-28 01:23
    I think I killed the DEBUG part of my SXKEY somehow so I am without WATCH capability now. In SLEEPING mode (WALK, RUN, ect. are GHOSTED OUT). I will have to figure out a new strategy. I made sure that I did not have the resonator installed while in DEBUG (spider) mode. Im not sure what else happened. However, the SXKEY can still program both SX52 and SX28 (PDB) but no DEBUG capability.

    I wish there was better protection built in. They are so easy to destroy - if you are not careful with them.
  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2007-03-28 01:50
    It is my expectation that if you can still program with the SX-Key then it has not been destroyed/debug-damaged. Can you still DEBUG other programs?

    - Sparks
  • T&amp;E EngineerT&amp;E Engineer Posts: 1,396
    edited 2007-03-28 02:29
    I did more testing and I beleive the SXKEY is ok as I can program and debug in my SX28 (PDB) ok. It appears that I can program in my SX52 protoboard too but the programs don't really do anything and if I go into DEBUG mode I always get the ghosted out STEP, WALK, RUN and it says it is sleeping. I probably fried the SX52 somehow. Luckly I bought 2 but the bad thing is that I have many LED ribbon cable wires soldered to RA, RB, RC, RD and RE. Unsoldering this weekend and try it again with the other board.
  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2007-03-28 16:27
    I think I have had an SX28 die a similar death. It would seem to program fine (possibly even verify?) but would not run or debug. I am not sure what caused it but it died in proto-typing so it was probably something I did (as opposed to running fine one day and being dead the next without being touched).

    Someone may tell me this is not possible but it seems to me that I also experienced similar symptoms as the result of a software programming error. As I recall, I later discovered that I was inadvertently overwriting the Program Counter register while trying to optimize an assembly routine. The SX Simulator allowed me to discover this error and correct it. Thanks G
  • T&amp;E EngineerT&amp;E Engineer Posts: 1,396
    edited 2007-04-01 16:50
    I tried to just replace the voltage regulator IC on the SX52 protoboard with a 7805 (they are close enough in specs) to see if that was all the issue was. I noticed the old regulator seemed to get pretty hot so it was worth a shot. However, it did not fix the problem.

    What I saw was very strange. I could not use DEBUG on that SX52 protoboard (always in a SLEEPING state) with the STEP, WALK, RUN ghosted. OK...what else was that certain programs would run. EG. I had a test program that displayed 1 LED at a time and it worked fine (no problems with programming it either). However, all of my other interupt driven·programs did nothing (nothing on the LED display "16x16").

    Does this make sense that 1 simple program would work and another would not?

    What I did was cut all the 32 wires and power from my 16x16 LED matrix and soldered them to a new SX52 protoboard. All of the programs worked with LEDs turning on/off as the should.

    I will have to order a couple more SX52 protoboards next week.
Sign In or Register to comment.