----- Original Message ----- From: Azrael To: Sent: Wednesday, October 13, 1999 5:53 AM Subject: What's in the train? The whole story. > Ok, since this post has gotten so many replies and gone off on more > tangents than i thought possible I'll give the concept I'm working on. And > maybe clear up some of the confusion that has arisin from my analogy. > > The real project is designing "smart" building-blocks. Around the size > of Duplo blocks or other large "Lego" like blocks. The goal is to create a > set of blocks that can do math when connected in a correct order. There > will be number blocks, addition, subtraction, multiplication, and division > blocks. All of them are like the cars in the train. The Equals block works > like the engine to gather the order and type of block conected to it and > computer the equation. With such a small size, electrical contacts seem the > most inexpensive way to go. My buget is as low as I can make it. The lower > the better. I went for a PIC that would just meet my needs (at $.90 > wholesale) and plastic and phone jack connectors for my contacts. The block > is being desiged by another group memeber but we are looking at cents each. > The blocks cannot be plugged in backwards, they have a front and back. > > Dan Larson made a nice picture to illustrate this > > > ----- ----- ----- ----- ----- > | |---->| |---->| |---->| |---->| | > | 7 | | = | | 5 | | + | | 2 | > | |<----| |<----| |<----| |<----| | > ----- ----- ----- ----- ----- > > Speed is pretty much not an issue, under a second is fine. In reality it > should do it in a fraction of that. > > The Equals block is going to be an impresive bit of code, we have a lot more > blocks than just numbers and simple math. Since all the others are just > slaves with an ID code, it all lies in there. > > If anyone has any input still, I'm still open. This is the second try at > this project, now with a PIC chip and i hope i can acomplish my goal. > > -Stu > This is by no means a trivial problem, and most of the posts I've read seem to go off into the ins and outs of data comms between blocks, and how this is best implemented. For my part, I think that an analysis of the functionality should be your first objective. No one appears to have mentioned the problem of determining the correct mathematical syntax. i.e number-operator-number-equals-number(and possibly more operators & numbers) If you are going to model an equation, it would seem prudent to allow the equal block to be the master in the system. You could then interogate exressions to the left and right and check for equality (and correct syntax). This cuts out the need for anything but the most simple display indicator, perhaps a bi-colour LED. You might wish to reward an equality with a pleasing tune, and errors mathematical or syntax with other tones (easily done with the lowliest PIC). You may be able to prevent syntax error mechanicaly by keying the blocks such that a connection cannot be made between two operators for example. This would simplify the code. On the other hand, you may deliberately want to allow syntax errors to improve the learning content of the toy. I assume you wish to operate with integers, but this throws up a problem with division. Also there is the problem of operator precedance with division and subtraction as x/y <> y/x and x-y <> y-x. This necesitates that each be able to determine its position within the expression and pass this to the master directly or to its neighbour for onward transmission. The far left block, having an unloaded port, could pass a data byte to the right, the next block adding its own data byte, passing two data bytes to the right, the next block adding its data etc, etc ... Until the data string (of whatever length) hits the equal block for processing. An identical method could be used for reading to the right of equal block. A simple charcter based start/stop protocol would be perfectly adequate. This bucket brigade type approach would appear to be the only solution as you have only the open ends and the blocks adjacent to the master as positional references. An asynchrous system would not be able to determine position, as you have no knowledge of which block is answering the interogating call. There is also the aspect of two digit numbers - are two adjacent number blocks to be considered as a two digit number? Again this would require to master to have positional knowledge of the blocks. It may be helpful to restrict you spec, if you need to get a conceptual demonstrator up and running quickly. I make no attempt to suggest a detailed method of implementation here, as there as many equaly valid approaches. Ask ten engineers - get eleven possible solutions ! Congrats on an interesting and thought provoking post ! This list needs more of these ! Good PIC'in Mick