Shop OBEX P1 Docs P2 Docs Learn Events
This .PBAS works, but.... — Parallax Forums

This .PBAS works, but....

First I am using an Scott Edwards LCD, which has it own set of "Character Codes"..0 through 255. Plus, as you can see in the code, there are also Constants to controll the LCD...position commands, backlight on and off...etc.

From the code, I have put in a fixed temperature reading of 125 degrees, into the HUB and then passed that to COG 7 to use in the "LCD" display. The problem I am having is when the RDLONG degrees, temp get the number from the HUB, and pass it down to the SEROUT command, instead of printing the "125", the LCD display thinks I am send it a control command, which is a "right hand bracket" instead of the temperature of 125 degrees. How do I make that PBAS command of SEROUT send the "number" 125 to be printed on the display...keep in mind that the number 125 is just a test number, as later on I will be using an LM34 to make temperature reading....and pass that value to COG 7 for a digital readout........thanks DenO


DEVICE P8X32A, XTAL1, PLL16X
XIN 5_000_000
STACK 10
baud                   CON "N9600"
carr_return            CON  13   
clrLCD                 CON  12          'clear the screen on the lcd
posCMD                 CON  16          'position the curser command
hideCUR                CON   4           'hide the curser command
blinkCUR               CON   6           'blink the curser command
degreeSYM              CON 223           'the "degree" symbol
receive_data           CON 255
backLTon               CON  14          'turn the back light on
backLToff              CON  15          'turn the back light off
brightness_ctl         CON  27
quarter_bright         CON  48
half_bright            CON  49
three_quarter_bright   CON  50
full_bright            CON  51
beep                   CON   7           'beep command
right_align            CON  18          'RIGHT ALIGN COMMAND
start_big_char         CON   2
end_big_char           CON   3
astrike                CON  42
block_char             CON 134
carReturn              CON  13          'carriage return command
blank_char             CON  32
left_arrow             CON 127
right_arrow            CON 126
LR_arrow               CON 131
LL_arrow               CON 128
UR_arrow               CON 129
UL_arrow               CON 130
down_arrow             CON 132
up_arrow               CON 133
equal_sign             CON  61
first_line             CON  64
second_line            CON 104          
degrees                HUB  LONG 
temp                   VAR  LONG

LCD_data_out           PIN 0  LOW

LCD_display TASK
PROGRAM START
START:
  temp = 125 
  WRLONG degrees, temp
  COGINIT LCD_display, 7 'cog 7
END

TASK LCD_display
   temp    VAR LONG
   RDLONG degrees, temp   

   SEROUT LCD_data_out, baud, clrLCD
   SEROUT LCD_data_out, baud, beep
   SEROUT LCD_data_out, baud, backLTon
   PAUSE 1000
   SEROUT LCD_data_out, baud, posCMD
   SEROUT LCD_data_out, baud, 64
   SEROUT LCD_data_out, baud, "TEMPERATURE IS"
   SEROUT LCD_data_out, baud, posCMD
   SEROUT LCD_data_out, baud, 84
   SEROUT LCD_data_out, baud, temp   '<<<<<<<the problem......?
ENDTASK

Comments

  • BeanBean Posts: 8,129
    You need to convert the value to an ascii string using the STR function.

    Bean
  • Thank you Bean, but I am going to need your help on that...SEROUT LCD_data_out, baud, STR temp, 000,,,still does not work. Even if I do this....SEROUT LCD_data_out, baud, STR temp, 123 does not work...what does "digits" mean in the example of STR...DennO
  • Denno, you can't put more tha one command per line. You need to define a string variable, load it using STR then use serout to display that string.
    Define a string variable:
       string1  HUB STRING(3)
    
    Use STR to place the ASCII representation of temp's value into a string
       string1 = STR temp,3
    
    THEN display it.
       SEROUT LCD_data_out, baud, string1 
    

    If you refer to these commands in the PropBASIC manual things will become much easier for you.
    I have a copy double side printed and in a binder and it's almost a necessity to do something similar when
    learning a new variant of a language.
    Here's the description of STR:
    PropBasic 00.01.48
    Page 34
    STR
    Converts a value to a string. If a signed option is used, the first character will be a "-" or a space.
    If the value is larger than the number of digits specified, the first character will be corrupt.
    Options 0 thru 3 will append a zero byte after the digits to form a single string, options 4 thru 7 do not.
    For signed options, the sign counts as a digit.
    The maximum digits is 11 for signed options and 10 for unsigned options.
    string1 = STR value1,digits{,option}
    Option:
    0 - Unsigned leading zeros, z-string
    1 - (default) Unsigned leading spaces, z-string
    2 - Signed leading zeros, z-string
    3 - Signed leading spaces, z-string
    4 - Unsigned leading zeros, no terminating zero
    5 - Unsigned leading spaces, no terminating zero
    6 - Signed leading zeros, no terminating zero
    7 - Signed leading spaces, no terminating zero
    
  • pmrobert...thank you for your knowledge, and your advice did the trick. I did read the info on STR, however, I did not understand setting up a HUB variable for a STRING(3)...plus you have to physically write and read data to the HUB...from each COG to use that data in another COG...meaning sending the "temp" value from COG 0 to COG 7..through the HUB.

    And, I will take your advice about printing out all the manual for 1.48 propbasic....

    DennO
Sign In or Register to comment.