Help with Basic stamp 2 code problem
oliverkd123
Posts: 17
in BASIC Stamp
im having problems trying to make a section of code work. its written in basic stamp and is being used in the basic stamp 2 kit from parallax. its supposed to calculate voltage difference between 2 reference points and the signal from a pair of variable gain amps and give a reading on an LCD display. all it gives is serial mode then a load of gibberish on the display so i think it could be a problem with the code. i have attached the code to this
any help/sugestions would be more than welcome
any help/sugestions would be more than welcome
Comments
and i have used it in the device.
Also
SEROUT LCD,32,[22,12,17] ' Clear and turn on backlight on LCD display
doesn't seem to use the control characters described in the data sheet. 22 is "Enable start-up message", 17 is "clear column". Was this originally written for a parallax serial LCD?
change it to
That will change the baud rate from 19,200 to 9600. But you still may need to simulate the second stop bit. You can try The addition 1 inserts one millisecond between characters. It may take two. But you will still need to sort out the control characters.
Actually, it looks more like 3 1/2 stop bits. I'm surprised; I had not actually measured it before. Bottom line, you should't need the PACE parameter I mentioned.
https://www.parallax.com/sites/default/files/downloads/27979-Parallax-Serial-LCDs-Product-Guide-v3.1.pdf
btw, this is a really excellent example of why "magic numbers" suck is poor programming practice. Using CONs to define the control codes would have made the job easier.
148 and 151 are also set cursor commands. I didn't notice any others.
Wherever they appear in a SEROUT statement.
You can painstakingly go through your code and the datasheets for both the Parallax display and Daventec display and change any Daventec controls to their Parallax equivalent one by one or
You can get a Parallax display and use that as described in the project design.
Parallax carefully tests their kits, projects, and sample code. When you substitute different parts, all bets are off. Unfortunately, serial LCD displays are one area where there's no accepted standard for control codes.
Personally, I would sit down with the two datasheets and make a table like tomcrawford's, but with all the control functions I can find in the Parallax display's datasheet. Then I'd figure out which Daventec display functions are equivalent, maybe using more than one Daventec function for a Parallax function. Then I'd make the substitutions in the program and try it. You'd learn about the capabilities of each display and maybe get an idea of what the program is trying to do with the display formatting. This would take time and effort vs. the expense and time to get a Parallax display.
128 gets changed to 2,1 but
148 gets changed to 2, 17 'line 2, character 1
153 gets changed to 2, 22 (or so) 'line 2, character 5
There are a bunch of constants great than 128; they all need to be changed appropriately. Some are in the range 128 to 144 or so; they refer to line 1. Some are in the range 148 to 160 or; they refer to line 2.
I agree with Mike. Print out both data sheets on paper, along with the program. Search through the program for control characters (anything in a serout [output data] that is less than 32 or greater than 127) and change them. It is good exercise and you will learn something about data formatting. The SEROUT portion of the BASIC book should also be on the table.
SEROUT LCD,32,[22,12,17] ' Clear and turn on backlight on LCD display
will not work. You will need to change it to:
Baud CON 84 ' Baud constant for 9600 Baud, no parity, 8 bits, 2 stop bits
somewhere near the beginning of your program. Similarly, you can define names for the LCD control codes to help make the SEROUT statements more understandable. If you look at a lot of Parallax's sample code, you'll see widespread use of these constant names for readability.