Go Back   Orbiter-Forum > Orbiter Space Flight Simulator > Orbiter Web Forum > Simpit Forum
Register Blogs Orbinauts List Social Groups FAQ Projects Mark Forums Read

Simpit Forum Share & discuss simpit projects for Orbiter here!

Thread Tools
Old 01-30-2015, 12:45 PM   #1
Default Any example code to send Orbiter values to Arduino?

Hi folks!

Hoping someone here can help point me to some sample code or the direction to go for what I'm trying to do.

I've been working on a full-scale Gemini space capsule simulator for the last year. Mechanical construction is about half done. All of the switches, dials, etc. are being duplicated. Not sure how I'm going to do the onboard computer yet but that's another story. I've made a joystick reproduction of the one found in the original capsules, and am using an Arduino Leonardo as a joystick simulator to provide those inputs to orbiter. I can also do keyboard emulation to send switch values to the program.

Where I'm having difficulty is in figuring out the best way to send values from Orbiter to the Arduino in order to drive mechanical dials. I've got dials (made using servos) for indicating altitude (during launch/reentry), acceleration, fuel levels, attitude, etc. Didn't want to use electronic MFD displays since those weren't authentic. Anyway, I've made good progress toward building all those instruments and they're controlled by Arduinos. But my weakness is in figuring out how to get the values sent over. I'm assuming I'll be using OrbConnect? Easiest thing for me would be if there is a way to send the values over a Com port since I'm familiar with Arduino serial comms. But I'm not as familiar with Windows programming. I can do VBA (like in Excel) and also C++ (as in Arduinos). I can figure out what I need to do if there is any sample code I can hack.

Has anyone seen anywhere an example of code that gets values from Orbiter and sends them over a serial interface? Really appreciate any advice that anyone can offer. Thanks!

MarcT is offline   Reply With Quote
Thanked by:
Old 01-31-2015, 12:18 PM   #2

Hello Marc,

I've done something very similar some time ago to connect NASSP to an Arduino-driven DSKY. So this might help.

It is not meant to be a generic class that can be used directly by you. It was highly specialized for the above mentioned project, but the general idea of how to operate Serial (COM) Connection is in there.

The idea behind this Serial class is as following:
  1. It is a kind of 'singleton', so I could get the one and only instance of it from any context via Serial::GetReference().
  2. It has knowledge of the data to be transmitted/received to detect if there is really a need for transmission or if nothing had changed.
  3. Periodically Serial::Transmit() would be called to transmit buffered data to the Arduino (if needed).
  4. Because of (2) Serial::Transmit() can be called in each Timestep. Real transmission will only start if the buffer contains changes.
For you to start, you should first ignore all the 'buffered' things that only make sense in the Apollo AGC/DSKY context (channel_010, channel_011, channel_013,...).
For the connection setup and transmission itself you should find enough hints on how to roll your own code. All the needed The WIN32-API calls (CreateFile, GetCommState, SetCommState, ClearCommError, ReadFile, WriteFile, CloseHandle) are in there.

Feel free to ask if you have questions,
Attached Files
File Type: zip src_sys.zip (3.9 KB, 63 views)
kuddel is offline   Reply With Quote
Thanked by:
Old 01-31-2015, 01:43 PM   #3

Hi again,

I found a simpler one (without any buffering) that makes it easier to understand the basics -I think.
Attached Files
File Type: zip serial_io.zip (2.4 KB, 28 views)
kuddel is offline   Reply With Quote
Old 01-31-2015, 11:16 PM   #4
Unicorn hunter
kamaz's Avatar

Originally Posted by MarcT View Post
  I'm assuming I'll be using OrbConnect?
If you want to use OrbConnect:

1. Start with this sketch http://arduino.cc/en/Tutorial/TelnetClient

2. Replace

if (client.connect(server, 10002)) {

if (client.connect(server, 37777)) {
3. Replace loop() with:

void loop()
  if (client.connected()) {
    // Set main engines to 50%

    // if there are incoming bytes available 
    // from the server, read them and print them:
    while (client.available()) {
      char c = client.read();

NB the above code is untested, but it should get you started

...From another thread:

Originally Posted by kamaz View Post
 Connect to TCP port 37777. Send command followed by a newline character.

Orb::Connect will reply in the form <command>=<response> followed by a newline character.

The commands you need are ORB:SimTime and ORB:TimeAccel.

See the Orb::Connect manual for more information (it installs under Doc\OrbConnect).

Last edited by kamaz; 01-31-2015 at 11:29 PM.
kamaz is offline   Reply With Quote
Thanked by:

  Orbiter-Forum > Orbiter Space Flight Simulator > Orbiter Web Forum > Simpit Forum

arduino, gemini, orbconnect, simpit, simulator

Thread Tools

Posting Rules
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Jump

All times are GMT. The time now is 07:28 PM.

Quick Links Need Help?

About Us | Rules & Guidelines | TOS Policy | Privacy Policy

Orbiter-Forum is hosted at Orbithangar.com
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Copyright 2007 - 2017, Orbiter-Forum.com. All rights reserved.