Shop OBEX P1 Docs P2 Docs Learn Events
Data from the PINK to the LCD — Parallax Forums

Data from the PINK to the LCD

TeronehcTeronehc Posts: 6
edited 2008-04-15 22:43 in BASIC Stamp
·Hi Im very new to programming and the Basic code. Using a BS2, the PINK and a 2x16 LCD screen, how can I read data from the PINK memory and display it on to the LCD screen? Please include a example code, it will make it more easier for me to understand.

Comments

  • RDL2004RDL2004 Posts: 2,554
    edited 2008-03-28 11:47
    I am no expert on the PINK, but from what I see it's meant mainly to be a web server for the Basic Stamp. The data is intended to go from the Stamp to the PINK. This data could just as easily go from the Stamp directly to the LCD at (pretty much) the same time.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Rick
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-28 13:35
    Teronehc,
    Have you looked at the documentation and existing examples for the PINK and for the LCD screen? There are also lots of examples of both in the Nuts and Volts columns (under the Resources tab on the main Parallax webpage). There's very little difference between using a DEBUG statement to show PINK information in the Stamp Editor debug window and using a SEROUT statement to show the same data on an LCD (if you're using a serial LCD). One of the better ways to get started with the Stamps is to try out the sample programs and to modify them little-by-little to make them into what you need for yourself.
  • TeronehcTeronehc Posts: 6
    edited 2008-03-31 22:04
    ·It has been brought to my attention that the LCD that Im using is not serial but parallel. I have also been using the code in the stampworks book that reads from the EEPROM of the stamp and display the data and have tried to modify it so that the PINK will write the specific data to the assigned memory address and then display it to the LCD. This is the code modification that I have done. Im currently seeing no data both in the memory map and the LCD display. Please tell me what Im doing incorrectly.

    ···· eeAddr = Msg1

    ····· SEROUT TX, Baud, [noparse][[/noparse]"!NB0R05"]································ ·'·Send Command To Read Variable 05
    ····· SERIN· RX, Baud, 100, Timeout, [noparse][[/noparse]STR nbvar \16\CLS]··· ' Get Data With Timeout
    ····· DEBUG "Variable 5: ", STR nbvar,CR··························· ' Display Byte In Decimal for testing purposes

    ····· FOR idx1 = 0 TO 15
    ······· WRITE eeAddr, nbvar············································· ' write the·data from the pink to an assigned memory location variable
    ······· eeAddr = eeAddr + 1·············································· ' increment location
    ····· NEXT

    · FOR idx1 = 0 TO 15······················································ ' First line message·to be displayed
    ····· char = LcdLine1 + idx1
    ····· GOSUB LCD_Command
    ····· READ (Msg1 + idx1), char··········································· ' eeram of first message
    ····· GOSUB LCD_Out
    · NEXT
    ···· PAUSE 2500
  • TeronehcTeronehc Posts: 6
    edited 2008-04-02 18:58
    ·Hi guys, I have been trying different codes and was able to display the data that existed on the PINK's memory. The only issue that I have now is sometimes weird characters are displayed on the parallel LCD screen. Also is there a way to detect the end of a string, Im currently uing the ascii codes for "space" or "." but I know this can lead to future problems. Here is the code that is used to read from the PINK.



    ····· SEROUT TX, Baud, [noparse][[/noparse]"!NB0R05"]······················ ' Send Command To Read Variable 05
    ····· SERIN· RX, Baud, 100, Timeout, [noparse][[/noparse]STR nbvar \16\CLS]· ' Get Data With Timeout
    ····· DEBUG "Variable 5: ", STR nbvar,CR·················· ' Display Byte In Decimal

    ·· eeAddr = Msg1
    ·· idx1=0
    ····· DO
    ······· WRITE eeAddr, nbvar(idx1)·············· ' write the recieved variable to the memory
    ······· eeAddr = eeAddr + 1···················· ' pionts to the next address
    ······· idx1 = idx1 + 1························ ' increments the index
    ····· LOOP UNTIL (nbvar(idx1)= 46)············· ' loops the read until a "."= 46 dec is incountered

    · FOR idx1 = 0 TO 15··························· ' First line message: room number
    ····· char = LcdLine1 + idx1
    ····· GOSUB LCD_Command
    ····· READ (Msg1 + idx1), char·················· ' eeram of first message
    ····· GOSUB LCD_Out
    · NEXT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-04-02 21:11
    Hello,

    It is very inefficient and potentially harmful (long term) to the EEPROM to keep writing the strings from the PINK to the EEPROM just to display them. You already have them in variable RAM anyway (array) so why not just write them from there?

    Think of it this way…When you’re writing them from the array into EEPROM you’re accessing both the array and the EEPROM using indexing…Why not just index the characters directly from the array onto the screen?

    As for the extra characters, it looks like you’re sending a fixed number of characters to the display instead of just what you want to print. The strings should be zero terminated, so why not just print until a zero is encountered? Of course, this means you’ll have to copy the zero back from the PINK Module as well.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • TeronehcTeronehc Posts: 6
    edited 2008-04-03 19:59
    Now Im really confused. So its not good to write to the EEPROM? Then how should the data be stored and passed to the LCD?
  • skylightskylight Posts: 1,915
    edited 2008-04-03 20:06
    Use a variable above the first 20 to access ram instead of flash memory
  • TeronehcTeronehc Posts: 6
    edited 2008-04-03 20:34
    Do you mean the Nb_varXX of the PINK module?
  • skylightskylight Posts: 1,915
    edited 2008-04-03 22:19
    Yes in your program section that writes to memory i'd make idx1=21 then you will sequentially write above variable 20
  • TeronehcTeronehc Posts: 6
    edited 2008-04-04 15:05
    Ok guys I have tried two completely different things: The first in reference to Chris's approach, I have used this code:

    SEROUT TX, Baud, [noparse][[/noparse]"!NB0R20"] ' Send Command To Read Variable 05
    SERIN RX, Baud, 100, Timeout, [noparse][[/noparse]STR nbvar \21\CLS] ' Get Data With Timeout
    DEBUG "Variable 20: ", STR nbvar,CR ' Display Byte In Decimal

    FOR idx1 = 0 TO 15 ' First line message: room number
    char = LcdLine1 + idx1
    GOSUB LCD_Command
    READ nbvar(idx1), char ' eeram of first message
    GOSUB LCD_Out
    NEXT
    PAUSE 2500 ' waits for 2.5 seconds
    '
    >
    FOR idx1 = 1 TO 16 ' shift display
    char = LcdDispR ' moves the first message off the lcd
    GOSUB LCD_Command
    PAUSE 100
    NEXT

    Where the LCD_OUT routine uses the char.lownib and char.highnib, but all that is displayed on the lcd are black squares where there should be text.

    My second approach used the write to the EEPROM of the basic stamp ( Msg1 data 32(16) ). Here the message is displayed except the second character every time. Someone please show me what I am doing wrong in both approaches. Here is the code that I used:

    SEROUT TX, Baud, [noparse][[/noparse]"!NB0R20"] ' Send Command To Read Variable 05
    SERIN RX, Baud, 100, Timeout, [noparse][[/noparse]STR nbvar \21\CLS] ' Get Data With Timeout
    DEBUG "Variable 20: ", STR nbvar,CR ' Display Byte In Decimal

    eeAddr = Msg1
    idx1=0
    DO
    WRITE eeAddr, nbvar(idx1) ' write the received variable to the memory
    eeAddr = eeAddr + 1 ' pionts to the next address
    idx1 = idx1 + 1 ' increments the index
    LOOP UNTIL (nbvar(idx1)= 46) ' loops the read until a "."= 46 dec is encountered


    FOR idx1 = 0 TO 15 ' First line message: room number
    char = LcdLine1 + idx1
    GOSUB LCD_Command
    READ (Msg1 +idx1), char ' eeram of first message
    GOSUB LCD_Out
    NEXT
    PAUSE 2500 ' waits for 2.5 seconds
    '
    >
    FOR idx1 = 1 TO 16 ' shift display
    char = LcdDispR ' moves the first message off the lcd
    GOSUB LCD_Command
    PAUSE 100
    NEXT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-04-15 22:43
    You're still writing to the EEPROM...It's hard to help if you won't take the suggestions provided. Please clarify exactly what it is you're trying to do...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.