Shop OBEX P1 Docs P2 Docs Learn Events
Experment 14 magic 8 Ball — Parallax Forums

Experment 14 magic 8 Ball

Chris123Chris123 Posts: 7
edited 2012-12-11 11:23 in BASIC Stamp
I need to convert this 8Ball.BS2 from a parallel LCD to a Serial LCD, All I need are a few simple changes.If anybody can help me that would be greatly appreciated. Thank you

Comments

  • davejamesdavejames Posts: 4,047
    edited 2012-12-07 10:46
    ...it looks like the text in the DATA statements would become text strings imbeded in SEROUT commands.

    I'd read up on the serial LCD that you intend to use to understand it's required control characters.


    BTW - welcome to the Forum!
  • Chris123Chris123 Posts: 7
    edited 2012-12-07 10:57
    I am completely new to this so i don't truly understand what your talking about, My serial LCD is just the basic one that comes with the kit from parallax.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2012-12-07 11:24
    Welcome to the forums! I only spent about 5 mins going through this and I haven't tested it (that you can do), but here is my modifications to the original code that I believe will allow this to work. The LCD baud rate is 19.2K and the constants have it connected to P12 and the button to P15. You can change these if you wish.
  • davejamesdavejames Posts: 4,047
    edited 2012-12-07 11:48
    Well I learned something Mr. Savage - thank you!

    I wasn't aware of the ability to "alias" text strings via the DATA statement.

    That trick will certainly save memory in my current project as I've a number of SEROUTs with the same quoted text string. :thumb:

    Thanks again.
  • Chris123Chris123 Posts: 7
    edited 2012-12-07 11:49
    Thank you. I appreciate the quick response, I tested it out and Its not completely working, So far I got one error and I don't know if there are more. I am looking through and will try to pin point the errors and try to fix them as well.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2012-12-07 17:14
    What sort of error? I did a check before I saved the file and it passed the syntax check. It may not works as intended, which is possible since I didn't actually connect an LCD, however if you can explain what is not working I will take another look at it and perhaps connect an LCD tomorrow morning.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2012-12-07 17:20
    davejames wrote: »
    Well I learned something Mr. Savage - thank you! I wasn't aware of the ability to "alias" text strings via the DATA statement. That trick will certainly save memory in my current project as I've a number of SEROUTs with the same quoted text string. :thumb: Thanks again.

    Since the BASIC Stamp Modules do not have any string handling functions, per se, I would tend to handle strings of text in PBASIC in the exact same manner as I would in ASM on say a Z80. the text blocks would be encoded as blocks of zero-delimited data with labels to refer to the address of that block of text.

    When you want to print the string you need only pass the address to the routine and continue to fetch bytes and process them (in this case print them) until you get a zero. In this manner your strings can be of varying lengths and all you need to know is the start address. the LOOKUP provides an easy way to turn a linear integer into a variable offset address.

    As a note, I use LOOKUP in keyboard/keypad scanning routines to convert the return values to the appropriate ASCII values all in one line.

    Anyway, I will build the circuit tomorrow if you haven't gotten it working by then. Take care.
  • Chris123Chris123 Posts: 7
    edited 2012-12-07 22:38
    First of all my LCD is not back lit. So I commented them out. I had to change all the serout from serout TX to serout 12. Before nothing would show up on the screen and now its says possible? (+-) and it scrolls though that cycle until you push the reset button. I had to comment out 'GOSUB LCD_Command... Also the push button does not work. I hope this helps and I will check back tomorrow morn.
    Thanks Chris.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2012-12-08 13:58
    Looks like I didn't click Save on the final version I was working on. The saved file I uploaded was obviously before I fixed all the bad stuff. Whoops! Okay, I have the PDB out and a Serial LCD so I will have a look at it now and fix my original edits.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2012-12-08 14:21
    Okay, I redid everything I did last time and this time was able to test it on a PDB using a Parallax Serial LCD set to 19.2K baud. Note that I changed the I/O pin constants to 0 and 1 to make things easier to connect on this board. Changing them won't affect the code negatively. As a note, you should make the pin change in your code in the constants section rather than hard-coding the pins throughout the code.

    Also, it doesn't matter if you have the Backlit LCD or not. The code for each is compatible so no need to delete anything for this to work, even though it may have backlight commands in it.
  • Chris123Chris123 Posts: 7
    edited 2012-12-09 13:03
    Thanks Chris!! Its working great!! I Just had to switch my push button wires around and we are good to go!
    Thanks again!
    Chris
  • Chris123Chris123 Posts: 7
    edited 2012-12-11 09:32
    How would I explain how this program works and how it acomplishes its task?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2012-12-11 10:56
    Well, it sounds like a class project/homework. Which means at this point since you have a working copy you'll have to put some effort into learning how it works. You can use the BASIC Stamp Manual to explain any commands you're not familiar with. The original StampWorks project should have had an explanation of how it worked and you can see from the changes I made what the differences are. So that should narrow things down.
  • Chris123Chris123 Posts: 7
    edited 2012-12-11 11:23
    I really to apreciate it and thanks again !
Sign In or Register to comment.