[Thread Prev] [Thread Next]
On Tue, 09 Nov 2010 17:33:06 -0500, Rotem Kimchi <rotemk2@xxxxxxxxxxxxxxxx>
It's nice to get questions maybe I could help you answer a few when I'll get
Sure. I'll welcome that :)
I did some more thinking about my project and I saw in the help guide that
microworld pro can use the computer serial port in order to transfer is
commands ... it's sounds easier than what I planned to do with the txt files I
created (translate them to binary with c++ and than send them)
I think using text files is easier... but maybe just because I've never used
serial port communication.
I will start to check it tomorrow, do you know how does the data transfer
(serial or parallel)?. Do MicroWorldPro have its own communication protocol?
No, I don't think it as a protocol. It is raw serial port communication. The
MicroWorlds Pro comes equipped with primitives that can send and receive
information through a serial port. Traditionally, these ports are used for
direct connections with a nullmodem cable or peripheral devices such as an
external modem. However, the three primitives in Primitives were designed with
the idea that someone might want to hook up a robotic device to a serial port.
In the early days of Logo, a mechanical "turtle" would carry out simple Logo
commands (such as forward 50) on a paper-covered floor!
One of the main advantages of the serial port is that it uses a standard
protocol. Information can be transferred back and forth between virtually any
two computers or devices provided they both have a serial port. Although your
computer probably has at least two serial ports, MicroWorlds can only "listen"
to one at a time. A call to a new serial port takes precedence: MicroWorlds
Pro will treat the most recently called port as the active one and ignore all
information transferred through other ports. Finally, when you quit
MicroWorlds Pro, all activated serial ports are essentially shut off.
Serial Port Primitives
.serialinit :port_number :baud_rate
This primitive activates a serial port. The first parameter is an integer
which designates the serial port. The second parameter specifies the speed of
the connection in bits per second. For example,
.serialinit "COM2 19200
activates the COM 2 serial port and sets the speed to 19,200 bps.
.setbaud :baud :parity :stop-bit
This primitive sets the baud rate, parity, and stop bit protocol for the
serial port. The first parameter specifies the speed of the connection in bits
per second. The second parameter specifies the parity with a number that
ranges from 0 to 4 (0 - no parity, 1 - odd, 2 - even, 3 - mark, 4 - space).
The third parameter specifies the stop bits with a number that ranges from 0
to 3 (0 - one stop bit, 1 - one stop bit and a half, 2 - two stop bits). For
.setbaud 2400 1 0
sets the speed of the serial port to 2400 bps, odd parity and 1 stop bit.
This primitive reads information from the activated serial port. It acts as a
reporter that returns the next byte (an integer between 0 and 255 inclusive)
or, if there is no incoming information, the integer –1.
This primitive sends a byte of information to the serial port. It accepts an
integer between 0 and 255 inclusive as the information to send.
Previous by thread:
Re: MIA, Ask an Expert: bounce
Next by thread:
Re: manipulating text files and serial port communication
To save an attachment to your computer, PC users should right-click (Mac users, click and hold the mouse button) on the link and then choose 'save target as' from the pop-up menu. A window will then pop up in which you can choose a location for the file.