I ROBOT!
BlitzPlus Forums/BlitzPlus Programming/I ROBOT!
| ||
WOOHOO! I finally got Blitz to send a message through the serial port! Ok, so I'm building a robot. I will use an old P3 desktop for the main AI and video. I am also using a BasicStamp micro-controller(mc) to manage the sensors(2 ultrsonic range finders, GPS, tri axle accellerometer, compass) and work the servos and drive. I am writing the main interface in b+, which gives me a fairly easy GUI and graphics capability. And communication between the PC and MC will be conducted via the COM1 serial port. Well today for the first time I was able to send a message from blitz to the mc via a DLL I wrote (with lots of help) in C++. All I can do is turn a LED on and off but IT WORKS.... The only bug is... I have to send messages twice for the MC to see it..... so time to debug. :) |
| ||
Sounds mabye like a problem with the robot's receiving end. I've studied some robotics before. How exactly are you sending the messages to the robot exactly? |
| ||
Found the problem, just needed to add a blank byte to terminate the send..... How am I sending it.... ?..... 9600 buad 8N1 over COM5 via a DLL I wrote that utilizes the win32 API functions createfile, read and write. My send functions work great now! :) I just finished writing the receive function so I get to test those tonight. I will update this thread from there :) |
| ||
I did the same years ago, never wrote the dll, downloaded it (Cannot remember where from), basically, I was just sending flags out of the port, and they were getting picked up by a chip programmed with PIX (Or something like that) It was to run motors, very interesting project at the time! :) Dabz |
| ||
SUCCESS! SUCCESS! I can now write information to and read information from the serial ports!!!!! That later was the hardest to accomplish. I packed it all into a nice little DLL so its easy to access. In includes the functions listed below. Right now it only operates at 9600 8N1. I plan to rewrite the create function to allow different speeds, parities and data formats. I will also add a simple read(bytes%) function for more flexable reading. The current read function waits for a prompt, and reads till a terminator is recieved. Give me a couple of days more and Ill have the code available freely. create_SerialComm%(port%, speed%):"create_SerialComm@8" ; creates a serialComm object open_SerialComm%(port%):"open_SerialComm@4" ; attempts to open that serialComm object serialIn$(port%, prompt$, term$):"serialIn@12" ; blocks till port recieves the prompt and receives all characters till term is received ; returns string equale to input or "" if an error occurs serialOut%(port%, msg$):"serialOut@8" ; sends the string msg to port buffer, blocks till message is sent close_SerialComm%(port%):"close_SerialComm@4" ; closes the indicated port delete_SerialComm%(port%):"delete_SerialComm@4" ; deletes the indicated port waitString%(port%, prompt$) : "waitString@8" ; blocks till the prompt string is received via the port indicated |
| ||
Hi Moore....any news of the code for this? |
| ||
Yes, yes. The basic code to send and recieve works! :) I've been having a hardware problem though. The micro proccessor that I am using, a Basic Stamp BS2sx uses the DTR line of the serial connection to reset the processor. SO every time they talk back and forth the microprocessor restarts. BUT I've found a way allow the microprocessor to disable the DTR, I just have to finish building the adapter. The interface is coming along well enough. I can get GPS coords from my robot. Right now I am working on transforming those coords onto a cartesian plane. I hope to have this done by sept/oct. In time for the seattle robothon. :) Well that's the update. And specific questions or request? |