Here is the new one....but the same value....
i hope this is what i forgot to change/add.
The reason i used 11 string is when i used 5 i didn´t get the hex to display at all.
But now i figured it out (have not tried it in the car though,but from computer to computer it works
' {$STAMP BS2}
k VAR Byte
hexstr VAR Byte(5)
hexa VAR Word
i VAR Byte
value VAR Word
main:
SEROUT 0,16468,[noparse][[/noparse]"010c",13]
SERIN 1,16468,[noparse][[/noparse]SKIP 6,STR hexstr\5]
FOR i=0 TO 5 ·SEROUT 2,84,[noparse][[/noparse]hexstr(i)]
NEXT
FOR k = 0 TO 1
IF hexstr(i) < "0" OR hexstr(i) > "9" THEN skip1x ·· hexstr(i) = hexstr(i) - "0"
skip1x:
IF hexstr(i) < "a" OR hexstr(i) > "f" THEN skip2x ·· hexstr(i) = hexstr(i) - "A" + 10
skip2x:
IF hexstr(i)<"A" OR hexstr(i)>"F" THEN skip3x ·· hexstr(i)=hexstr(i)-"A" +10
SKIP3x:
NEXT
FOR k = 3 TO 4
IF hexstr(i) < "0" OR hexstr(i) > "9" THEN skip4x ·· hexstr(i) = hexstr(i) - "0"
skip4x:
IF hexstr(i) < "a" OR hexstr(i) > "f" THEN skip5x ·· hexstr(i) = hexstr(i) - "A" + 10
skip5x:
IF hexstr(i)<"A" OR hexstr(i)>"F" THEN skip6x ·· hexstr(i)=hexstr(i)-"A" +10
ok...changed it so this is the new version...but i still get 21912
' {$STAMP BS2}
k VAR Byte
hexstr VAR Byte(5)
hexa VAR Word
i VAR Byte
value VAR Word
main:
SEROUT 0,16468,[noparse][[/noparse]"010c",13]
SERIN 1,16468,[noparse][[/noparse]SKIP 6,STR hexstr\5]
FOR i=0 TO 5
SEROUT 2,84,[noparse][[/noparse]hexstr(i)]
NEXT
FOR k = 0 TO 1
IF hexstr(i) < "0" OR hexstr(i) > "9" THEN skip1x
hexstr(i) = hexstr(i) - "0"
skip1x:
IF hexstr(i) < "a" OR hexstr(i) > "f" THEN skip2x
hexstr(i) = hexstr(i) - "a" + 10
skip2x:
IF hexstr(i)<"A" OR hexstr(i)>"F" THEN skip3x
hexstr(i)=hexstr(i)-"A" +10
SKIP3x:
NEXT
FOR k = 3 TO 4
IF hexstr(i) < "0" OR hexstr(i) > "9" THEN skip4x
hexstr(i) = hexstr(i) - "0"
skip4x:
IF hexstr(i) < "a" OR hexstr(i) > "f" THEN skip5x
hexstr(i) = hexstr(i) - "a" + 10
skip5x:
IF hexstr(i)<"A" OR hexstr(i)>"F" THEN skip6x
hexstr(i)=hexstr(i)-"A" +10
I just noticed that you changed the variable in the FOR statements to "k" even though I had originally written it as "i". You didn't change the subscripts in the statements within the FOR/NEXT loop to match.
Also, just after "main:", you have a "FOR i = 0 to 5". Shouldn't this be "FOR i = 0 to 4"?
okej,it seem to "work" and react on the difrent rpm however....
when i had 904 rpm the stamp showed 5464...and i had the "value/4" as i should according to the elm327 pdf as i posted to you earlier...
It´s very strange that i works fine here with my computers and when i get down to the car it shows diffrent...
the only thing i changed was the serout and serin pin....i swapped them in the program.
can this be the diffrence?
You'll have to make sure that the SERIN pin is the one being used for serial input to the Stamp and the SEROUT pin is the one being used for serial output. The Stamp doesn't care which pins are used. All of them (pins 0-15) are identical for most of the PBasic commands. The PBasic manual mentions restrictions where they exist (the LCD and I2C statements are some of those that use particular pins). Anytime you change something in a program that seems to work and it stops working, I'd suspect the changes until I've proven otherwise (and found the real problem).
Since you have an LCD attached to your Stamp, you could use that for debugging. Maybe the Stamp isn't getting the data you expect.
Like I said before, use DEBUG or the LCD to follow what's going on in your program. Simulate the program on paper with your expected data, then make sure (with some kind of debug output) that you're actually receiving what you expect.
Came to think of something that might be usefull....
if you look at the attached elm pdf file at page 41 they say something about internal UART
could it be this that´s missing?
Or does the stamp have this?
strange if if would though since i do get my hex values as i think i suppose to get.
The Stamp does not have an internal UART (Universal Asynchronous Receiver Transmitter). The SERIN and SEROUT statements provide most of the same functionality. The difference is that an internal UART is usually an independently functioning logic block that has some buffering. The SERIN/SEROUT statements do not have any buffering so, when the Stamp is not actually executing the SERIN statement, it is ignoring the receive pin. Similarly, when the Stamp is transmitting with a SEROUT statement, it's doing nothing else.
I got it working just as i should....
1500 rpm on the car shows the same on the LCD.
Thank you for all the help with the conversion etc
here is the working program
' {$STAMP BS2}
hexstr VAR Byte(15 )
i VAR Byte
value VAR Word
main:
SEROUT 2,84,[noparse][[/noparse]"?f"]
SEROUT 3,16468,[noparse][[/noparse]"010c",13]
SERIN 4,16468,[noparse][[/noparse]STR hexstr\15]
FOR i=6 TO 13
'SEROUT 2,84,[noparse][[/noparse]STR hexstr]
'DEBUG hexstr(i)
FOR i= 6 TO 7
IF hexstr(i) < "0" OR hexstr(i) > "9" THEN skip1x
hexstr(i) = hexstr(i) - "0"
skip1x:
IF hexstr(i) < "a" OR hexstr(i) > "f" THEN skip2x
hexstr(i) = hexstr(i) - "a" + 10
skip2x:
IF hexstr(i)<"A" OR hexstr(i)>"F" THEN skip3x
hexstr(i)=hexstr(i)-"A" +10
SKIP3x:
NEXT
FOR i = 9 TO 10
IF hexstr(i) < "0" OR hexstr(i) > "9" THEN skip4x
hexstr(i) = hexstr(i) - "0"
skip4x:
IF hexstr(i) < "a" OR hexstr(i) > "f" THEN skip5x
hexstr(i) = hexstr(i) - "a" + 10
skip5x:
IF hexstr(i)<"A" OR hexstr(i)>"F" THEN skip6x
hexstr(i)=hexstr(i)-"A" +10
SKIP6x:
NEXT
value =(hexstr(6) << 12) + (hexstr(7) << 8) + (hexstr(9) << 4) + hexstr(10)
Comments
i hope this is what i forgot to change/add.
The reason i used 11 string is when i used 5 i didn´t get the hex to display at all.
But now i figured it out (have not tried it in the car though,but from computer to computer it works
' {$STAMP BS2}
k VAR Byte
hexstr VAR Byte(5)
hexa VAR Word
i VAR Byte
value VAR Word
main:
SEROUT 0,16468,[noparse][[/noparse]"010c",13]
SERIN 1,16468,[noparse][[/noparse]SKIP 6,STR hexstr\5]
FOR i=0 TO 5
·SEROUT 2,84,[noparse][[/noparse]hexstr(i)]
NEXT
FOR k = 0 TO 1
IF hexstr(i) < "0" OR hexstr(i) > "9" THEN skip1x
·· hexstr(i) = hexstr(i) - "0"
skip1x:
IF hexstr(i) < "a" OR hexstr(i) > "f" THEN skip2x
·· hexstr(i) = hexstr(i) - "A" + 10
skip2x:
IF hexstr(i)<"A" OR hexstr(i)>"F" THEN skip3x
·· hexstr(i)=hexstr(i)-"A" +10
SKIP3x:
NEXT
FOR k = 3 TO 4
IF hexstr(i) < "0" OR hexstr(i) > "9" THEN skip4x
·· hexstr(i) = hexstr(i) - "0"
skip4x:
IF hexstr(i) < "a" OR hexstr(i) > "f" THEN skip5x
·· hexstr(i) = hexstr(i) - "A" + 10
skip5x:
IF hexstr(i)<"A" OR hexstr(i)>"F" THEN skip6x
·· hexstr(i)=hexstr(i)-"A" +10
SKIP6x:
NEXT
value =(hexstr(0) << 12) + (hexstr(1) << 8) + (hexstr(3) << 4) + hexstr(4)
DEBUG "hex1:",hexstr(0),CR
DEBUG "hex2:",hexstr(1),CR
DEBUG "hex3:",hexstr(3),CR
DEBUG "hex4:",hexstr(4),CR
DEBUG DEC value
SEROUT 2,84,[noparse][[/noparse]"?n",DEC value]
PAUSE 1000
'GOTO main
Post Edited (Robban) : 3/8/2007 9:54:56 PM GMT
2) You forgot to fix the assignment statements after the IF statements for "lower case". The "A" needs to be changed to "a".
or is there something else?
Post Edited (Robban) : 3/8/2007 10:04:43 PM GMT
' {$STAMP BS2}
k VAR Byte
hexstr VAR Byte(5)
hexa VAR Word
i VAR Byte
value VAR Word
main:
SEROUT 0,16468,[noparse][[/noparse]"010c",13]
SERIN 1,16468,[noparse][[/noparse]SKIP 6,STR hexstr\5]
FOR i=0 TO 5
SEROUT 2,84,[noparse][[/noparse]hexstr(i)]
NEXT
FOR k = 0 TO 1
IF hexstr(i) < "0" OR hexstr(i) > "9" THEN skip1x
hexstr(i) = hexstr(i) - "0"
skip1x:
IF hexstr(i) < "a" OR hexstr(i) > "f" THEN skip2x
hexstr(i) = hexstr(i) - "a" + 10
skip2x:
IF hexstr(i)<"A" OR hexstr(i)>"F" THEN skip3x
hexstr(i)=hexstr(i)-"A" +10
SKIP3x:
NEXT
FOR k = 3 TO 4
IF hexstr(i) < "0" OR hexstr(i) > "9" THEN skip4x
hexstr(i) = hexstr(i) - "0"
skip4x:
IF hexstr(i) < "a" OR hexstr(i) > "f" THEN skip5x
hexstr(i) = hexstr(i) - "a" + 10
skip5x:
IF hexstr(i)<"A" OR hexstr(i)>"F" THEN skip6x
hexstr(i)=hexstr(i)-"A" +10
SKIP6x:
NEXT
value =(hexstr(0) << 12) + (hexstr(1) << 8) + (hexstr(3) << 4) + hexstr(4)
DEBUG "hex1:",hexstr(0),CR
DEBUG "hex2:",hexstr(1),CR
DEBUG "hex3:",hexstr(3),CR
DEBUG "hex4:",hexstr(4),CR
DEBUG DEC value
SEROUT 2,84,[noparse][[/noparse]"?n",DEC value]
PAUSE 1000
'GOTO main
Also, just after "main:", you have a "FOR i = 0 to 5". Shouldn't this be "FOR i = 0 to 4"?
Now i got my 6904...changed the k to i and the 5 to 4
gonna get down to the car and try it....*very exiting*
when i had 904 rpm the stamp showed 5464...and i had the "value/4" as i should according to the elm327 pdf as i posted to you earlier...
It´s very strange that i works fine here with my computers and when i get down to the car it shows diffrent...
the only thing i changed was the serout and serin pin....i swapped them in the program.
can this be the diffrence?
Post Edited (Robban) : 3/9/2007 6:41:45 PM GMT
Since you have an LCD attached to your Stamp, you could use that for debugging. Maybe the Stamp isn't getting the data you expect.
Like I said before, use DEBUG or the LCD to follow what's going on in your program. Simulate the program on paper with your expected data, then make sure (with some kind of debug output) that you're actually receiving what you expect.
if you look at the attached elm pdf file at page 41 they say something about internal UART
could it be this that´s missing?
Or does the stamp have this?
strange if if would though since i do get my hex values as i think i suppose to get.
I got it working just as i should....
1500 rpm on the car shows the same on the LCD.
Thank you for all the help with the conversion etc
here is the working program
' {$STAMP BS2}
hexstr VAR Byte(15 )
i VAR Byte
value VAR Word
main:
SEROUT 2,84,[noparse][[/noparse]"?f"]
SEROUT 3,16468,[noparse][[/noparse]"010c",13]
SERIN 4,16468,[noparse][[/noparse]STR hexstr\15]
FOR i=6 TO 13
'SEROUT 2,84,[noparse][[/noparse]STR hexstr]
'DEBUG hexstr(i)
FOR i= 6 TO 7
IF hexstr(i) < "0" OR hexstr(i) > "9" THEN skip1x
hexstr(i) = hexstr(i) - "0"
skip1x:
IF hexstr(i) < "a" OR hexstr(i) > "f" THEN skip2x
hexstr(i) = hexstr(i) - "a" + 10
skip2x:
IF hexstr(i)<"A" OR hexstr(i)>"F" THEN skip3x
hexstr(i)=hexstr(i)-"A" +10
SKIP3x:
NEXT
FOR i = 9 TO 10
IF hexstr(i) < "0" OR hexstr(i) > "9" THEN skip4x
hexstr(i) = hexstr(i) - "0"
skip4x:
IF hexstr(i) < "a" OR hexstr(i) > "f" THEN skip5x
hexstr(i) = hexstr(i) - "a" + 10
skip5x:
IF hexstr(i)<"A" OR hexstr(i)>"F" THEN skip6x
hexstr(i)=hexstr(i)-"A" +10
SKIP6x:
NEXT
value =(hexstr(6) << 12) + (hexstr(7) << 8) + (hexstr(9) << 4) + hexstr(10)
DEBUG "hex1:",hexstr(6),CR
DEBUG "hex2:",hexstr(7),CR
DEBUG "hex3:",hexstr(9),CR
DEBUG "hex4:",hexstr(10),CR
DEBUG DEC value,CR
SEROUT 2,84,[noparse][[/noparse]"?n",DEC value/4]
' SERIN 0,16468,[noparse][[/noparse]WAIT(">")]
PAUSE 1000
GOTO main
NEXT
PAUSE 1000
have saved this on several discs
Now i´m gonna expand it to show speed,coolant temperature etc...
Once again....THANK YOU!