Control Trainz from external application

jfl_207

New member
Hi,
I'm back to Trainz after a long break.

i'm wondering if it's now possible to control Trainz from an external apps.
I'd like to have a microcontroller device connected to my pc and then have it to control some functions of TRAINZ.
As there is a commercially available train controller on the market, i think it could be possible to do the same by myself.

thanks

Jean-Francois
 
I think by using several voice recognition programs you can speak into a microphone, and say the KB commands: H-horn, B-bell, :-Ditchlights, S stop, F-forward, Q-release, WWWWWWWW-throttle up 8 times, XXXXXXXX throttle down 8 times, AAAAAAAAAAAAAAAA-brake application full ... etc ...
 
Hi Jean-Francois and everybody.
Cascade is correct in stating you can use voice recognition programs to control trainz when driving. I have Dragon NaturallySpeaking 12.5 and it works perfectly on my system having just tested it, although I do not normally use it for that purpose

If you have Dragon and want to use it in trainz then can I suggest that you make sure that you have fully completed the audio training program to your voice. Without that you may get inaccuracies in the keys being pressed due to the background noise of the consist running. Dragon is very accurate for complete sentences with high levels of background noise but can become somewhat inaccurate for individual key presses in the same circumstances unless it is very well trained to your voice

I use Dragon NaturallySpeaking for everything that requires text typing including all I post on this forum so the software is well trained to my voice. You may also be able to use the inbuilt Windows 7 and 8 speech software but I have never used that for anything, although the reports on its accuracy are pretty good these days.
Bill.
 
Last edited:
Erm.. Its microprocessor Control he's after not microphone control

Guessing you know what you are doing with a microcontroller in which case it's a case of linking the keyboard commands to the device through a USB port, keyboard scan codes? Something like this would possibly be suitable as you can program it from a PC and then use it in the other direction to control the PC or Trainz. http://www.matrixmultimedia.com/ecio.php obviously you have to sort out the actual controls you are using to replicate the appropriate key presses and knock up an appropriate circuit board and bung it in a box. Haven't done anything like this for over 20 years but it used to be done using an eprom.
 
Hi Malc
Erm.. Its microprocessor Control he's after not microphone control

Having a second look, you are right there Malc. Coming up to the grand old age of 70 in three weeks time the old eyes aint what they used to be (well that's my excuse and I'm sticking to it)

Besides, me and the wife have been walking out on Exmoor today and with all that sunshine (although it was very cold and windy) the glare further dazzled and deteriorated the eyes temporarily so I cannot see the screen clearly and that's another excuse I'm using and sticking to.

However, a nice very large Drambuie and soda seems to be rapidly warming me up and clearing the eye situation to the extent that I am now seeing everything in HD and therefore able to recognise my error.:D

Bill
What's a microprocessor anyway?:o
 
Last edited:
Hi all,
thanks to all for your reply.
so the solution will be to create a custom keyboard.
one last question : For the moment throttle up or throttle down is done by pressing many times the same key, could it be possible to have one key assign to each step of the trhottle.
I think that's where script could come to the rescue, but as i'm far from being used to it, is there any expert in the area ?

jean-francois
 
May I ask what micro controller you are using? I have built a setup using a Arduino Leonardo, and have been quite successful. I am thinking about putting the code up when I am done, but I am nowhere near being done yet. I have mine run via keyboard control, but have used various if statements to give me different numbers of button presses per notch. It can currently control steam and diesel, but not electric yet.
 
Hi,
i'm working with the pic series from microchip.

when you say "I have mine run via keyboard control, but have used various if statements to give me different numbers of button presses per notch" will you say that for each notch you reset to no throttle and then send as many throttle up or throttle down command as needed ?

jean-francois
 
Using an Arduino Esplora for Trainz

Hi,
I'm back to Trainz after a long break.

i'm wondering if it's now possible to control Trainz from an external apps.
I'd like to have a microcontroller device connected to my pc and then have it to control some functions of TRAINZ.
As there is a commercially available train controller on the market, i think it could be possible to do the same by myself.

thanks

Jean-Francois


Hi Jean-Francois,

I have programmed an Arduino Esplora micro controller as a programmable controller for Trainz 12. It works very well and makes driving (in DCC mode) very enjoyable. This was my first Arduino project and took me about 3 days to program.

The following link shows my controller in action:
https://www.dropbox.com/s/b0y76mydtxsl7u7/IMG_2165.JPG

For general information about the Arduino Esplora, see
http://arduino.cc/en/Main/ArduinoBoardEsplora#.UxgR3dyefbQ

This is the arduino sketch (the source):
https://www.dropbox.com/s/61jo3esucmyjl62/Esplora_Trainz_Controller.ino
(Arduino software 1.5.5-r2 or later must be installed on your pc or mac to view the sketch)

The buttons of the Esplora handle the following actions:
top button - toggle map mode
left button - pause
right button - toggle forward switch (turnout). Direction depending on driving direction.
Reverse button - toggle driving direction (handled internally in Esplora)

The linear potentiometer sets the DCC throttle

The joystick can be toggled to two different states by pushing it down

First state:
left - view direction towards left
right - view direction towards right
top - Zoom in
down - Zoom out

Second state:
left - move backwards in consist
right - move forward in consist
top - view direction upwards
bottom - view direction downwards

The LCD display also shows the consumpion of a supply (for example water for a steam engine, or diesel
for a diesel engine). The supply lasts for approximately 30 minutes at full throttle. To reset the supply level to maximum, the "reset" button on the esplora needs to be pressed. This supply level is not connected to any internal supply level in Trainz, because the Esplora has no knowledge of any Trainz internals (no two way communication). But it makes driving in DCC mode much more interesting. Reset the supply level only at the corresponding refill station in Trainz.
If the supply has been used up, the engine cannot be moved any further. The LED is green, if the supply is above a 10% level, below it is red. It is blue, if the second state has been selected for the joystick.

The controller works for both PC and Mac versions of Trainz.

This solution is of course only for people who enjoy to do a bit of programming. You might have to slightly adjust the sketch depending on the keyboard you use on your computer.

Rene
 
Last edited:
I wonder if anyone is using Actions for iPad, its a very useful app and easy to program. It connects via Bluetooth you can have as many buttons as you want each one operating a keyboard shortcut.
here is a link http://getactionsapp.com/ there are also some videos on youtube.
If you already have any iPad its a cheap option.

John
 
Last edited:
All of those solutions are fine.
But it would be nice to have access to some api to be able to get direct access to the settings.
if you look at the flight sim series, there is a dll that you can add as a reference and then you are able to control all aspect of the sim via an custom app that you write as you will.
could we dream that Auran will one day provide us with the same thing ?
 
Back
Top