PING.SXB and LCD_4.SXB Together
![Bill Chennault](https://forums.parallax.com/uploads/userpics/820/n25YAQT2TKN7D.jpg)
JonnyMac--
I got your Ping demo code working perfectly in the PDB/USB SX-Key/SX-28 environment. I also got your LCD demo code working perfectly in the same environment. Since YOU wrote the code, this was not too hard for ME to do! Of course, I imagine you can guess what I did next . . . I combined the two so I could watch Ping distances on the 2x16 LCD in preparation to moving the system to my robot.
Basically, I merely stuck the PING.SXB code into the LCD_4.SXB code. I moved the Ping port to RC.0 and added the WORD variable "distance" to the variable declarations. (I also stripped out LCD_BIN, LCD_HEX, and the smiley face code and data.) I made the pullup statements look like this . . .
· PLP_A = %0000
· PLP_B = %0000_0000
· PLP_C = %0000_0000
It doesn't SEEM to make a difference.
It doesn't quite work. Although the LCD display updates in a linear manner as distance changes, the numbers are wrong. I wonder if I do not understand something about sending your PING.SXB WORD variable "distance" to your LCD_4.SXB LCD_DEC subroutine?
The comingled code is attached. The changes are simple and as outlined above.
Got a minute? [noparse]:)[/noparse]
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.
I got your Ping demo code working perfectly in the PDB/USB SX-Key/SX-28 environment. I also got your LCD demo code working perfectly in the same environment. Since YOU wrote the code, this was not too hard for ME to do! Of course, I imagine you can guess what I did next . . . I combined the two so I could watch Ping distances on the 2x16 LCD in preparation to moving the system to my robot.
Basically, I merely stuck the PING.SXB code into the LCD_4.SXB code. I moved the Ping port to RC.0 and added the WORD variable "distance" to the variable declarations. (I also stripped out LCD_BIN, LCD_HEX, and the smiley face code and data.) I made the pullup statements look like this . . .
· PLP_A = %0000
· PLP_B = %0000_0000
· PLP_C = %0000_0000
It doesn't SEEM to make a difference.
It doesn't quite work. Although the LCD display updates in a linear manner as distance changes, the numbers are wrong. I wonder if I do not understand something about sending your PING.SXB WORD variable "distance" to your LCD_4.SXB LCD_DEC subroutine?
The comingled code is attached. The changes are simple and as outlined above.
Got a minute? [noparse]:)[/noparse]
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.
SXB
![](/plugins/FileUpload/images/file.png)
10K
Comments
I made some updates to your program -- others may offer up better ideas.
* changed OSCHS1 to OSCXT1 since you're running 4MHz
* removed pull-up enabling on pins that are being used
* replaced LCD_DEC with a newer version I had on my system
Note that I have several Propeller projects in development on my desk and cannot take the time to duplicate your circuit -- you'll have to test this code and make any final fixes.
Note: For reasons I don't understand, the forums won't let me attach a .SXB file so I added .TXT to the name.
Thanks for again taking time to help. When I get it up and running, I will be sure to share your work on the forum!
Strange about that NOT .SXB thing.
My wife is a Windows professional. (Poor girl.) I'll ask her if she has ever run into anything like that.
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.
It works!
I want to thank everyone that helped me with this project on two different forums and three or four threads.
The ORIGINAL code worked. The problem was (probably me) that the LCD_DEC subroutine refused to convert to inches and, instead, converted to centimeters. So, I simply commented out the conditonal compilation directive and statements involving centimeters and left the inch conversion untouched. The final program may be reduced in size depending on what you need the LCD to do. All I want it to do is display the word "Distance: " and the distance in inches. The original LCD demo code (LCD_4.SXB), which is great, will do a LOT more than that, but I took a lot out that I did not need.
Worked like a charm.
Although several folks helped with this project, the code is JonnyMac's. All I did was adapt it (very little) to my particular environment by combining two separate programs. My environment CURRENTLY consists of a PDB/USB SX-Key/SX28, Parallax's Ping and parallel 2x16 LCD module. In the process of putting it all together, I learned about the suspected flakiness and fix for the USB SX-Key, an issue with the SX48 module that prevented it from working with the USB SX-Key in Debug mode, and the fact that I really should wear my reading glasses. (The SX48 modules are having a tiny fix applied even as I type.)
My goal is to move the entire thing to the SX48 module on my robot and let Ping keep it from running into stuff as it chases my wife's cats. (Infrared, maybe?) Anyway, the code is attached if you need a base from which to build an SX/Ping/LCD machine. When I get it moved to the SX48, which will include a simple navigation program, I will post that, as well.
Thanks to all, again.
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.