Journal


January 24, 2003

This week I completed two of the biggest things necessary to start this project. First, I went over to PAC and saw the CCR for the first time and now know how to start it and the basic layout of the track. Second, I am writing a journal entry, so that means my webpage is up and running (hopefully). I had two meetings with Dr. Pankratz and think I have a pretty good idea what direction my project is heading. I have even started to lay out some of the commands the low-level language will use to drive the train and make it move. The next step is to create some command for the turnouts and photocells, and then find the functions of the CCR language that would correspond to these commands. Although the website is started, it is far from complete, making another task to be completed.


February 1, 2003

This week I worked on every part of the webpage so at the very least each link is connected to page with some information on it. On the project front, I think that I have come up with the basic language that will be used to control the train, turnouts, and check the status of photocells. It is a pretty primitive language that consists of only 12 commands right now. This number might stay the same or go up depending on what I find I still need after writing some dummy programs. In order to write some programs I need to be able to compile the code that has been written, so I have begun work on the interpreter for my language and have a pretty good start. Once I am able to read the incoming language I then have to coordinate the incoming commands to the functions for the CCR which I found in the code from last year's project.
February 9, 2003

My interpreter is all but completed in the sense that it parses code coming in from a text file. I have run into some problems regarding what the functions that have already been created to run the train do, or which functions I should use. Once I am able to use these functions, I have to insert them into the code, and I should be able to make the train go through the simplest of the commands, such as start, stop, and reverse. Once I am able to do these I have to begin work on the more advanced commands such as conditionals and the actual monitoring of the train by an overlying operating system to keep everything running smoothly.
February 10, 2003

I have modified the interpreter so that it ignores white space and now has the ability to recognize comments within my language. Previously, I thought I would use the same commenting style (/*) as C, but decided instead to use something unique. My language will use opening and closing ~'s to denote comments, and they work pretty well. The most difficult part was handling comments that wrapped to a new line, but after some tinkering I figured it out. Next step is to add the "toupper" function so it doesn't matter if commands are in upper or lower case.
February 16, 2003

I have definitely made progress this week towards the final vision of my project. First, Dr. Pankratz and I had productive meeting in which a lot of the existing code was simplified down to the basic functions I need in order to get the train moving on the track. I have inserted those functions and plan to test them on Monday, due to the fact that PAC was closed on Saturday. I have also created the structure in which the track layout will be saved. It will be saved in a two dimensional array that hashes to the photocell number and then contains any turnout it is connected to and what other cells it is connected to. I also created a train struct that will serve to keep track of all the current data pertaining to a train. This includes speed, past cell, next cell, id, direction, and track direction.
February 23, 2003

With much of the code now in place that will actually run the train itself, I have begun designing other aspects of the language that do not necessarily relate to the movement of the train or physical components of the track. The first of these is a while statement. My initial idea was to store lines in a while statement in an array so they can be quickly accessed, however, an array does have a pre-determined size which would limit the language. I have also started to go back into my code and comment the functions that I have created. My program is definitely growing in size and getting harder to keep track of parts, making the comments a necessity.
February 25, 2003

A big breakthrough today in my project. We finally got the train to run using the simple DCC commands. Dr. Pankratz created a test program which I looked at and used the original DCC command file to get the trains to run. It was a nice surprise that many of the commands I have written without testing actually worked. I was able to make a train start, advance to a photocell, reverse course, advance to another photocell and stop. This sounds simple but I was extremely happy to see the train acting as it should. Now I can get to work on the overlaying "brain" of the system that will make sure the train gets where the user intends it to and that it won't crash. Today Dr. Pankratz and I also began discussing variables and symbol tables that my language may use. My next step is to make my compiler read in the commands from the file and place them into an array. This will allow for jumps in code and the ability to use simple conditionals.
March 2, 2003

I spent some more time today with the CCR and many of the commands are working. I am having some problems with the turnouts, but I think it is a hardware problem. I have converted my code so that it now works as a true compiler. My program reads in the file from the user and stores it into memory, if there are any errors in the file the user is notified and the program will not be run. I have also began investing vectors in order to make the track size dynamic. I have also changed my code to that the computer will automatically switch a turnout when the train is one photo cell away from its destination. This was a little trickier than I thought, and required stopping the train while the turnout switched to avoid the train going off the track.
March 9, 2003

The last time I was working over on the train I noticed some of my functions were acting erratically, so I wrote some small driver programs that I could test at home and get the functions to work properly. I got everthing working correctly with those functions now, and I also cleaned up a lot of my code. I noticed that I had a lot of code in multiple places and I combined this code into functions which made my program much easier to read. I also added my 4 conditional statements and the symbol table to keep track of the jumps involved with the conditionals. Since the walkthrough I have also been thinking of ways to possible upgrade to two trains and have already explored and scrapped an idea or two.
March 24, 2003

No updates in a while but it is definitely not due to lack of progress. The week of spring break gave me considerable time to get a lot done with the train system. First, I have converted to numeric opcodes for all of my commands after compile. These opcodes are followed by numeric entries denoting constants or variables. Variables are another big addition to the system. I have tested the variables out several times and everything seems to be working great. I have also added a DEC and INC function that allows a variable to be incremented or decremented by one. Using this combined with other commands I created a program that decreased the speed of the train by one at each photocell around the track. The only problem I have run into recently is racing conditions surrounding the conditionals of the turnouts and photocells. I also had a problem regarding the end statement. As soon as a train passed photocell the end would be triggered and programs would not work as planned, to combat this, the end statement only is triggered when a NEW photocell is passed. This way if a train reverses after going over a photocell, unwanted results are avoided.
March 30, 2003

Although I have yet to test my system since Tuesday, Dr. Pankratz and I decided that the racing condition could probably be taken care of with a very short delay in order to eliminate the split second where a photocell could switch from covered to uncovered. I have also tried to implement a timer that would fire every half second in order to update the current position of the train. Trying to tie together all of the commands that I have created, I put together a quick reference guide so that others can write some programs for my system for testing purposes. I have also begun work on a memory dump utility that would allow for all of the current variable values to be put out onto the screen if the user needed them.
April 6, 2003

The idea of a timer has gone by the wayside, replaced by a function that fires prior to a line of code being run, and during any down time of a delay or end command. This also helps to slow down the system so that racing conditions won't be as much of a problem. I have added some new commands like Set_TO_Dir and Get_TO_Direction which allow the user to set the TO to a certain direction and also to get the current direction of a turnout. I have also done away with the idea of an accumulator and have instead reworked the greater than, less than, and equal to commands to seem more logical. I have also reworded some of my commands making them more logical as well.
April 13, 2003

The completion of my project is definitely within sight. I have added an emergency stop to the system to that the user can kill the train at anytime while running a program. Once I started keeping a log of all current resources the train held once a photocell was reached, I came across some problems with my track data structure and how the program used the data. I fixed these problems and everything is working fine now. I also created a random number generator command. Some applications of this could include random speeds, number of times around the track, or delay times.
May 2, 2003

I finished my project and presented it on April 29th. Everything went well and the train performed as I had programmed it to. I have gone back through my code and have commented it more to explain the functionality and the data structures better. I have also created a "how to" document explaining how to write programs for the language and how to set up the track structure.