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

3DOF Arduino Sabertooth 4 x 24v wheelchair motors

Discussion in 'DIY Motion Simulator Projects' started by BartS, Sep 10, 2011.

  1. BartS

    BartS Member

    Joined:
    Oct 10, 2010
    Messages:
    156
    Balance:
    417Coins
    Ratings:
    +5 / 1 / -0
    Hey jyrki, its an LCD4884 if u want to look it up.
    I've looked up the OpenServo project it has many of handy code like 'curves' so i will read a bit more into it.

    I am trying to configure my AD interrupt, does AD mean analog digital, anyway I have managed to set up an interrupt however I can only fire the interrupt on a low - high or vise versa, when value crosses 511 center, I also tried change, rising and falling also non had the effect I was expecting of constantly firing while pot rotating.

    The code I used is like so :
    //A0-A5 (D14-D19)
    PCICR |= (1<<PCIE1);
    PCMSK1 |= (1<<PCINT8); // A0 analogpin this works but only when value hi or low
    PCMSK1 |= (1<<PCINT9); // A1 analogpin this works but only when value hi or low
    PCMSK1 |= (1<<PCINT10); // A2 analogpin this works but only when value hi or low
    PCMSK1 |= (1<<PCINT11); // A3 analogpin this works but only when value hi or low
    PCMSK1 |= (1<<PCINT12); // A4 analogpin this works but only when value hi or low
    PCMSK1 |= (1<<PCINT13); // A5 analogpin this works but only when value hi or low
    MCUCR = (1<<ISC00) | (1<<ISC01); // set to anychange

    any ideas how to get the effect I desire or is that going to overwhelm my interrupts with jittering sensors.
    Thanks Bart
  2. jyrki.j.koivisto

    jyrki.j.koivisto New Member

    Joined:
    Aug 30, 2010
    Messages:
    85
    Location:
    Finland
    Balance:
    314Coins
    Ratings:
    +3 / 0 / -0
    Not looking any further of those registers I think you've set your ports on some kind of comparator mode, it's been a while since I've programmed an Atmel chip though, data sheets and application notes are you're friends. Here's someones tutorial on ADC-ints on Atmel http://winavr.scienceprog.com/example-a ... inavr.html

    Search info directly with the ATMega2560 name and family of microcontrollers, they are plenty on the net
  3. BartS

    BartS Member

    Joined:
    Oct 10, 2010
    Messages:
    156
    Balance:
    417Coins
    Ratings:
    +5 / 1 / -0
    Hi Jyrki,
    Yes they where comparator modes and thats what I thought I needed.
    I did some more digging especially into the openservo project, there code will take me quite some time to get thorough and understand btw. I found the adc function in there which lead me to do some more investigation work, with the fact that I need a quick and simple code snippet just to integrate into my system I kept on looking and found this, what do you think?
    http://www.avrfreaks.net/index.php?name ... ic&t=56429
    Is this more on the lines of what you described to do, in whole I'd say it looks pretty accurate to the function I need and how I'd want it to work. Should I be setting ADC to Free-Running Mode or not? I have to figure out the right code for my Uno and Mega also how to access different channels with the MUX.
    I have also dug out a FIR filter which I could build in. http://www.arduino.cc/cgi-bin/yabb2/YaB ... 79123369/3
  4. BartS

    BartS Member

    Joined:
    Oct 10, 2010
    Messages:
    156
    Balance:
    417Coins
    Ratings:
    +5 / 1 / -0
    Ok I got my own built AD converter working specifically for uno and mega, finally I am very pleased after 4 days and 25hrs learning an all new style of ADC jargon. ssssssshhhhheeeeeeeessssssssshhhhhhh my head is bustin.

    @ Jyrki || Kubing : where Jyrki says : Make an interrupt that reads in the AD-conversion results on it's own (maybe add a digital filter)
    My question is what kind of interrupt should this be? is this timed also, I dont think I should be polling it or should I just kick it into a free running mode on all sensors and ISR(ADC_vect) results to an array and add a timed delay before next conversion.
    Thanks for anymore help you can offer Bart

    PS I will post code of this my hard work when function ready.

    I'm going to do some timing test on this first
  5. BartS

    BartS Member

    Joined:
    Oct 10, 2010
    Messages:
    156
    Balance:
    417Coins
    Ratings:
    +5 / 1 / -0
    UPDATE : ok guys after a week of silence I have been working hard underground. I can honestly say this project has taken me far beyond the reaches that the Arduino sketch environment can offer. I've had to learn more stuff than I actually intended, to make the perfect Arduino Mega 2560 driven simulator.
    Some of the things I have been working on involve ADC thats Analogue Digital Converters and how they work with interrupts, from this I learn I can trigger an ADC to start a conversion on a channel say my front right motor input feedback pot then while thats happening I could process other code like math until it was complete then assign the new value to a variable and proceed with my math. As it is the arduino environment can bog you down waiting for a conversion to complete before continuing with the rest of the code. This can amount to many of microseconds maybe even some milliseconds per channel depending on what oscillator frequency your running at. This is a big speed improvement factor and a massive performance upgrade from the standard analogueRead function.
    Another thing I've been working on is the USART or Serial connection from PC to MC the arduino environment has a pre defined system ( Serial.begin() ) which is absolute junk if you want to use it to your timing and speed advantage, I have hardcoded my own connection and sync'ed my AVR to start refresh timing around my input from the PC the whole MC is driven by the timing of input from the PC not when the MC is ready now.
    I've also created my own code for a Ring buffer for storing my serial data and setting flags for my other main loop code to execute when I have received a complete datapacket which the arduino enviroment also disadvantages you.
    Now I have all that worked out there are still quite a few things i've got to do thats my interrupt timers and getting everything in running nice n tight, some filtering but this isnt my main focus at moment, LCD menus and options.
    I still have this problem of dealing with a laggy LCD update to work out, this is a killer to my simulators speed, but I will work it out.


    Thanks to my programming friends kubing and jyrki and the information I have gained from them. It is more work than I planned originally but I will build an industrial comercial standard simulator in the end soon.
  6. BartS

    BartS Member

    Joined:
    Oct 10, 2010
    Messages:
    156
    Balance:
    417Coins
    Ratings:
    +5 / 1 / -0
    Hi, followers of my project here is another PROJECT STATUS UPDATE,
    After another 200+ hours of programming since my last update almost 2 week ago I am happy to report I am very close to a functional system. The main program components like functions, interrupts and other routines are all built I now have only to jam it all together.
    As my code is now very big it has become all too hard to manage and so everything has been separated into externally included components from the main program which has also taken quite sometime but makes things really easy to modify.
    I am currently building a timebased multitasking framework which executes my code efficiently in key frame like intervals.
    Once this part is built it should all work musically together. Lets all see what happens in the next few days.
    Thanks for reading Bart
    • Like Like x 1
  7. bsft

    bsft

    Balance:
    Coins
    Ratings:
    +0 / 0 / -0
    Hey Man, you have been busy and persistent, well done. :D
  8. BartS

    BartS Member

    Joined:
    Oct 10, 2010
    Messages:
    156
    Balance:
    417Coins
    Ratings:
    +5 / 1 / -0
    Jyrki this is for you,
    I figured out the LCD speed problem which was killing my simulator refresh loop.
    Again I am going to attack the Arduino Environment on its slow making function.
    Direct port mapping and switching control of port high and low has resolved my LCD speed issues which directly affected my refresh loop.
    jyrki I'd like to thank you again for pointing out to me my SPI driven LCD shouldnt be the bottleneck instead it was the crap use of Arduino code in my LCD class.
    This was a long ongoing problem. Now fixed, I will sleep well tonight.
  9. BartS

    BartS Member

    Joined:
    Oct 10, 2010
    Messages:
    156
    Balance:
    417Coins
    Ratings:
    +5 / 1 / -0
    OK more hard work and good progress and I am very happy again after much research to get to where I need to be, my programming has outgrown the Arduino environment and I have fully abandoned it and started developing in the much more feature rich AVR Studio 5. My main reason for this is that the Arduino IDE rewrites alot of my stuff on compile and upload plus it packs many core files which limit my control.
    Back on with the task in hand...
  10. jyrki.j.koivisto

    jyrki.j.koivisto New Member

    Joined:
    Aug 30, 2010
    Messages:
    85
    Location:
    Finland
    Balance:
    314Coins
    Ratings:
    +3 / 0 / -0
    Nice to hear that you've made some good progress on your controller, congratulations! On embedded controllers it's always a good thing not to use busy loops as you've noticed but instead make good use of integrated peripherals and interrupts. I'm also pleased that you searched the solutions on your own and actually learned a lot in the process, it's much better to understand things than to blindly just copy code and hope it would work, good work!
  11. BartS

    BartS Member

    Joined:
    Oct 10, 2010
    Messages:
    156
    Balance:
    417Coins
    Ratings:
    +5 / 1 / -0
    Hi again guys, I have yet another >> PROJECT UPDATE << after a long time no posting here, you probably thought I was all smoke and no fire.
    I have my Arduino Mega 2560 running like the clappers now and it probably hates me the poor little thing.

    I have been working very hard on the Analogue to Digital Converter for well over a month now and as per usuall approx 10 hours per day every day. Now my target is to match and beat the pants off a pololu 12v12, it has a very good sampling resolution of 12 Bits and can read 0 - 4096 positions, the Arduino, well standard it is 10 Bits and only 0 - 1024 positions.
    I said thats just not good enough for me I need more range speed and accuracy. Well My arduino now has 12 Bit resolution infact its unlimited to 16 Bit resolution I have created an ADC monster it samples at 1Mhz not the crappy slow ass standard of 125khz this thing is now overclocked a wopping 8 times faster with 4 times more resolution and it is still a standard Arduino Mega 2560. ( I think Arduino people need me working on there software development team.)
    For all you that dont know what these numbers mean well its fast enough now to possibly provide near 300 updates to each of my 4 motors in a second. I was struggling to acheive a targeted 100 updates per second on 4 motors prior to this milestone.

    Ok its just bits and bats to be done now, I have all my code contained in classes and objects very easy to manage just assembling priority of execution now and running some tests.

    Back soon with a for another update. :clap: :D :hi:
  12. bsft

    bsft

    Balance:
    Coins
    Ratings:
    +0 / 0 / -0
    Thanks Barts, keep us informed.
  13. boss.mann71

    boss.mann71 New Member

    Joined:
    Dec 31, 2011
    Messages:
    13
    Balance:
    0Coins
    Ratings:
    +0 / 0 / -0
    Great job BartS! I just found this thread and I will be following it closely. I am new to Arduino and motion simulation and I hope I can learn from you as well. I have been playing with the Arduino UNO and MEGA and I have been looking for a starting point to get my project going. My ultimate goal is a 6DOF, but I think I will be starting with 2DOF and upgrade from there. I have not settled on a platform design yet, but I am leaning heavily towards DERIY(SATO)'s design due to space limitations.

    I have also asked a couple of friends of mine for help deciphering the motion queues from the PS3 and/or the XBOX (they made the mistake of telling me that they were a little bored and they are much better at coding than I am :D ). I hope to read the USB signal from my wheel to my computer, configure my Arduino as a USB device and send the data to my console. basically a take-off of the Kinect hack that I read a few weeks ago. Theory being that I may be able to isolate the x, y and z coordinates.

    Anyway, great work and I look forward to seeing your end result.
  14. BartS

    BartS Member

    Joined:
    Oct 10, 2010
    Messages:
    156
    Balance:
    417Coins
    Ratings:
    +5 / 1 / -0
    Hi Boss mann,

    I can tell you I have spent many thousand + hours in the 5month from when I started, on average 6 - 10 hours a day have gone into programing this controller in c++ class and maximum optimization levels where possible.
    Its going to be a good one, 0 - 4095 resolution on sensor readings thats 12bit at 125microseconds per sensor, acheived through oversampling.
    16bit resolution for all six axis from pc Input in 1.02 milliseconds.
    I'm tring to build a good strong solid loop right now hopefully acheive a refresh of around 5 - 10ms microseconds.
    thats approximatly the same speed your lcd monitor screen refreshes at. In a human way of thinking 100 - 200 updates ( frames per second ).
  15. djmerritt

    djmerritt New Member

    Joined:
    Feb 1, 2012
    Messages:
    11
    Balance:
    0Coins
    Ratings:
    +0 / 0 / -0
    I am new here and want to build using 90volt dc motors , does anyone know what i need to control it on x-sim ?
  16. djmerritt

    djmerritt New Member

    Joined:
    Feb 1, 2012
    Messages:
    11
    Balance:
    0Coins
    Ratings:
    +0 / 0 / -0
    thought i better give more info here i am planning to have 2 axis and do not plan to have steering or pedals as this will be for motion theater only .
  17. BartS

    BartS Member

    Joined:
    Oct 10, 2010
    Messages:
    156
    Balance:
    417Coins
    Ratings:
    +5 / 1 / -0
    >> PROJECT UPDATE <<
    Okey dokey things are pretty complexed under the hood right now, theres so many things going on between main code and interrupt it makes my head hurt thinking about it, my ADC switches from timer triggered interrupt sampling 16times 4 channels at 125us intervals to sampling 1 channel 1time every 16ms. Its driving me mental. Why have i done this? because I need to sample a human interface device, a joystick for my LCD.
    Yes Im build a multi level navigatable LCD menu so I can use it to debug my code and build in option to adjust PID on the fly rather than uploading new code every time I make a change. Working out how to build a custom menu and getting my head round is turning into a massive ball ache, I have to debounce buttons build in new eeprom functions to save my data aaaaaaaaaarrrrrrrrrggggggghhhhhhhhhhhhhh and if ya think that aint that bad, well finding a gap in my refresh loop without affecting the timing and processing the extra code is bad + I'm getting low on RAM.
    But I think I finally got my head round it today still need to make it happen tho.

    More comming soon.
  18. BartS

    BartS Member

    Joined:
    Oct 10, 2010
    Messages:
    156
    Balance:
    417Coins
    Ratings:
    +5 / 1 / -0
    Ok I now have a full C++ class driven Menu System finally after 4+ weeks building it. It works absolutely beautifully, it has taken me so long because I wont settle for anything less than perfect but thats just me and I dont intend to come back to the same code unless its just for some small optimisation. I still have some small fear of this menu taking up to much RAM while it is on the processing stack, hence it will probably slow down my loop somewhat. This is only a problem while performing menu action which only occur on human input.

    I think I am now ready to finally start releasing some videos of my progress as it is alot easier to see whats going on with an LCD Menu system fully operational.

    Let me just build up some useful page information into my menu system and then I will post a video.

    You will be able to see how easy it is to track what is going on from errors, timing conflicts, actuator positions etc.

    This is really awesome for me and I am buzzing. :yippiee:
  19. tahustvedt

    tahustvedt Member

    Joined:
    Nov 23, 2011
    Messages:
    201
    Balance:
    62Coins
    Ratings:
    +8 / 0 / -0
    Looking forward to more info/video.
  20. hpesserl

    hpesserl New Member

    Joined:
    Jul 17, 2012
    Messages:
    1
    Balance:
    0Coins
    Ratings:
    +0 / 0 / -0
    Sorry for my English from Google Translate. I wonder how is your project. I was very curious about it. Have news? Thanks and good luck.