Shop OBEX P1 Docs P2 Docs Learn Events
Using PINK (Ethernet module) and SX/B — Parallax Forums

Using PINK (Ethernet module) and SX/B

John CoutureJohn Couture Posts: 370
edited 2009-02-14 06:09 in General Discussion
Tim Gilmore's recent question·inspired me to dust off my PINK module and see if I could get it running.· Below are a few of my lessons learned and the complete program which I am now using to read (via 1Wire network) my AAG weather instrument on the top of the hill.


Programming Notes for the Ethernet PINK module and the SX processor
··
1) Setup: SX28 at 4mhz, PINK set to 9600,8bits,No Parity, 1 stop bit.
·· I tested my SX28 program on a terminal program before I tried
·· to get the PINK module to work.

2) The PINK module is a pretty neat module designed to accept
·· data from its serial port and update internal web pages
·· that can then be accessed from the Internet.·
··
3) In a text editor (i.e. notepad), set up a simple page:

<html>
· <head>
··· <title>This is a page title</title>
· </head>
· <body>
··· <p>This is a variable from PINK <Nb_var51>
· </p>
· </body>
</html>

·· Using FTP, copy it to the folder on the PINK module.
·· Yep, it is that easy and I was impressed too!

4) In your START routine in your SX program

· · DELAY_MS 2000· ' allow PINK to initialize
·· TX_BYTE 0····· ' clear xmit buffer
·· TX_BYTE "!"··· ' wakie, wakie, Mr. Pink
··
5) In your main loop

·· TX_STR "!NB0W51:"· ' Update variable # 51
····················· ' note that it is NB ZERO W
·· TX_STR "This is fun"
·· TX_BYTE 0········· ' terminate transmission
··
6) Run your program and then run the browser and you
·· should see "This is fun" on the browser.
··
7) Now I abbreviated a lot here but the TX_BYTE and
·· TX_STR routines would be common routines that have
·· been printed many, many times by Jon Williams in his
·· books and on this forum.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John J. Couture

San Diego Miramar College

Comments

  • JonnyMacJonnyMac Posts: 9,214
    edited 2009-02-14 01:05
    John,

    I believe you have glitch in your TX_STR subroutine (and if you got it from me I apologize):

    ' Use: TX_STR [noparse][[/noparse]String | Label]
    ' -- pass embedded string or DATA label
    SUB TX_STR
      ' Local Variables
      strIOByte VAR __PARAM1
    
      strAddr = __WPARAM12
      DO
        READINC strAddr, strioByte     ' read a ioByteacter
        IF strioByte = 0 THEN EXIT     ' if 0, string complete
        TX_BYTE strioByte              ' send the byte
      LOOP
      ENDSUB
    


    Your strAddr variable and your strIOByte variable collide with each other as strIOByte (__PARAM1) is the LSB of strAddr (__WPARAM12). I've tried to code this routine using nothing but internal variables but have found it not possible. When you call TX_BYTE __PARAM3 and __PARAM4 (which I tried to use for strAddr as __WPARAM34) get used in SEROUT. I use a temporary word (usually tmpW1 in my programs) for strAddr.

    Post Edited (JonnyMac) : 2/14/2009 1:31:25 AM GMT
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2009-02-14 01:41
    JonnyMac,
    I think you are mistaken.
    strAddr is a normal word variable that gets assigned the value of the passed parameter (__wparam12).
    strIOByte is aliased to __param1

    READINC reads a new value into strIOByte (eg. __param1)
    which is tested for 0, and if not, calls TX_BYTE.
    Now, because strIOByte is aliased to __param1
    there is a redundant MOV __param1,strIOByte
    prior to calling TX_BYTE.
    TX_BYTE destroys __param1 (eg. strIOByte)
    but not strAddr and since strIOByte is not used
    after calling TX_BYTE there is no problem.

    regards peter
  • John CoutureJohn Couture Posts: 370
    edited 2009-02-14 03:12
    (grin) To the mortals like me on the ground, this is facinating watching the "clash of the titans".

    To newbies, Jon Williams and Peter Verkaik are a couple of the select few demi-gods of the SX/B and SX chip. Read their posts carefully as you will learn a lot. If, in my lifetime, I learn just 10% of what they know I will consider myself lucky!

    To Jon and Peter, a heartfelt Thank You for all the time you spend on this forum helping us out!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John J. Couture

    San Diego Miramar College
  • JonnyMacJonnyMac Posts: 9,214
    edited 2009-02-14 06:09
    You're absolutely right, Peter -- I was very tired and in need of a Heineken! I didn't see that he had created strAddr as a variable at the top of the program and my tired mind read the moving __WPARAM12 to it as a variable declaration.

    Sorry, John.
Sign In or Register to comment.