can anyone suggest any information on using serin/serout or sample code. I am trying to input a 12 bit binary serial data from an external device and display a decimal output on a parallax serial LCD display.
What does the stream from the device look like? Is it binary (would be two bytes to hold twelve bits)? If so, in what order do the bytes arrive? Or, is the information sent as a text string? If the latter, the BASIC Stamp has conversion functions that will work at 9600 baud and lower.
And, as always, reading the sections on SERIN and SEROUT in the manual (their detailed) will go a long way toward developing your understanding of these commands. The manual (and help file) have several code snippets to demonstrate PBASIC features.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Jon Williams Applications Engineer, Parallax
It looks like it should be doable in PBASIC. I wrote a subroutine to receive the bytes and parse the bits, but I'm not seeing how %010110_010101 correpsonds to -21.2? Also, links to the documentation for the ADC you are using would be helpful.
Post Edited (Andy Lindsay (Parallax)) : 1/18/2006 11:24:39 PM GMT
This is off the top of my head after looking at the data sheet (and assumes a BS2; see our template for conditional compilation directives to set the baudmode value for any BS2-family module).
Here's what the Get_Sensor routine does: It waits for two bytes and then checks the high bit of the MSB to make sure that the bytes are properly aligned.· If that's the case, then the word variable is reassembled from the two bytes that contain six data bits each.· Please study the data shee carefully and compare it to this code.
Here is a test program (TestSpectroTilt3.bs2) to try with your·SPECTROTILT module and Parallax Serial LCD.· Make sure to update the Pin directives for your setup.· Also, if you're not using the BASIC Stamp 2, make sure to update the $STAMP, and BaudMode directives accordingly.
The examples in the part datasheet appear to be incorrect because they truncate the D10 and D11 bits.· Either that, or the explanation is incorrect.··Assuming the explanation is correct, the binary value for -56.27 degrees·should be·1100_0110_0101_0101 and the·one for -37.7 degrees·should be·1000_1110_0011_0011.·
Yes, you can use the custom character creator.· The main thing is that it outputs the correct values for the character and you can just paste those into your existing DATA statement where needed.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Chris Savage Parallax Tech Support csavage@parallax.com
can anyone suggest a link because most of the documentation I am finding seems to be targeting sending special characters to a non-serial LCD. The documentation on the display (2x16 serial LCD pn:27977) says "coming soon custom LCD animation"
I've attached a demo for the Parallax Serial LCD that shows how to download custom characters.· As you can see, the only difference betwee the DATA statments in this program and the output for the LCD Character Creator is the addition of the character code constant.· There was a discussion on this subject in this thread:
Comments
And, as always, reading the sections on SERIN and SEROUT in the manual (their detailed) will go a long way toward developing your understanding of these commands. The manual (and help file) have several code snippets to demonstrate PBASIC features.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
· value VAR Word
····.
····.
····.
· SEROUT 14, 84, [noparse][[/noparse]22, 12]
· PAUSE 5
· DO
··· GOSUB Get_12_Bit_ADC_Value
··· SEROUT 14, 84, [noparse][[/noparse]128, DEC5 value]
··· PAUSE 250
· LOOP
··· .
····.
··· .
There are more tips and tricks of a similar sort in this post: Getting Started with the Parallax Serial LCD.
Post Edited (Andy Lindsay (Parallax)) : 1/18/2006 7:34:08 PM GMT
MSB (B7 [noparse][[/noparse]1] indicates·MSB - B6 EVEN PARITY - B5-B0 output of A/D convereter)
LSB (B7 [noparse][[/noparse]0]·indicates LSB - B6 EVEN PARITY - B5-B0 output of A/D convereter)
i.e. 1001 0110·· 0101 0101 equals -21.2 in decimal
Post Edited (gc3076) : 1/18/2006 8:21:39 PM GMT
Post Edited (Andy Lindsay (Parallax)) : 1/18/2006 11:24:39 PM GMT
http://www.spectronsensors.com/appsheets/SAN-213-0304.pdf
Here's what the Get_Sensor routine does: It waits for two bytes and then checks the high bit of the MSB to make sure that the bytes are properly aligned.· If that's the case, then the word variable is reassembled from the two bytes that contain six data bits each.· Please study the data shee carefully and compare it to this code.
Sensor···· ·PIN··· 15
SnsrBaud··· CON··· 84
result···· ·VAR··· Word
...
Get_Sensor:
· SERIN Sensor, SnsrBaud, [noparse][[/noparse]result.HIGHBYTE, result.LOWBYTE]
· IF (result.BIT15 = 0) THEN Get_Sensor
· result.BIT6 = result.BIT8
· result.BIT7 = result.BIT9
· result.HIGHBYTE = (result.HIGHBYTE & %00111111) >> 2
· RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Here is a test program (TestSpectroTilt3.bs2) to try with your·SPECTROTILT module and Parallax Serial LCD.· Make sure to update the Pin directives for your setup.· Also, if you're not using the BASIC Stamp 2, make sure to update the $STAMP, and BaudMode directives accordingly.
The examples in the part datasheet appear to be incorrect because they truncate the D10 and D11 bits.· Either that, or the explanation is incorrect.··Assuming the explanation is correct, the binary value for -56.27 degrees·should be·1100_0110_0101_0101 and the·one for -37.7 degrees·should be·1000_1110_0011_0011.·
Regards, Andy
Post Edited (Andy Lindsay (Parallax)) : 1/22/2006 12:38:09 AM GMT
If not I tried to use the following as a test using a ASCII chart from the below link.
http://www.myke.com/lcd.htm
' {$STAMP BS2}
' {$PBASIC 2.5}
degree VAR Byte
degree = %01111110
SEROUT 14, 84, [noparse][[/noparse]degree]
Post Edited (gc3076) : 1/24/2006 8:20:41 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
http://forums.parallax.com/showthread.php?p=567287
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax