PROPBASIC and DATA statement...
denno
Posts: 235
in Propeller 1
Is it possible to "implant" a constantly changing variable in a DO/LOOP (i.e. a temperature reading from an LM34) into a DATA statement like:
The above DATA statement does "print" on the LCD at the right positions and the right line, but the variable(s), temp_1 and temp_2 spaces are just blank. Bean, any ideas...?
DennO
LCD_data_2 DATA temp_1, posCMD,82,degreeSYM,posCMD,99,temp_2,posCMD,102,degreeSYM,posCMD,115,".",posCMD,135,".",0
The above DATA statement does "print" on the LCD at the right positions and the right line, but the variable(s), temp_1 and temp_2 spaces are just blank. Bean, any ideas...?
DennO

Comments
You can do it like this:
DEVICE P8X32A,XTAL1,PLL16X FREQ 80_000_000 Baud CON "T9600" LCD_Pin PIN 30 HIGH LCD_Data DATA "The temperature is:" LCD_Data2 DATA "99999", 13, 0 ' The "99999" will get changed in code temp VAR LONG PROGRAM Start Start: PAUSE 5000 FOR temp =0 to 20 LCD_Data2 = STR temp, 5, 5 SEROUT LCD_Pin, Baud, LCD_Data NEXT temp GOTO Start ENDBean
DEVICE P8X32A,XTAL1,PLL16X FREQ 80_000_000 Baud CON "T115200" ''''9600" LCD_Pin PIN 30 HIGH LCD_Data DATA "The temperature is:",0 LCD_Data2 DATA "99999", 13, 0 ' The "99999" will get changed in code temp VAR LONG PROGRAM Start Start: PAUSE 1000 SEROUT LCD_Pin, Baud, LCD_Data FOR temp = 0 to 20 LCD_Data2 = STR temp, 5, 5 SEROUT LCD_Pin, Baud, LCD_Data2 PAUSE 1000 NEXT temp GOTO Start ENDHowever, I am trying to "insert" a variable in the middle (2 places actually) of the the following DATA statement...where your "insertion" is at the end of the first LCD_data statement...please note temp_1DEC, temp_2DEC. Is this even possible? I do have another way that does work, but uses 24 SEROUT commands to place (4) variables on 4 different lines of the LCD.
Thanks...DennO
To do multiple values you can either break up the DATA statement into multiple DATA statements, or use offsets.
or
Bean
P.S. Originally I had LCD_data_2[2] and LCD_data_2[12] that was incorrect.
That COMMAND will SEROUT the the LCD_data_2, first, then the LCD_data_2 [2], second, and then the LCD_data_2 [12], and fill in the "11111" and "22222".
That will certainly reduce my coding...space.
In reference to the STACK directive...should one just use STACK 255 and/or is the directive really necessary...?
DennO
After a few trial and errors...aka "UNKNOWN COMMAND",,,I added the extra DATA statements:
LCD_data_2[3] DATA "111"
LCD_data_2[9] DATA "222"
Thanks again..and I am sure, as I move forward in using the PROP...I will have more.
DennO
PropBasic Version 00.01.48 Aug 9, 2018
Finished Compile. 251 Lines Read, 1355 Lines Generated, 0 Warnings, 0 Errors.
Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved
Compiled for i386 Win32 at 08:17:48 on 2009/07/20
Loading Object LCDdisplay_SE
Loading Object LCD_1.spin
LCD_1.spin - Error at (530,13) Expected End of Line, Assembly Conditio
nal, BYTE, WORD, LONG or Assembly Instruction
__LCD_DATA_2[3]_adr LONG 146
____________^
Compiled 665 Lines of Code in 0.017 Seconds
And here is the code that I am trying to run...again thanks for your time...much appreciated...when I uncomment line 101 below, I get the above LCD_1.spin error. When I leave it commented, I get the "UNKNOWN COMMAND"
TASK LCD_1 LMM 'this TASK is running in COG 7 LCD_data_out PIN 2 temp_1 VAR LONG 'the temp_1erature data, itself.. temp_2 VAR LONG VOLT VAR LONG VOLTtenth VAR LONG VOLThunds VAR LONG VOLT_3v VAR LONG VOLTtenth_3v VAR LONG VOLThunds_3v VAR LONG MCPValue VAR LONG ' LCD_data_2[3] VAR LONG 'the following DATA statments are to preload the display, the variables are loaded elsewhere in the program. LCD_data_1 DATA clrLCD,beep,backLTon,posCMD,64,"TEMPERATURE IS",posCMD,84,"TEMPERATURE IS",posCMD,104,"VOLTAGE =",0 LCD_data_2 DATA posCMD,79,"000",posCMD,82,degreeSYM,posCMD,99,"222",posCMD,102,degreeSYM,posCMD,115,".",posCMD,135,".",0 LCD_data_3 DATA posCMD,114, "1",posCMD,115,".",posCMD,116,"2",posCMD,117,"3",posCMD,119,"volts",posCMD,124,"VOLTAGE =",posCMD,139,"volts",0 ' LCD_data_2[3] DATA "111" <<<<<<< <<<<<BEAN this is LINE 101>>>>>> ' LCD_data_2[9] DATA "222" ' LCD_data_3[16] DATA "1" ' LCD_data_3[22] DATA "2" ' LCD_data_3[25] DATA "3" SEROUT LCD_data_out, baud, LCD_data_1 SEROUT LCD_data_out, baud, LCD_data_2 SEROUT LCD_data_out, baud, LCD_data_3 'LCD_data_2 DATA posCMD,79,"11111",posCMD,82,degreeSYM,posCMD,99,"22222",posCMD,102,degreeSYM,posCMD,115,".",posCMD,135,".",0 'LCD_data_2[2] = STR temp_1, 5, 5 ' LCD_data_2[2] is position of "11111" 'LCD_data_2[12] = STR temp_2, 5, 5 ' LCD_data_2[12] is position of "22222" DO RDLONG degrees_1, temp_1 'reading the temperature data that is in the HUB PAUSE 100 LCD_data_2[3] = STR temp_1,3,5 ' SEROUT LCD_data_out, baud, LCD_data_2[3] RDLONG degrees_2, temp_2 'reading the temperature data that is in the HUB PAUSE 100 ' LCD_data_2[9] = STR temp_2,3,5 RDLONG volt_location, VOLT PAUSE 100 RDLONG tenth_location, VOLTtenth PAUSE 100 RDLONG hunds_location, VOLThunds PAUSE 100 ' LCD_data_3[16] = STR VOLT,1,5 ' LCD_data_3[22] = STR VOLTtenth,1,5 ' LCD_data_3[25] = STR VOLThunds,1,5 RDLONG volt_location_3v, VOLT_3v PAUSE 100 RDLONG tenth_location_3v, VOLTtenth_3v PAUSE 100 RDLONG hunds_location_3v, VOLThunds_3v PAUSE 100 actualVOLT_3v = STR VOLT_3v,1 actualVOLTtenth_3v = STR VOLTtenth_3v,1 actualVOLThunds_3v = STR VOLThunds_3v,1' SEROUT LCD_data_out, baud, posCMD SEROUT LCD_data_out, baud, 134 SEROUT LCD_data_out, baud, actualVOLT_3v SEROUT LCD_data_out, baud, posCMD SEROUT LCD_data_out, baud, 136 SEROUT LCD_data_out, baud, actualVOLTtenth_3v SEROUT LCD_data_out, baud, posCMD SEROUT LCD_data_out, baud, 137 SEROUT LCD_data_out, baud, actualVOLThunds_3v LOOP ENDTASK LCD_1I made a typo the index needs to be in parens not brackets.
LCD_data_2(3)
You don't need any of those extra DATA lines with the offsets. Those make no sense...
Just do
Again, sorry my bad. I will fix the previous post.
Bean
DennO
You have the comment correct, but the code is not correct.
Bean
'the following DATA statments are to preload the display, the variables are loaded elsewhere in the program. LCD_data_1 DATA clrLCD,beep,backLTon,posCMD,64,"TEMPERATURE IS",posCMD,82,degreeSYM,0 'LCD...line 1 LCD_data_2 DATA posCMD,84,"TEMPERATURE IS",posCMD,102,degreeSYM,0 'LCD...line 2 LCD_data_3 DATA posCMD,104,"VOLTAGE =",posCMD,115,".",posCMD,119,"volts",0 LCD_data_4 DATA posCMD,124,"VOLTAGE =",posCMD,134,"1",posCMD,135,".",posCMD,136,"2",posCMD,137,"3",posCMD,139,"volts",0 SEROUT LCD_data_out, baud, LCD_data_1 'to print line 1 SEROUT LCD_data_out, baud, LCD_data_2 'to print line 2 SEROUT LCD_data_out, baud, LCD_data_3 'to print line 3 SEROUT LCD_data_out, baud, LCD_data_4 'to print line 4 DO RDLONG degrees_1, temp_1 'reading the temperature data that is in the HUB PAUSE 100 LCD_data_1a DATA posCMD,79,"000",0 LCD_data_1a(2) = STR temp_1,3 SEROUT LCD_data_out, baud, LCD_data_1a RDLONG degrees_2, temp_2 'reading the temperature data that is in the HUB PAUSE 100 LCD_data_2a DATA posCMD,99,"222",0 LCD_data_2a(2) = STR temp_2,3 SEROUT LCD_data_out, baud, LCD_data_2a RDLONG volt_location, VOLT 'reading the voltage data that is in the HUB PAUSE 100 RDLONG tenth_location, VOLTtenth 'reading the voltage data that is in the HUB PAUSE 100 RDLONG hunds_location, VOLThunds 'reading the voltage data that is in the HUB PAUSE 100 LCD_data_3a DATA posCMD,114,"1",posCMD,116,"2",posCMD,117,"3",0 LCD_data_3a(2) = STR VOLT,1,5 LCD_data_3a(5) = STR VOLTtenth,1,5 LCD_data_3a(8) = STR VOLThunds,1,5 SEROUT LCD_data_out, baud, LCD_data_3a RDLONG volt_location_3v, VOLT_3v PAUSE 100 RDLONG tenth_location_3v, VOLTtenth_3v PAUSE 100 RDLONG hunds_location_3v, VOLThunds_3v PAUSE 100 LCD_data_4a DATA posCMD,134,"1",posCMD,136,"2",posCMD,137,"3",0 LCD_data_4a(2) = STR VOLT_3v,1,5 LCD_data_4a(5) = STR VOLTtenth_3v,1,5 LCD_data_4a(8) = STR VOLThunds_3v,1,5 SEROUT LCD_data_out, baud, LCD_data_4a LOOPThere is no need to use STR for 1 digit values. (STR generates a lot of code).
Just do this:
Just be sure to DEC VOLT, "0" if you want to use the value after using WRBYTE to put it in the data string.
That will save a bunch of code...
Bean
I know I can do regular math in a COG, but I am wondering, (first)...why I have to send data as a STR XXXXXXX, X as in the following example: I am quite good at interger math, as that is what is used, as you know in PBASIC. But I find myself, having to do the same with PROPBASIC, to get it to the LCD...
LCD_data_1aa DATA posCMD,79,"11",posCMD,81,".",posCMD,82,"3",posCMD,83,degreeSYM,0 LCD_data_1aa(2) = STR TEMP_100,2,5 LCD_data_1aa(8) = STR TEMP_tenths,1,5 SEROUT LCD_data_out, baud, LCD_data_1aaIn reading through your 1.48 "rules of the road", I see there is a VAL and a ABS, can't these be used to change a STRING to some decimal value. I know in PBASIC, if I modify something that I want to send to the display, I preface the VAR with DEC(x). I hope I am making since...
As far as the example you gave me, (#2 below), I kept getting ERROR messages, when I was trying to use it for one "digit" to get it into a index DATA statement...instead of using as example the following code...(#1 below)
#1..example
LCD_data_3a DATA posCMD,114," ",posCMD,116," ",posCMD,117," ",0 LCD_data_3a(2) = STR VOLT,1,5 LCD_data_3a(5) = STR VOLTtenth,1,5 LCD_data_3a(8) = STR VOLThunds,1,5 SEROUT LCD_data_out, baud, LCD_data_3aBean, I keep getting an error message with the following code...#2 example
And, last, are you going to or is there a later "rules of the road" then 1.48? I just think that PROPBASIC is easier to use/learn, along the lines of PBASIC then SPIN...no offence to those that put SPIN language together.
DennO
Print "4 X 2“ will output 4 X 2
Look at an ASCII chart, Print a decimal 13 and you will get a carriage return.
Print a decimal 10 and you will get a line-feed.
Keep in mind, I am writing to a stand alone LCD display, made by Scott Edwards, so one has to tell the display where to print stuff, by a position command...I am not sending stuff to the computer screen....
DenO
LCD_data_3a DATA posCMD,114," ",posCMD,116," ",posCMD,117," ",0 LCD_data_3a(2) = STR VOLT,1,5 LCD_data_3a(5) = STR VOLTtenth,1,5 LCD_data_3a(8) = STR VOLThunds,1,5 SEROUT LCD_data_out, baud, LCD_data_3aNow, the above code will run and place the VAR(s) in the proper locations on the LCD.
But, if I change the code to:
LCD_data_3a DATA posCMD,114," ",posCMD,116," ",posCMD,117," ",0 LCD_data_3a(2) = INC VOLT, "0" LCD_data_3a(5) = INC VOLTtenth, "0" LCD_data_3a(8) = INC VOLThunds, "0" SEROUT LCD_data_out, baud, LCD_data_3ato save code space, I get this....ERROR messageAnd, I am using the INC after a RDLONG command.
So, what am I doing wrong...LOL...DennO
INC adds a value to an integer variable. It's completely different from STR, which converts an integer into a string. There's no general way to replace STR with INC. In the case of a one digit number you might be able to do something like: but that will ONLY work if VOLT is between 0 and 9; other values will fail badly. Also note that this changes VOLT, so if you want to use that value later save it off somewhere. The formatting will also be a bit different from the STR case.
Eric