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

Interface Sample Source

Discussion in 'DIY Motion Simulator Projects' started by stowaway, Jan 31, 2012.

  1. stowaway

    stowaway New Member

    Joined:
    Mar 16, 2009
    Messages:
    213
    Location:
    Gold Coast - Australia
    Balance:
    1Coins
    Ratings:
    +0 / 0 / -0
    I have been going around and around in circles, But I can not find the interface sample source that it says here:
    You will find two sample source codes. One is based on the velleman serial output to a K8063 interface and one is a input to a ADC USB interface which also use serial comunication. (USB to RS232 adapter onchip)

    http://www.x-simulator.de/wiki/Writing_ ... ofiler_2.x

    Is there any Sample Source I can look at?
  2. stowaway

    stowaway New Member

    Joined:
    Mar 16, 2009
    Messages:
    213
    Location:
    Gold Coast - Australia
    Balance:
    1Coins
    Ratings:
    +0 / 0 / -0
    ahh, I had it all along :) C:\Program Files (x86)\X-Sim\other stuff\Sourcecode\InterfacePlugin
  3. stowaway

    stowaway New Member

    Joined:
    Mar 16, 2009
    Messages:
    213
    Location:
    Gold Coast - Australia
    Balance:
    1Coins
    Ratings:
    +0 / 0 / -0
    Hi Sirnoname, What do you mean interface plugins have a bigger support in the software itself?
  4. stowaway

    stowaway New Member

    Joined:
    Mar 16, 2009
    Messages:
    213
    Location:
    Gold Coast - Australia
    Balance:
    1Coins
    Ratings:
    +0 / 0 / -0
    excuse my ignorance, as im just an amateur C# and java programmer with a course of C under my belt (not c++)..

    but how does one debug the interfaces? Im going over it line by line but I would like to do it in the debugger... But I cant run-debug a dll...
  5. stowaway

    stowaway New Member

    Joined:
    Mar 16, 2009
    Messages:
    213
    Location:
    Gold Coast - Australia
    Balance:
    1Coins
    Ratings:
    +0 / 0 / -0
    Im still playing with the interface source. Ive found a round about way to debug by just putting MessageBox's everywhere when i want to know the value of something and running the program..

    But im wondering, Is there any benifts to building my own interface as opposied to the USO?
    the reason i ask is someone has squashed my dreams of creating my own chip (im working on 2 solutions.. 1 involves using tronics design and 1 attempting my own).. But im told the Arduinos are too slow to run it smoothly (it would suck going over this line by line only to discover my hardware isnt up to scratch)?
  6. stowaway

    stowaway New Member

    Joined:
    Mar 16, 2009
    Messages:
    213
    Location:
    Gold Coast - Australia
    Balance:
    1Coins
    Ratings:
    +0 / 0 / -0
    So, is this what you are suggestng..

    The Ardunio will give Xsim the position of the pot xsim will tell ardunini move AxisX,Y until axis's are in the right spot and then tell it to stop (instead of telling ardunio the position it needs to be in and the arduino moving motors and stopping motors when in the correct position)

    is that what your saying?
  7. stowaway

    stowaway New Member

    Joined:
    Mar 16, 2009
    Messages:
    213
    Location:
    Gold Coast - Australia
    Balance:
    1Coins
    Ratings:
    +0 / 0 / -0
    great :)
    thats a good start. thanks.
  8. stowaway

    stowaway New Member

    Joined:
    Mar 16, 2009
    Messages:
    213
    Location:
    Gold Coast - Australia
    Balance:
    1Coins
    Ratings:
    +0 / 0 / -0
    I took this psydo code for the PID from http://www.arduino.cc/cgi-bin/yabb2/YaB ... 1250907652

    So, what I am workign wiht now, Is X-Sim gives me a Position where it wants Axis-x and axis-y. It has the current position of axis-x and axis-y that the ardinuo will supply it from its POTs.

    So it sends the Arduino the Proportional (error) value and the arduino will use the below formula to try and correct itself so its error is as close to 0 as possible (2 DOF 2 PID's)

    (Please let me know if im way off base)

    ...would i be just better off giving the arduino the axis-x and axis-y positions and not hte PID value.. and it can calualtor the P (error) value and correct from there..

    //stolen PID FORMULA that the arduino will do
    sensorValue = getSensor();
    previousError = error; //store the previous error
    error = sensorValue - actuatorValue; //this is how far we are from our goal
    integralPart = integralPart + error; //this is the integral part which eliminates the steady state error
    if(integralPart > antiWindUpLimit) then //here we limit the integral part
    integralPart = AntiWindUpLimit;
    if(integralPart < antiWindUpLimit) then
    integralPart = -AntiWindUpLimit;
    //this is the PID calculation
    actuatorValue = pGain*(error + dGain*(error - previousError) + iGain*integralPart);
    //this can also be written like this
    actuatorValue = pGain*error + dGain*(error - previousError) + iGain*integralPart;
    //just expanding the multiplication to understand how the change of each gain affects our system better.
    setActuator(actuatorValue);
  9. stowaway

    stowaway New Member

    Joined:
    Mar 16, 2009
    Messages:
    213
    Location:
    Gold Coast - Australia
    Balance:
    1Coins
    Ratings:
    +0 / 0 / -0
    I will have to do some more research on the theory...

    I thought hte PID was the value of the error from where something is and where it needs to be.
    I dont understand why it would only be sent once at the start and not continually through the game.
  10. stowaway

    stowaway New Member

    Joined:
    Mar 16, 2009
    Messages:
    213
    Location:
    Gold Coast - Australia
    Balance:
    1Coins
    Ratings:
    +0 / 0 / -0
  11. stowaway

    stowaway New Member

    Joined:
    Mar 16, 2009
    Messages:
    213
    Location:
    Gold Coast - Australia
    Balance:
    1Coins
    Ratings:
    +0 / 0 / -0
    So Just so im clear in my theory.

    the P - I and D values are set at the start of each game to fine tune the the speed the motors find the correct position.

    Why isnt it possible to find out values are best to get the simulator to the correct posistion and use it for every game? Why would the PID be different for different games?
  12. eaorobbie

    eaorobbie Well-Known Member SimTools Developer Gold Contributor

    Joined:
    May 26, 2009
    Messages:
    2,574
    Occupation:
    CAD Detailer
    Location:
    Ellenbrook, Western Australia
    Balance:
    20,440Coins
    Ratings:
    +1,684 / 23 / -2
    My Motion Simulator:
    2DOF, DC motor, JRK, SimforceGT, 6DOF
    ya proberly know this already the arduino has its own pid libary even explains how us adaptive pid tuning allowing code to adjus pid values when too big of an error occurs. This is where i went over me head still trying to surface.
  13. stowaway

    stowaway New Member

    Joined:
    Mar 16, 2009
    Messages:
    213
    Location:
    Gold Coast - Australia
    Balance:
    1Coins
    Ratings:
    +0 / 0 / -0
    yeah ive noticed it has a PIDlibrary...

    im a complete n00b to Andrino. (and MCU etc)
    but i thought i would design it myself rather than use library,, I didnt evne look at the library I was thikning about efficience and only including exactly what i needed for my project..

    anyway I beleive I have the theory in my head. Next step is putting it into pratice with a model sized simulator
  14. eaorobbie

    eaorobbie Well-Known Member SimTools Developer Gold Contributor

    Joined:
    May 26, 2009
    Messages:
    2,574
    Occupation:
    CAD Detailer
    Location:
    Ellenbrook, Western Australia
    Balance:
    20,440Coins
    Ratings:
    +1,684 / 23 / -2
    My Motion Simulator:
    2DOF, DC motor, JRK, SimforceGT, 6DOF
    cool i will try and find time to vid what i have done plus post the code to it, just been real busy with work life.
  15. eaorobbie

    eaorobbie Well-Known Member SimTools Developer Gold Contributor

    Joined:
    May 26, 2009
    Messages:
    2,574
    Occupation:
    CAD Detailer
    Location:
    Ellenbrook, Western Australia
    Balance:
    20,440Coins
    Ratings:
    +1,684 / 23 / -2
    My Motion Simulator:
    2DOF, DC motor, JRK, SimforceGT, 6DOF
    ok the hbridge i was testing with the arduino is from spark fun - Monster Moto Shield.
    Its a good alternative if i can get the pid of the code right.

    http://www.sparkfun.com/products/10182

    You have to wire in two pots for feedback but it is equivilant in power output as the jrks from pololu.
    It runs two of the same motor driver chips so ya get 2 for one.