LEGO MINDSTORMS Robots Manual page 112

Unofficial guide
Table of Contents

Advertisement

First, the terminal emulator needs to know how long to wait after sending each character. In HyperTerminal (in Windows 95, 98, or NT), this setting is available in the File > Properties menu
option. In the window that appears, choose the Settings tab and press the ASCII Setup button. You should set the Line delay to 100 milliseconds and the Character delay to 20 milliseconds, as
shown in Figure 6-2.
To upload a file to pbFORTH, choose Transfer → Send Text File from the menu.
There are other options, as well. Appendix B, A pbFORTH Downloader, contains source code for a Java-based program downloader. Furthermore, the pbFORTH web site has pbFORTH tools
written in Tcl/Tk.
About Forth
In this section, I'll briefly describe the Forth language itself. Then I'll detail pbFORTH's RCX-specific words and present some short examples of robotic programming with pbFORTH.
The Stack
Forth is a simple but powerful language. It is based around the idea of a stack. A stack is just what it sounds like, like a stack of trays in one of those spring-loaded carts at a cafeteria. You can add
something to the stack or remove the top item. Adding an item to the stack is a push. Retrieving the top item is a pop. A pop always returns the last item that was pushed.
Assuming you've already gotten pbFORTH running on your RCX, let's see how this works. Let's begin by pushing a number on the stack. Type a number into your terminal emulator and hit
return. pbFORTH responds with a friendly "ok":
77
ok
Now type a single period and press return. The period pops a value off the stack and prints it out to the console, along with that ubiquitous "ok":
.
77 ok
You can push multiple values on the stack by separating them with spaces. Similarly, you can pop more than one value off the stack with more than one period, like this:
Figure 6-2.
Setting character delays for sending files
Page 121

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the MINDSTORMS Robots and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Table of Contents