1. 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!
  2. 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
  3. 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

Simulated Wind using MonsterMoto and ArduinoUno

Discussion in 'SimTools compatible interfaces' started by SilentChill, May 15, 2015.

  1. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    18,443
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    132,002Coins
    Ratings:
    +10,205 / 48 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    They will receive a notification from my comment.
  2. MagicEdge

    MagicEdge Active Member Gold Contributor

    Joined:
    Oct 3, 2013
    Messages:
    131
    Occupation:
    Aircraft Technician
    Location:
    Justin' TX USA
    Balance:
    1,327Coins
    Ratings:
    +100 / 0 / -0
    My Motion Simulator:
    6DOF
    I tried to download Gamedash and Windows 10 notified it has a trogon in it and stopped the download. Any reason why this happened?
  3. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    18,443
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    132,002Coins
    Ratings:
    +10,205 / 48 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    • Informative Informative x 2
  4. ART FLY

    ART FLY Gettin' High on DIY :) Gold Contributor

    Joined:
    Jan 18, 2020
    Messages:
    116
    Occupation:
    Bavarian State Theater, Decoration Stock Manager
    Location:
    BAVARiA
    Balance:
    418Coins
    Ratings:
    +68 / 0 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino


    I just uploaded this superfast video :popcorn on how I got my wind sim with the
    great help of SilentChill, ZED, Avenga76, NoorBeast.
    Might be informative & very funny for you too - if you like broad bavarian-alpine accent :grin
    All stay safe,
    Greetings from BAVARiA,
    Yours ARTi
    • Like Like x 1
    • Winner Winner x 1
  5. robjos1

    robjos1 Member

    Joined:
    Jun 17, 2018
    Messages:
    49
    Occupation:
    Flying about
    Location:
    United Kingdom
    Balance:
    18Coins
    Ratings:
    +38 / 0 / -0
    My Motion Simulator:
    6DOF
    Has anyone managed to get this code working with FlyPT Mover, it works perfectly in the arduino IDE but I believe due to the Binary output the S,R or L commands don't seem to be working and cant get it running. I've tried most combinations of "S<WindAxis>" or "[R<WindAxisR>][L<WindAxisL>]" in the output
  6. Zed

    Zed VR Simming w/Reverb Gold Contributor

    Joined:
    Apr 4, 2017
    Messages:
    1,035
    Location:
    USA
    Balance:
    5,722Coins
    Ratings:
    +1,027 / 4 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    The input code I wrote won’t work with binary data but it should be easily modified. It’s one byte per character so you see S100 as four chars. In binary it could be two or four values depending if the digits are sent individually or as a single number since a byte can range from 0 to 255. But you need to know the format of the data from FlyPt to rewrite the input routine.
    • Informative Informative x 1
  7. robjos1

    robjos1 Member

    Joined:
    Jun 17, 2018
    Messages:
    49
    Occupation:
    Flying about
    Location:
    United Kingdom
    Balance:
    18Coins
    Ratings:
    +38 / 0 / -0
    My Motion Simulator:
    6DOF
    Thanks, So basically Mover is sending the letters as Binary so for example L<WindL> becomes 076 XXX where XXX is 0-255 based on the wind data.

    I've tried changing if (bufferArray[0] == S ) //S to if (bufferArray[0] == 255 ) //S and limiting the outputs to less and using <255><Wind> in Mover but that dosen't seem to work
  8. Zed

    Zed VR Simming w/Reverb Gold Contributor

    Joined:
    Apr 4, 2017
    Messages:
    1,035
    Location:
    USA
    Balance:
    5,722Coins
    Ratings:
    +1,027 / 4 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    Is FlyPT sending the “S” character? If it is you would want to test if bufferArray[0]=083 for S and not 255.

    After it gets the start character (R,L, or S), it gathers the digits and builds the value by multiplying each char by the value of its position (hundreds, tens, ones) and adds them together to get the numerical value to use for the PWM for the fans. If the number is coming as a single byte, that’s already done and you should just bounds check it before using it to set the PWM.

    It’s been a while since I looked at the code but it first spins until it gets a valid start char (R,L, or S) and then reads the digit chars. You may need to look at how it does that because if it’s waiting for 3 chars and FlyPT is just sending one byte value, you’ll need to adjust what it’s looking for or it may not appear to complete and progress to setting the PWM.
  9. robjos1

    robjos1 Member

    Joined:
    Jun 17, 2018
    Messages:
    49
    Occupation:
    Flying about
    Location:
    United Kingdom
    Balance:
    18Coins
    Ratings:
    +38 / 0 / -0
    My Motion Simulator:
    6DOF
    So when I try that I get a 'invalid digit "8" in octal constant' error
  10. Zed

    Zed VR Simming w/Reverb Gold Contributor

    Joined:
    Apr 4, 2017
    Messages:
    1,035
    Location:
    USA
    Balance:
    5,722Coins
    Ratings:
    +1,027 / 4 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    @robjos1 - I am not at my computer to look at the last code revision but was looking at some older code here in other’s posts that looks current (but maybe isn’t so caveat). Anyway, I used int for the input array characters. I don’t remember using any octal variables so if you can post the line throwing the error, variable declarations, and some code ahead of the error. At any rate, octal’s range is 0-7. 8 is invalid in octal. I used int since each digit can have values 0-9 but I had to convert the characters 0-9 to numeric values of 0-9 and that’s why the -48 in the line where I turn the hundreds, tens, and ones into a number value. All outside the range of octal.

    if FlyPT is using octal coding, you’ll need to sort that. I don’t have FlyPT so can’t easily troubleshoot actual code. I put lots of hopefully accurate comments in so hopefully that helps with the code troubleshooting.
  11. robjos1

    robjos1 Member

    Joined:
    Jun 17, 2018
    Messages:
    49
    Occupation:
    Flying about
    Location:
    United Kingdom
    Balance:
    18Coins
    Ratings:
    +38 / 0 / -0
    My Motion Simulator:
    6DOF
    Thanks for the commenting, was helpful and for the replies here.

    The Buffer array is defined at the top as:

    int bufferArray[4];

    ----------------
    Code exerpt below:
    -----------

    void ReadData()
    {
    // We need 4 characters - the command followed by three digits

    bool haveCommand = FALSE;
    bool haveStart = FALSE;

    while (haveCommand == FALSE) // can't exit until have a full valid cddd command
    {
    // where c is a valid char and ddd is a valid 3
    // character representation of three digits

    // Valid command always starts with an S (legacy for both fans), L (left fan), or R (right fan)
    while (haveStart == FALSE)
    {
    while (Serial.available() == 0); // spin and wait for data
    bufferArray[0] = Serial.read(); // have data, read it

    if (bufferArray[0] == 'S' ) //S
    {
    whichFan = BOTH;
    haveStart = TRUE;
    }
    else if (bufferArray[0] == 'L' ) //L
    {
    whichFan = LEFT;
    haveStart = TRUE;
    }
    else if (bufferArray[0] == 'R' ) //R
    {
    whichFan = RIGHT;
    haveStart = TRUE;
    }
    }

    // Now need the numbers - will just read three and throw them away if any don't qualify
    // if we unsynchronize, it will fail valid digits and go back to waiting for command char
    for (int i = 1; i < 4; i++) // read and label each byte.
    {
    while (Serial.available() == 0); // spin and wait for each character to arrive
    bufferArray = Serial.read(); // store as they come in
    }

    // Check the numbers for validity
    if (isDigit(bufferArray[1]) && isDigit(bufferArray[2]) && isDigit(bufferArray[3]))
    // all are numbers - have a full cddd command
    haveCommand = TRUE; // otherwise start over looking for a new and valid command
    }
    // Now turn that into a number and clip to 255 - rely on Game Dash for proper scaling
    Speed = ((bufferArray[1]-48)*100) + ((bufferArray[2]-48)*10) + ((bufferArray[3]-48)*1);
    //Serial.println(SpeedGameDash);
    if (Speed > 253)
    Speed = 253;
    }
  12. Zed

    Zed VR Simming w/Reverb Gold Contributor

    Joined:
    Apr 4, 2017
    Messages:
    1,035
    Location:
    USA
    Balance:
    5,722Coins
    Ratings:
    +1,027 / 4 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    But where did you get the octal error you mentioned? If it was in the compile in the Arduino environment it will give you a line number and we need the instruction in that line with the code around it for context.

    The last version I posted compiles clean or at least used to and I wouldn’t expect that to change. The code you posted looks unmodified. Am I missing something?
  13. robjos1

    robjos1 Member

    Joined:
    Jun 17, 2018
    Messages:
    49
    Occupation:
    Flying about
    Location:
    United Kingdom
    Balance:
    18Coins
    Ratings:
    +38 / 0 / -0
    My Motion Simulator:
    6DOF
    Yes that's the original code. I tried to change if (bufferArray[0] == 'S' ) //S to if (bufferArray[0] == 083 ) //S and that triggered the octal error on that line.
  14. Zed

    Zed VR Simming w/Reverb Gold Contributor

    Joined:
    Apr 4, 2017
    Messages:
    1,035
    Location:
    USA
    Balance:
    5,722Coins
    Ratings:
    +1,027 / 4 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
  15. pmvcda

    pmvcda aka FlyPT

    Joined:
    Nov 3, 2010
    Messages:
    1,720
    Location:
    Portugal
    Balance:
    13,267Coins
    Ratings:
    +1,869 / 14 / -0
    My Motion Simulator:
    6DOF
    • Winner Winner x 1
  16. Zed

    Zed VR Simming w/Reverb Gold Contributor

    Joined:
    Apr 4, 2017
    Messages:
    1,035
    Location:
    USA
    Balance:
    5,722Coins
    Ratings:
    +1,027 / 4 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    @pmvcda - I checked your links and you are already outputting differential wind? What do you think of that? It’s something I’ve wanted for a long time with SimTools plugins but got stalled with other stuff and wasn’t able to do more than put provisions in the code to support that. You’re the first I've seen actually using it.
    • Like Like x 1
  17. pmvcda

    pmvcda aka FlyPT

    Joined:
    Nov 3, 2010
    Messages:
    1,720
    Location:
    Portugal
    Balance:
    13,267Coins
    Ratings:
    +1,869 / 14 / -0
    My Motion Simulator:
    6DOF
    Hi,
    I'm not using it, I still don't have fans.
    Someone (zeronilzero in Thanos discord) asked me for some code examples to do it, so I made this.
    The idea there, was to use yaw speed to make a difference between fans. I have no idea if that's something worth the trouble.
    But I'm curious to test. Need to get some fans.
    • Like Like x 1
    • Informative Informative x 1
  18. Zed

    Zed VR Simming w/Reverb Gold Contributor

    Joined:
    Apr 4, 2017
    Messages:
    1,035
    Location:
    USA
    Balance:
    5,722Coins
    Ratings:
    +1,027 / 4 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    @pmvcda - I’ll make the firmware slide the fan speed back and forth between my two fans just to feel if it might provide the desired sensations. I’ve never done that but should have I guess. That might be fun and simple to do and if it’s what I think it is, I’ll post the code so others can feel the wind vary from side to side. Won’t help without fans, though. :)

    It may be in actuality it’s not the sensation I imagine, or maybe it is. It wouldn’t be actual code to use in a sim. Just demo code to test the sensation and then folks can reflash back to sim code.
    • Like Like x 2
  19. Zed

    Zed VR Simming w/Reverb Gold Contributor

    Joined:
    Apr 4, 2017
    Messages:
    1,035
    Location:
    USA
    Balance:
    5,722Coins
    Ratings:
    +1,027 / 4 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    Here it is. This is a TEST/DEMO firmware strictly to let twin fan wind users try out differential wind. The wind is purely fictional/demo and doesn't use any communications with GameDash or SimTools. You have to use the Arduino Monitor utility to send it one valid command (doesn't matter which one but "S000" (cap ess-zero-zero-zero) is an example for those unfamiliar).

    To beat this horse thoroughly, this is only a demo of differential wind. Once you program this, to get back in action you will need to program your wind Arduino back with whatever code you loaded originally/last. This firmware is not a replacement for your present firmware for actual sim use and won't work for sim use.

    All this code does is wait for a valid command, and once it gets that it starts cycling the right and left fans according to a sine and cosine function - forever. It takes a reset, power off, or downloading new firmware to stop it. One fan will lead the other by 90 degrees in trigonometry speak as they both cycle from 0 to 254 wind speed. That lead/lag bit will let you feel the differential wind but not full on 180 degrees out of phase where one is full speed and the other is off at various times in the cycle. In this routine, when one fan is at max (254), or min (0), the other will be at mid value (127). So the most you will experience with this code is one fan at max and the other fan at half, or half and zero, etc. It will look like this in terms of wind speeds from the two fans:

    sine_cosine.png

    For anyone interested in the code, it really is just a sine and cosine, corrected for offset and scaled proper for the fan speed PWM signal and it just steps through angle values at an arbitrary rate. I meant to put a 50ms delay in the loop so it would approximately match the GameDash 50ms command spacing but in rechecking the code, I see I left that out. That explains why I had to play with the angle step size. There's also a Serial.println(SpeedL) still in the code but that might be handy to watch the numbers for fan speed scroll by. Those were both mistakes I see now but it runs fine on an Arduino Uno. Anyone running on a different clock might see slightly different behaviors. Sorry about that but only noticed it when writing this stuff. I knew what I wanted to do. It just wasn't what I did entirely. :oops:

    Curious what you guys think. Close your eyes and see if you can tell what's going on. :popcorn

    Attached Files:

    • Useful Useful x 1
    Last edited: Sep 5, 2021
  20. R-power

    R-power New Member

    Joined:
    Jan 7, 2016
    Messages:
    9
    Balance:
    29Coins
    Ratings:
    +1 / 0 / -0
    My Motion Simulator:
    3DOF
    @noorbeast and all of You

    dears
    ivo from italy
    i am a complete noob on these wonderful things
    i have bought a used kit for simulated wind that was built following this topic
    the previous owner used it with simtools

    i want to use it with simhub since there i manage already shakers, buttkickers and vibrating pedals
    i usually use iracing mainly

    BUT..... i am completely ignorant of what to do.....
    my pc sees the wind sim as COM7 but i think i must manage the "stetch area"...
    but i do not know in which way

    Do someone has already done and is able to drive me ???
    Obviously i can send paypal for this very helpful help

    thx so much

    upload_2021-12-28_19-1-16.png