BVE WorldWide
Would you like to react to this message? Create an account in a few clicks or log in to continue.

OpenBVE and Arduino

Go down

OpenBVE and Arduino Empty OpenBVE and Arduino

Post by buonsm Thu Jun 11, 2020 6:55 pm

Hi everyone!


This is my first message here. I’m a rail enthusiast since I was a child. I play (and love!) BVE/OpenBVE since 2002, on version 2.03. I play other sims too but OpenBVE is still my favourite, absolutely!


I have a question for you.


I want to build a cab controller based on Arduino. I’m able to pass to the sim the inputs read from levers and switches, through Arduino board connected via USB, but I’d like something more realistic, with live gauges, displays, lights, etc. (Arduino can handle many kinds of devices as outputs, such as stepper motors, lcd screens, addressable led strips or simple leds, it can drive transistors and relays, and so on).


But… to do so I need to get some real-time parameters from the sim (for example: instant speed, brake pressure values, safety systems related, in-game clock, etc), and the big question comes:


is it possible/do you know how to intercept such parameters direct from the sim? Is there a library or a function for doing that?
Or, maybe, does the sim write them down to a (sort of) temporary file I could read from?


Any help will be really appreciated, thank you in advance!

buonsm

Posts : 1
Join date : 2020-06-10

Back to top Go down

OpenBVE and Arduino Empty Re: OpenBVE and Arduino

Post by leezer3 Fri Jun 12, 2020 6:20 pm

Easiest method is likely to be a .Net runtime plugin attached to your train:
https://openbve-project.net/documentation_hugo/en/plugins/overview.html

This however limits you to the specific train which is designed with your plugin in mind.

The other method would be to make a custom build, and hook whatever you want into the main train update function:
https://github.com/leezer3/OpenBVE/blob/master/source/OpenBVE/Simulation/TrainManager/Train/Train.cs#L321

Simple check to make sure it's the player train, ad then pull off any parameters you want.

leezer3

Posts : 1785
Join date : 2011-08-23

http://www.bvecornwall.co.uk

Back to top Go down

OpenBVE and Arduino Empty Re: OpenBVE and Arduino

Post by AdamSantoso Mon Jul 20, 2020 4:16 am

buonsm wrote:Hi everyone!


This is my first message here. I’m a rail enthusiast since I was a child. I play (and love!) BVE/OpenBVE since 2002, on version 2.03. I play other sims too but OpenBVE is still my favourite, absolutely!


I have a question for you.


I want to build a cab controller based on Arduino. I’m able to pass to the sim the inputs read from levers and switches, through Arduino board connected via USB, but I’d like something more realistic, with live gauges, displays, lights, etc. (Arduino can handle many kinds of devices as outputs, such as stepper motors, lcd screens, addressable led strips or simple leds, it can drive transistors and relays, and so on).


But… to do so I need to get some real-time parameters from the sim (for example: instant speed, brake pressure values, safety systems related, in-game clock, etc), and the big question comes:


is it possible/do you know how to intercept such parameters direct from the sim? Is there a library or a function for doing that?
Or, maybe, does the sim write them down to a (sort of) temporary file I could read from?


Any help will be really appreciated, thank you in advance!

Did you succeed in making it?

I tried to make a simple control panel for the function of adding forward power and braking system on a single throttle train system using Arduino, but it didn't work on openBVE, but if I try it on BVE TS it works

leezer3 wrote:Easiest method is likely to be a .Net runtime plugin attached to your train:
https://openbve-project.net/documentation_hugo/en/plugins/overview.html

This however limits you to the specific train which is designed with your plugin in mind.

The other method would be to make a custom build, and hook whatever you want into the main train update function:
https://github.com/leezer3/OpenBVE/blob/master/source/OpenBVE/Simulation/TrainManager/Train/Train.cs#L321

Simple check to make sure it's the player train, ad then pull off any parameters you want.

Do I also have to make a new train plugin to be able to use the controller that I made so that it can be used in openBVE?

AdamSantoso

Posts : 20
Join date : 2012-05-16
Age : 24
Location : Bogor, Jawa Barat, Indonesia

https://madots.xyz/

Back to top Go down

OpenBVE and Arduino Empty Re: OpenBVE and Arduino

Post by leezer3 Tue Jul 21, 2020 2:17 pm

AdamSantoso wrote:Do I also have to make a new train plugin to be able to use the controller that I made so that it can be used in openBVE?

No idea without more details, sorry.

How is your controller presenting itself to Windows?
I'd guess as some sort of HID device, but I'd need to see it or the code you're using to take a look.

Have you got the source for your arduino code available somewhere on Github or anything?

leezer3

Posts : 1785
Join date : 2011-08-23

http://www.bvecornwall.co.uk

Back to top Go down

OpenBVE and Arduino Empty Re: OpenBVE and Arduino

Post by AdamSantoso Wed Jul 22, 2020 5:29 am

leezer3 wrote:
AdamSantoso wrote:Do I also have to make a new train plugin to be able to use the controller that I made so that it can be used in openBVE?

No idea without more details, sorry.

How is your controller presenting itself to Windows?
I'd guess as some sort of HID device, but I'd need to see it or the code you're using to take a look.

Have you got the source for your arduino code available somewhere on Github or anything?

I bought a new Arduino type device that will detect as a joystick when connected to a computer, and now it functions as a control panel, thanks Very Happy

AdamSantoso

Posts : 20
Join date : 2012-05-16
Age : 24
Location : Bogor, Jawa Barat, Indonesia

https://madots.xyz/

Back to top Go down

OpenBVE and Arduino Empty Re: OpenBVE and Arduino

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum