Jump to content

RailMaster Programming....use of the 'repeat' command.


Guest Chrissaf

Recommended Posts

Hi Guys

I am having difficulty in implementing the repeat command in a programme.

As I understand it the repeat command with the number of repeats is inserted at the start. End repeat command is placed at the end of the programme.

I have more than likely misunderstood the instructions in the manual.

Any suggestions guys?

Cheers

Dave

Link to comment
Share on other sites

Ray (St1ng4ay), is our resident RM program expert.

.

I suggest that to help him to help you that you paste your whole program text containing your implementation of the 'repeat' command into this thread for him to review and advise.

Link to comment
Share on other sites

I have a TTS decoder test routine setup in RM that steps a decoder up and down in speed steps of ten, whilst playing all the functions one by one.

 

To endurance test the decoder I set this as a repeat event. (I certainly wasn’t going to sit and listen to a TTS decoder playing its heart out for hours).

 

That program is on the other PC but I will dig it out tomorrow and post, however essentially what you said is correct - Repeat(n) early on and Repeat end at the end, but I am not sure from memory exactly where the first bit was lodged.

Link to comment
Share on other sites

On pages 123 /124 of the manual there is this text in red. I post it here just in case it is relevant and to bring it to your attention.

.

"Note: Chained programs should not contain their own Chain commands. You must also be very careful about the use of Repeat … End Repeat loops in chained programs otherwise multiple chained commands could be repeatedly executed causing undesired effects. It is best to avoid the use of Repeat … End Repeat loops in programs you know will be chained into a master program."

Link to comment
Share on other sites

I have submitted a screen shot of my programme, as it was an image I am waiting for it to be approved by a moderator.

Meanwhile thanks for the info, this is a stand alone programme and not chained. One step at a time  😉

My aim is to totally automate the whole layout, a 2 x 4 foot N gauge. It's not enormous but very busy. RM and e link controls N gauge locos very smoothly.

The best thing with RM is that it's great fun to use and once I master the programming it will be awsome.

Link to comment
Share on other sites

David,

As the ComMods have said so many times on this forum, Community Moderators do not approve images. They can only be approved by the official Hornby forum administrator. This is why images are only approved during normal UK working office hours (but not after 3PM on Fridays). Your image won't appear until tomorrow at the earliest.

Link to comment
Share on other sites

David

 

I see you are referring to a local sound file,, maybe that should be imported into RM for it to work.

 

This is the start of my program using repeat(n)

 

/media/tinymce_upload/463d51e7a7509533635f516057ee9827.JPG

 

and this is the end of the program - notice I have and End Program command.

 

/media/tinymce_upload/0b87ecddc372216f9f42c920209a9b05.JPG

Link to comment
Share on other sites

Hello David,

At first glance I can't see anything wrong with your program. However, could you tell us.....

1. Are you running the program in the program editor window or from the main screen?

2. What, if anything, happens when you run the program?

3. Have you examined the LOG.TXT file in the RM folder after running the program?

 

Ray

Link to comment
Share on other sites

Hello again David,

 

I have reproduced your program in my Railmaster, albeit a second copy on a computer which isn't linked to a DCC controller .....

 

/media/tinymce_upload/cc68fa8f3c2b62a15d8198bd4f7cba51.png

 

I changed the addresses on the points, signals and loco to fit in with mine, and I changed the sound file to a standard RM sound. I have run the program both in the editor window and in the main screen, and it appeared to work fine. The log file shows these program runs and each run executed the repeat 5 times. 

 

So we need to know what happens when you run the program. Also, are you using the latest version of the software 1.70 rev 2 and do you have ProPack ?

 

Ray

Link to comment
Share on other sites

Hi Ray

I am using the latest version of RM, and I do have ProPack.I

I can run the programme both in edit with all lines selected. I can also it from the main screen. On both methods it runs perfectly but does not repeat.

I will 're write the programme and try again maybe it isn't reading something correctly.

I must thank you for all the effort you have put in to help me. Much appreciated.

I'll let you know the outcome of the 're write.

cheers

Dave

Link to comment
Share on other sites

Have a look at the log file after you have run the program. Has it recorded the Repeat command at the top? The log from my run via the main screen looks like this...

 

28/05/19 11:11:18 00:01 Executing: Repeat [5] Times

28/05/19 11:11:19 00:02 Executing: Switch left for: Controller: A Port: 0006

28/05/19 11:11:23 00:06 Executing: Signal clear for: Controller: A Port: 0027

28/05/19 11:11:25 00:08 Executing: Play sound: C:Program Files (x86)RailmasterSoundsL_2_Chimes.wav

28/05/19 11:11:29 00:12 Executing: Forward to shunt for: Class 25 Green

28/05/19 11:11:32 00:15 Executing: Signal stop for: Controller: A Port: 0027

28/05/19 11:11:37 00:20 Executing: Switch left for: Controller: A Port: 0003

28/05/19 11:12:07 00:50 Executing: Signal clear for: Controller: A Port: 0027

28/05/19 11:12:17 01:00 Executing: Signal stop for: Controller: A Port: 0027

28/05/19 11:12:55 01:38 Executing: Stop for: Class 25 Green

28/05/19 11:12:57 01:40 Executing: End Repeat

28/05/19 11:12:58 00:02 Executing: Switch left for: Controller: A Port: 0006

28/05/19 11:13:02 00:06 Executing: Signal clear for: Controller: A Port: 0027

28/05/19 11:13:04 00:08 Executing: Play sound: C:Program Files (x86)RailmasterSoundsL_2_Chimes.wav

28/05/19 11:13:08 00:12 Executing: Forward to shunt for: Class 25 Green

28/05/19 11:13:11 00:15 Executing: Signal stop for: Controller: A Port: 0027

28/05/19 11:13:16 00:20 Executing: Switch left for: Controller: A Port: 0003

28/05/19 11:13:46 00:50 Executing: Signal clear for: Controller: A Port: 0027

28/05/19 11:13:56 01:00 Executing: Signal stop for: Controller: A Port: 0027

28/05/19 11:14:34 01:38 Executing: Stop for: Class 25 Green

28/05/19 11:14:36 01:40 Executing: End Repeat

28/05/19 11:14:37 00:02 Executing: Switch left for: Controller: A Port: 0006

28/05/19 11:14:41 00:06 Executing: Signal clear for: Controller: A Port: 0027

28/05/19 11:14:43 00:08 Executing: Play sound: C:Program Files (x86)RailmasterSoundsL_2_Chimes.wav

28/05/19 11:14:47 00:12 Executing: Forward to shunt for: Class 25 Green

28/05/19 11:14:50 00:15 Executing: Signal stop for: Controller: A Port: 0027

28/05/19 11:14:55 00:20 Executing: Switch left for: Controller: A Port: 0003

28/05/19 11:15:25 00:50 Executing: Signal clear for: Controller: A Port: 0027

28/05/19 11:15:35 01:00 Executing: Signal stop for: Controller: A Port: 0027

28/05/19 11:16:13 01:38 Executing: Stop for: Class 25 Green

28/05/19 11:16:15 01:40 Executing: End Repeat

28/05/19 11:16:16 00:02 Executing: Switch left for: Controller: A Port: 0006

28/05/19 11:16:20 00:06 Executing: Signal clear for: Controller: A Port: 0027

28/05/19 11:16:22 00:08 Executing: Play sound: C:Program Files (x86)RailmasterSoundsL_2_Chimes.wav

28/05/19 11:16:26 00:12 Executing: Forward to shunt for: Class 25 Green

28/05/19 11:16:29 00:15 Executing: Signal stop for: Controller: A Port: 0027

28/05/19 11:16:34 00:20 Executing: Switch left for: Controller: A Port: 0003

28/05/19 11:17:04 00:50 Executing: Signal clear for: Controller: A Port: 0027

28/05/19 11:17:14 01:00 Executing: Signal stop for: Controller: A Port: 0027

28/05/19 11:17:52 01:38 Executing: Stop for: Class 25 Green

28/05/19 11:17:54 01:40 Executing: End Repeat

28/05/19 11:17:55 00:02 Executing: Switch left for: Controller: A Port: 0006

28/05/19 11:17:59 00:06 Executing: Signal clear for: Controller: A Port: 0027

28/05/19 11:18:01 00:08 Executing: Play sound: C:Program Files (x86)RailmasterSoundsL_2_Chimes.wav

28/05/19 11:18:05 00:12 Executing: Forward to shunt for: Class 25 Green

28/05/19 11:18:08 00:15 Executing: Signal stop for: Controller: A Port: 0027

28/05/19 11:18:13 00:20 Executing: Switch left for: Controller: A Port: 0003

28/05/19 11:18:43 00:50 Executing: Signal clear for: Controller: A Port: 0027

28/05/19 11:18:53 01:00 Executing: Signal stop for: Controller: A Port: 0027

28/05/19 11:19:31 01:38 Executing: Stop for: Class 25 Green

28/05/19 11:19:33 01:40 Executing: End Repeat

 

Notice that the Repeat command itself only appears in the log once, at the start of the program run, whereas the End Repeat commands are shown each time around the loop. Are either of these commands shown in your log file?

 

Ray

Link to comment
Share on other sites

So when I went back into my programme on the edit screen the "repeat end" text had changed to the figure 1.

I 're selected the repeat end and saved the change. The programme runs fine.

Including the sound file. I have closed RM and restarted it to check 

Just a thought, did I not save correctly? or was it just a gremlin? 

A further question, once I master chaining programmes together. I understand that you can't have repeat commands in chained programmes.

Can you repeat the whole chain?

Thanks for your help.

Dave

Link to comment
Share on other sites

There is a bug in the Program Editor which can occasionally cause a cell to be overwritten by some rubbish, but it is very difficult to pinpoint what causes it. I think it can happen if you click accidentally or otherwise in the body of the window while a program is running. For a while now I have intended to record a program editor session, using some third-party software called "Flashback Express", which may help in finding out when this sort of thing happens.

As far as chaining programs together is concerned, I have never tried a few chain commands wrapped up inside a Repeat loop.

There is another way of repeating a whole program using the Schedule facility in RM. What you could do is create a schedule containing a single entry at time, say, 01:00:00. To start it off you then change the main RM clock to, say, 00:59:50 and 10 seconds later your program should start up. However, to accomplish the repeat, the program needs a command as the last line in the program to reset the time once more to 00:59:50, and the process should then repeat ad infinitum.

 

I do all of my operating using RM programs and schedules. Wait till you discover the accelerate and decelerate commands - you will have great fun  😉

 

Ray

Link to comment
Share on other sites

I would think not as the starting command would be in link program 1 and the end command would be in the last program and RM would baulk at the error in each individual program.

Hi Rob,

You must have been typing while I was...

 

This might work...

 

Repeat [5] Times

Chain Program A

Chain Program B

Chain Program C

End Repeat

 

because when RM is asked to execute a program containing Chain commands, it spends a few seconds merging the chained programs together in memory into one large program, and then executes the result. The trouble is there is a fault in RM whereby it starts off the execution clock before it has finished the merge process, so if program A has commands at 1, 2, 3 and 4 seconds, these might get executed very quickly as RM tries to catch up with the clock.

 

Ray

Link to comment
Share on other sites

Once again guys, thanks for your comprehensive reply. I think my way forward is to perfect writing and mastering programmes with and without repeat loops. I will try the accelerate and decelerate commands. One thing I am certain of is the amount of satisfaction I get seeing a programme work after spending hours compiling it.

all the best

Dave

Link to comment
Share on other sites

Ray

I have notice that occasionally programs can skip the first command, so I had been getting into the habit of slipping the first command by a few seconds, but RM wants me to start at zero, so I put in a duff command to fool it.

 

I must come back up to speed with programs as I want to use them to demo the Train-Tech Smart Screen capability.

Rob

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
  • Create New...