Elvas Tower: Using Arduino devices with Open Rails - Elvas Tower

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Using Arduino devices with Open Rails Rate Topic: -----

#1 User is offline   cesarbl 

  • Conductor
  • Group: Status: Active Member
  • Posts: 395
  • Joined: 30-March 20
  • Gender:Male
  • Simulator:Open Rails
  • Country:

Posted 08 May 2023 - 09:25 AM

Yesterday a new feature was included to the Testing release: the web server now allows controlling trains with external devices. It was already possible to obtain the state of indicators and gauges via a GET HTTP request to the /API/CABCONTROLS page, but now you can also do POST requests, e.g. to use a potentiometer to move the throttle.

Additionally, I'm developing a glue program that connects to the Web Server and Arduino devices to allow communication between them, using a text-based protocol. https://github.com/I...leases/tag/v0.1

I upload here the Arduino source code we are using. It allows controlling Throttle+Dynamic Brake, Cruise Speed, Train Brake (PBL2 style), Engine Brake, Reverser, Pantographs, Circuit Breaker, Horn, LZB... and it gets information from OR to move two dials (ammeter and line voltage).

I hope I can find some time to write proper documentation for all these things, but in the meantime I'll be happy to answer any question if someone is interested.

Attached File(s)



#2 User is offline   VAPOR3D 

  • Conductor
  • Group: Status: Active Member
  • Posts: 268
  • Joined: 15-March 20
  • Gender:Male
  • Location:Barcelona, Catalunya
  • Simulator:Open Rails
  • Country:

Posted 08 May 2023 - 05:18 PM

Hello everyone!

Very good job, Cesar. I had a RailDriver but I sold it, as it takes up a lot of space and I don't drive much, I prefer to dedicate myself to design. But all this is very useful and interesting in a serious simulator, like the one I have seen you are setting up. I take this opportunity to congratulate you from here, Bravo!

#3 User is offline   Eldorado.Railroad 

  • Foreman Of Engines
  • Group: Status: Contributing Member
  • Posts: 982
  • Joined: 31-May 10
  • Gender:Male
  • Country:

Posted 08 May 2023 - 06:05 PM

View Postcesarbl, on 08 May 2023 - 09:25 AM, said:

I upload here the Arduino source code we are using. It allows controlling Throttle+Dynamic Brake, Cruise Speed, Train Brake (PBL2 style), Engine Brake, Reverser, Pantographs, Circuit Breaker, Horn, LZB... and it gets information from OR to move two dials (ammeter and line voltage).


Hi,

Interesting that this is being connected to a microcontroller, like the Arduino (Uno?).

Do you have any schematics on how you have connected all of this together, maybe even a few photos?

I have not looked at the Arduino in some time, but as I recall there is some AD conversion possible, which is why you can connect a potentiometer. Curious to see how analog meters are being connected.

But once you connect all of those switches/psu for Arduino etc, does it not take up a lot of desk space?

Thanks,
Steve

#4 User is offline   Aldarion 

  • Engineer
  • PipPipPipPipPip
  • Group: ET Owner
  • Posts: 629
  • Joined: 11-February 13
  • Gender:Male
  • Location:Lisbon, Portugal
  • Simulator:Open Rails
  • Country:

Posted 08 May 2023 - 09:25 PM

This is definetly of high interest, not only to improve a full size locomotive simulaotr but because I'm trying to get my hands on a subway full-size cab and a tramway controller.

#5 User is offline   cesarbl 

  • Conductor
  • Group: Status: Active Member
  • Posts: 395
  • Joined: 30-March 20
  • Gender:Male
  • Simulator:Open Rails
  • Country:

Posted 08 May 2023 - 11:20 PM

Quote

Interesting that this is being connected to a microcontroller, like the Arduino (Uno?).

Typically you use one of the bigger ones like the Mega, which has +40 GPIO pins. That's enough to directly connect everything without intermediate circuits.

Quote

Do you have any schematics on how you have connected all of this together, maybe even a few photos?

Wiring is pretty simple:
  • Potentiometers: connected to +5V, GND and an analog pin. You read data using analogRead(pin) function, from 0 to 1024 (https://arduinogetst...ing-diagram.jpg)
  • Buttons: one pin connected to a digital GPIO pin, the other to GND. You set pinMode(INPUT_PULLUP), and then you check if it is pressed with digitalRead(pin) == LOW (note the reversed logic due to the internal pullup resistor). https://www.arduino..../PullUp_bbd.png
  • Dials: one pin connected to a PWM capable GPIO pin, the other to GND. They are controlled using analogWrite(pin, 0-255). In our case analog meters had a variable resistor which we used to calibrate them so 5V means full range.
  • Indicators: one pin to a GPIO (with pinMode(OUTPUT)), the other to GND. You toggle them on/off using digitalWrite(pin, HIGH/LOW).


Quote

But once you connect all of those switches/psu for Arduino etc, does it not take up a lot of desk space?

Levers and switches obviously take a lot of space. But wiring is simple, and the arduino is not big, so only the controls themselves are a problem.

This is the cab we are preparing, using an old driver simulator. See that you only need one wire for each control + a common GND, so for 6 buttons you need just 7 wires.
Attached Image: 344763475_782949746460801_5692947470061394921_n.jpg

#6 User is offline   FS.E652 091 

  • Conductor
  • Group: Status: Active Member
  • Posts: 275
  • Joined: 22-April 14
  • Gender:Male
  • Location:Sicily
  • Simulator:ORTS
  • Country:

Posted 09 May 2023 - 03:59 PM

this is a great topic! thank you for sharing it, i will try with dedicated time on my rail desktop project!

#7 User is online   joe_star 

  • Fireman
  • Group: Status: Active Member
  • Posts: 209
  • Joined: 16-January 13
  • Gender:Male
  • Simulator:MSTS
  • Country:

Posted 15 June 2023 - 08:56 AM

Is there any documentation on how to use the POST request to send inputs into OR?

I have a regular throttle quadrant that I have configured via AHK script to send key stroke inputs into OR, but this seems like a much more elegant way of doing it

#8 User is offline   Heagle81 

  • Apprentice
  • Group: Status: Switchman
  • Posts: 3
  • Joined: 20-May 15
  • Gender:Male
  • Simulator:OR
  • Country:

Posted 15 March 2024 - 03:06 AM

Thanks to Cesar's guidelines and above all to the ability of Umberto, alias "656trainsim", who literally starting from scratch, wrote the Arduino source codes, to be able to interface with OR, a real driving bench of an Italian locomotive (E464 ) complete with all the real tools, taps and levers.
There is still a lot of work to do but we are on the right path!
Soon it will be the turn of instrument and diagnostic monitors...A big thank you also goes to Carlo Santucci for having implemented the safety system used in Italy i.e. the SCMT as well as other commands such as opening/closing of the loco's power circuit so as to increase realism.
Now we are working to take care of the details aiming for total realism of the machine.

Attached thumbnail(s)

  • Attached Image: E464.jpg


#9 User is offline   FS.E652 091 

  • Conductor
  • Group: Status: Active Member
  • Posts: 275
  • Joined: 22-April 14
  • Gender:Male
  • Location:Sicily
  • Simulator:ORTS
  • Country:

Posted 15 March 2024 - 07:38 AM

That is awesome!!! will be this software downloadable from others?

#10 User is offline   Csantucci 

  • Member, Board of Directors
  • Group: Status: Elite Member
  • Posts: 7,000
  • Joined: 31-December 11
  • Gender:Male
  • Country:

Posted 17 March 2024 - 03:12 AM

Here a video by Rocco (Heagle81) during a run on the E464 driving bench.
Attached File  VID-20240311-WA0003.zip (17.13MB)
Number of downloads: 26

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users