1. Do not share user accounts! Any account that is shared by another person will be blocked and closed. This means: we will close not only the account that is shared, but also the main account of the user who uses another person's account. We have the ability to detect account sharing, so please do not try to cheat the system. This action will take place on 04/18/2023. Read all forum rules.
    Dismiss Notice
  2. For downloading SimTools plugins you need a Download Package. Get it with virtual coins that you receive for forum activity or Buy Download Package - We have a zero Spam tolerance so read our forum rules first.

    Buy Now a Download Plan!
  3. Do not try to cheat our system and do not post an unnecessary amount of useless posts only to earn credits here. We have a zero spam tolerance policy and this will cause a ban of your user account. Otherwise we wish you a pleasant stay here! Read the forum rules
  4. We have a few rules which you need to read and accept before posting anything here! Following these rules will keep the forum clean and your stay pleasant. Do not follow these rules can lead to permanent exclusion from this website: Read the forum rules.
    Are you a company? Read our company rules

Help understanding GameDash Data

Discussion in 'SimTools DIY Version' started by eXntrc, Dec 16, 2014.

  1. eXntrc

    eXntrc Member

    Joined:
    Dec 3, 2014
    Messages:
    35
    Balance:
    636Coins
    Ratings:
    +44 / 0 / -0
    My Motion Simulator:
    Arduino
    I'd really appreciate if someone could help me understand the format that GameDash sends numbers to a serial port device.

    In GameEngine when you setup an interface you can specify the Bit Range for the output. Am I understanding correctly that this allows you to take the full Axis range and map it down into a particular data size? For example, if the range for <Axis1> is -32767 to 32767 setting the Bit Range to 8-bit would map these values to +/- 127 or 0 to 256?

    This feature seems to be missing from GameDash and the Ard device I'm controlling uses a 4-byte command packet in the following format:

    [StartByte] [CommandByte] [Param1] [Param2]

    For example, to control the speed of the two attached motors I would send:

    [StartByte] ['S'] [128] [255]

    Where 'S' means to "set the speed", 128 is left motor at 50% and 255 is right motor at 100%.

    As you can see, I need to be able to send axis values as a single byte. I have been able to do this successfully in GameEngine but I have not been able to do it successfully from GameDash. I have figured out how to convert the dash value (meters per second) to a range of 0 - 255, but when the game runs the hardware doesn't respond in the way it does in GameEngine. I'm guessing because GameDash is sending the <Dash> values as Integers instead of Bytes.

    I could troubleshoot this using a Serial Port Monitor tool, but the cheapest 64-bit serial port monitoring tool I can find is $60 and I hate to buy it just for a single use.

    Any pointers on how to map GameDash values into single bytes?

    Thanks!
    Last edited: Dec 16, 2014
  2. bsft

    bsft

    Balance:
    Coins
    Ratings:
    +0 / 0 / -0
  3. eXntrc

    eXntrc Member

    Joined:
    Dec 3, 2014
    Messages:
    35
    Balance:
    636Coins
    Ratings:
    +44 / 0 / -0
    My Motion Simulator:
    Arduino
    Well, I answered my own question. The trick to get a single byte (or bytes) is to use TOCHR. For my example above, here's what I did:

    PERCENT 0 30
    SCALE 0 255
    ROUND 0
    TOCHR


    PERCENT 0 30 means any speed over 30 m/s will be considered 100% speed.
    SCALE 0 255 means to convert that percentage into a number between 0 and 255.
    ROUND 0 to get rid of trailing decimal places
    TOCHR to convert the value to an array of characters (bytes). Since the value can fit within a single byte, only a single byte is produced.

    Now I just wish I could figure out a way to use PERCENT 2 30. I don't want to cut down on the fans top speed but I don't want it to start spinning until at least 2 m/s. If I use PERCENT 2 30 and the value is less than 2 it actually produces negative numbers! Those can't be converted to chars.
    • Like Like x 1
    • Informative Informative x 1
  4. eXntrc

    eXntrc Member

    Joined:
    Dec 3, 2014
    Messages:
    35
    Balance:
    636Coins
    Ratings:
    +44 / 0 / -0
    My Motion Simulator:
    Arduino
    @yobuddy any chance you could add a CLAMP method to Game Dash? When we're converting to chars (bytes) we can't use negative numbers, but I think this would be helpful in other scenarios too.

    For now until I've modified the PERCENT method in my GameDash.exe to not allow numbers to go negative.


    WAS:

    if (Conversions.ToDouble(str2) > 100.0)
    {
    str2 = "100";
    }
    else if (Conversions.ToDouble(str2) < -100.0)
    {
    str2 = "-100";
    }


    (TEMPORARILY) CHANGED TO:

    if (Conversions.ToDouble(str2) > 100.0)
    {
    str2 = "100";
    }
    else if (Conversions.ToDouble(str2) < 0.0)
    {
    str2 = "0";
    }


    I'd love to help with bug fixes or feature requests if you're interested in having a contributor.

    Thanks!
    • Useful Useful x 2
    • Informative Informative x 1