Shop OBEX P1 Docs P2 Docs Learn Events
3PO (PHP -> Python -> Propeller) — Parallax Forums

3PO (PHP -> Python -> Propeller)

ProcessingData...ProcessingData... Posts: 208
edited 2011-04-26 12:37 in Robotics
***Update: Servo control of the laser is now supported, a chat room has been implemented, and a visitor log has also been put on the site.

Being inspired by the Orbduino, (http://www.tnhsmith.net/Other/Orbduino/index.htm)

I built this:
http://propeller.dyndns-ip.com/propeller

Why (and How) I did this:

I decided I wanted to connect my Propeller Chip to the web.
Not Having the $$$ to buy a Spinneret, I concluded Apache would have to do.

To start off, I installed Apache and PHP (Packaged in a neat little installer called XAMPP) on my Windows XP Desktop Computer.

After installing, I looked at what my Options were for communicating with the Propeller Chip over a Serial Connection.

I found that PHP could transmit to a Serial Port on windows, but not receive.
After testing a few times, I decided I did not want a One-way conversation between the Propeller Chip and The Internet.

As I was studying Python, low and behold, a Chapter Heading jumped out at me.
It Read:
Using Python as a CGI

I devoured the chapter, and wrote a Python script that would communicate with the Propeller at 115220 Baud, and wait for 1 Second for a reply.

Putting the file into my htdocs folder (where apache serves files from), I called up the file on my browser.

Nothing happened, except for Apache dumping the entire contents of the Python script to my browser.
Perplexed by this, I looked for an explanation.
I found this tutorial on how to setup Apache to run Python scripts.

After I added the *.py extension to the list of CGI scripts to run on apache, it worked fine.

A few days previous, I had bought a $2 Laser and had ripped off most of the casing, and soldered leads to it.
I connected the laser to pin 1 on the Propeller Chip, and wrote a Spin program that toggles the pin when it receives 'o1' (ouput 1), and then sends the current state of the laser on the serial port.

I then wrote an HTML page that uses XMLHTTP Request to run the Python Script when a button is pressed, and update a Paragraph Tag with the text returned from the propeller.

If you have any questions, feel free to ask them.

~ProcessingData...
Sign In or Register to comment.