Tower of Hanoi

ftComputing : Programme für die fischertechnik-Interfaces und -konstruktionskästen
  
ftComputing.de
Home
Back
Sitemap
Index
Links
Impressum
Mail
 

Solution for the Magnet Robot and ROBO Pro

Hanoi Robot

Something more general about robot and the logic of the program on the german Hanoi-Seite

The samples of ROBO Pro contain a Hanoi Robot using the Industry Robot. It is a complex solution which uses all components of that robot.

The Hanoi-Seite shows solutions for the more simple robot above for different programming languages. On this page a solution for ROBO Pro and the ROBO Interface is discussed. You can operate it as well with the Intelligent Interface (Online Mode).

The discussed - graphical - solution corresponds in construction and naming to the textual solutions. The most interesting subs are discussed here - some notes to LLWin are included -, the complete program is contained - together with some other solutions - in HanoiRob.ZIP.

The Main Program

Look like very easy :

GStellung makes the robot run home and than to PosA.

Hanoi is the (recursive) program for the Hanoi logic. Recursive programming and parameters are not possible with LLWin.

- Constant 3 : Number of discs to be moved.

- Globla variables Pos A, PosB, PosC : Positions for the Hanoi staples. The variable are initialized to the noted values, if program starts. Constants are possible too, but with global variable GStellung can use PosA as well.

The green and the red "Männeken" start and and the program. They are used on the traffic lights in the old DDR (GDR). 

 

The Logic of Hanoi

The jumping point of the Hanoi logic is the artificial changing of the actual positions of the pile parameters to the recursive calls. The real move of a disc goes nearly undercover. This sub is nearly the same coming with the Hanoi sample of ROBO Pro. Difference : In the actual version the end of recursion is determined by n = 1 (A=1), an additional recursive level less, therefore an additional call Ziehe (Move) in the end case. The ROBO Pro solution asks for n = 0.

This is a program with many yellow lines because of the call parameters in the 6edged boxed are used several times. Return parametes are possible to, but not used here.

ROBO Pro doesn't have textual expressions (like LLWin). In this case too a graphical operator is used for subtracting n - 1. On logical expressions it is done in the same manner.

General : ROBO Pro offers a level concept from level 1 - 3. Level 1 / 2 are very similar to LLWin, but have no variables. Level 3 introduces variables and a concept of separate data (yellow) and control (black lines) flow.

ASenken : Arm down

The sub ASenken only runs the arm motor down on the gear to the end switch.

The left turn command start the motor with full speed by sending a message to the output device symbol.

The J command inside the black control flow is waiting for the message in the data flow I4 to be closed. After that motor ist stopped.

The compact level 1 commands can be used alternatively mixed with the level 3 commands to your convenience.

 

SNach : Drive to a Pile Position

SNach runs the robot to a given pile position (in terms of numbers of impulses form end switch).

The parameter ZPos contains the destination position, the global variable RobPos contains the actual position.

With the A?B command the destination position is compared to the actual, if equal destination is reached.

If destination position is greater than actual, the impulses of I2 (yellow line) were incremented to RoboPos ('+1' command) otherwise decremented. The motor is operated with full speed (left : direction of the end switch).

Notes :
Assignment operations (=, +, -) are coupled with the value belonging to it. A '-1' means a 
RobPos -= 1; in C++ notation. Alternatively values of an (e.g.) input device can be routed by a yellow pin on the right (right click to activate it) thru the command. 

The further subs are simple and only repeat the ROBO Pro elements discussed already.

Update (dd.mm.yy) : 10.03.2005