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

Teensy LC/Arduino Scripts

Discussion in 'Electronic and hardware generally' started by Nick Moxley, Jan 29, 2017.

  1. Nick Moxley

    Nick Moxley Well-Known Member

    Joined:
    Dec 13, 2013
    Messages:
    2,779
    Occupation:
    Owner/Operator- Moxleys Rantals
    Location:
    Winnipeg Manitoba Canada
    Balance:
    17,054Coins
    Ratings:
    +2,504 / 30 / -2
    My Motion Simulator:
    2DOF, 3DOF, DC motor, JRK
    Winner Winner chicken Dinner(and a beer). Thanks tady. I will surely let you know if i have any questions in the future, you sure seem to know your scripts pretty well. :cheers
    • Winner Winner x 1
  2. Nick Moxley

    Nick Moxley Well-Known Member

    Joined:
    Dec 13, 2013
    Messages:
    2,779
    Occupation:
    Owner/Operator- Moxleys Rantals
    Location:
    Winnipeg Manitoba Canada
    Balance:
    17,054Coins
    Ratings:
    +2,504 / 30 / -2
    My Motion Simulator:
    2DOF, 3DOF, DC motor, JRK
    I would very much appreciate that, There will likely be standard N/O push buttons on all the other pins with a likely hood of needing another encoder added in and maybe even a 3rd encoder(but unlikely) 2 is more than enough for most guys on the wheel. Encoder's being used will be CTS 288's so simple 3 pin hook up.

    I have a shi* load of resistors but there are all poorly labeled from an Ebay seller and I tried a few times to sit down with a few color charts but its always ended in colors not matching and thing's being confusing.....when i wanted to slow down a Fan the other day, i just tried different values till i got the fan to do what i want. No clue what actual value i used. :oops:
    Last edited: Feb 10, 2017
  3. Nick Moxley

    Nick Moxley Well-Known Member

    Joined:
    Dec 13, 2013
    Messages:
    2,779
    Occupation:
    Owner/Operator- Moxleys Rantals
    Location:
    Winnipeg Manitoba Canada
    Balance:
    17,054Coins
    Ratings:
    +2,504 / 30 / -2
    My Motion Simulator:
    2DOF, 3DOF, DC motor, JRK
    Question, How can we improve the signal strength of the Rotary encoder on the Alps.....watching the Controllers window closely it seems to miss some clicks when i rotate the knob, it will be consistent for a few clicks then miss one or 2.

    Ive also now joined the Ground terminal to the com to eliminate one more wire....everything seems to work fine still.
  4. Nick Moxley

    Nick Moxley Well-Known Member

    Joined:
    Dec 13, 2013
    Messages:
    2,779
    Occupation:
    Owner/Operator- Moxleys Rantals
    Location:
    Winnipeg Manitoba Canada
    Balance:
    17,054Coins
    Ratings:
    +2,504 / 30 / -2
    My Motion Simulator:
    2DOF, 3DOF, DC motor, JRK
  5. tadythefish

    tadythefish Active Member

    Joined:
    Jul 8, 2009
    Messages:
    148
    Occupation:
    Process automation engineer
    Location:
    Slovenia
    Balance:
    676Coins
    Ratings:
    +95 / 1 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino
    The code needs optimisation. This tactics is not so good. I forgot to tell you that.. Encoders need to be read with interrupt rutines (when a pulse gets to the teensy the program stops and executes another smal program an then it returns to where it left of). This way no pulses are lost.
    But with interrupts you MUST debounce the inputs with capacitors and resistors!!

    Another theory is that only one pulse from the encoder is used to do the blinking. The other one is used just to see in what direction you turned the knob. Maybe there is no way to eliminate this...

    I will edit the code and try to improve it and i will add other NO inputs and one more encoder..

    Do you have a multimetet? I can read color codes from my head but alot of time i just measure;) (dont hold the resistor when measuring with both fingers, if you have a large value resistor you will also measure your body resistance ;) )
    • Like Like x 1
  6. Nick Moxley

    Nick Moxley Well-Known Member

    Joined:
    Dec 13, 2013
    Messages:
    2,779
    Occupation:
    Owner/Operator- Moxleys Rantals
    Location:
    Winnipeg Manitoba Canada
    Balance:
    17,054Coins
    Ratings:
    +2,504 / 30 / -2
    My Motion Simulator:
    2DOF, 3DOF, DC motor, JRK
    Ya i have a multimeter, Thanks again. :thumbs
  7. tadythefish

    tadythefish Active Member

    Joined:
    Jul 8, 2009
    Messages:
    148
    Occupation:
    Process automation engineer
    Location:
    Slovenia
    Balance:
    676Coins
    Ratings:
    +95 / 1 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino
    Ok... Now everything works... I will edit the code tonight or tomorow... How do you want the other encoder to work? The same way as the existing one or like a slider?
    • Like Like x 1
  8. Nick Moxley

    Nick Moxley Well-Known Member

    Joined:
    Dec 13, 2013
    Messages:
    2,779
    Occupation:
    Owner/Operator- Moxleys Rantals
    Location:
    Winnipeg Manitoba Canada
    Balance:
    17,054Coins
    Ratings:
    +2,504 / 30 / -2
    My Motion Simulator:
    2DOF, 3DOF, DC motor, JRK

    lets go for button presses for now, because when i think of an adjustment in say Assetto, You can assign the UP and Down Value for say TC, or ABS and same with Brake Bias, those are seen by button presses. So without having Iracing or the likes with Black box settings, i dont at the time see the need for the X/Y slider.
  9. tadythefish

    tadythefish Active Member

    Joined:
    Jul 8, 2009
    Messages:
    148
    Occupation:
    Process automation engineer
    Location:
    Slovenia
    Balance:
    676Coins
    Ratings:
    +95 / 1 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino
    How fast were you turning the encoder? Or it doesn't matter (very slow and very fast)
    • Like Like x 1
    Last edited: Feb 10, 2017
  10. Nick Moxley

    Nick Moxley Well-Known Member

    Joined:
    Dec 13, 2013
    Messages:
    2,779
    Occupation:
    Owner/Operator- Moxleys Rantals
    Location:
    Winnipeg Manitoba Canada
    Balance:
    17,054Coins
    Ratings:
    +2,504 / 30 / -2
    My Motion Simulator:
    2DOF, 3DOF, DC motor, JRK

    i couldn't seem to see a difference if i went fast or slow, it was somewhat repetitive in how it missed the clicks, but at the same time varied a bit....i didn't try super super slow, but will try that when i get a chance.
  11. tadythefish

    tadythefish Active Member

    Joined:
    Jul 8, 2009
    Messages:
    148
    Occupation:
    Process automation engineer
    Location:
    Slovenia
    Balance:
    676Coins
    Ratings:
    +95 / 1 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino
    @Nick Moxley
    Hmm then it must be a software problem... I have a mechanical encoder but the Detent points are different from yours... I will try to fix it in a few hours :)
    • Like Like x 1
  12. tadythefish

    tadythefish Active Member

    Joined:
    Jul 8, 2009
    Messages:
    148
    Occupation:
    Process automation engineer
    Location:
    Slovenia
    Balance:
    676Coins
    Ratings:
    +95 / 1 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino
    @Nick Moxley
    Please download the attachement... This is only a Encoder test... everything else was removed for easyer trouble shooting
    Encoder is connected the same way (5 and 6 pin) please test and report back if it is better or worse

    Attached Files:

    • Winner Winner x 1
    • Useful Useful x 1
  13. tadythefish

    tadythefish Active Member

    Joined:
    Jul 8, 2009
    Messages:
    148
    Occupation:
    Process automation engineer
    Location:
    Slovenia
    Balance:
    676Coins
    Ratings:
    +95 / 1 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino
    • Like Like x 1
  14. Nick Moxley

    Nick Moxley Well-Known Member

    Joined:
    Dec 13, 2013
    Messages:
    2,779
    Occupation:
    Owner/Operator- Moxleys Rantals
    Location:
    Winnipeg Manitoba Canada
    Balance:
    17,054Coins
    Ratings:
    +2,504 / 30 / -2
    My Motion Simulator:
    2DOF, 3DOF, DC motor, JRK
    sorry got busy the past few, I'll have a look at it today and let you know. Thanks :cheers
  15. tadythefish

    tadythefish Active Member

    Joined:
    Jul 8, 2009
    Messages:
    148
    Occupation:
    Process automation engineer
    Location:
    Slovenia
    Balance:
    676Coins
    Ratings:
    +95 / 1 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino
    No problem.. I just curious ;) ok ... Try it when you have time and we will try to work out the bugs:)
    • Like Like x 1
  16. Nick Moxley

    Nick Moxley Well-Known Member

    Joined:
    Dec 13, 2013
    Messages:
    2,779
    Occupation:
    Owner/Operator- Moxleys Rantals
    Location:
    Winnipeg Manitoba Canada
    Balance:
    17,054Coins
    Ratings:
    +2,504 / 30 / -2
    My Motion Simulator:
    2DOF, 3DOF, DC motor, JRK
    Ok so rolling to the left gives me input 11 lighting up but if i roll it 2-3 times quick I will get a hit on the Right Direction #12....if I roll right No matter what i do, I Do Not get a 11 glitch, So something is different between the left and right encoder
  17. tadythefish

    tadythefish Active Member

    Joined:
    Jul 8, 2009
    Messages:
    148
    Occupation:
    Process automation engineer
    Location:
    Slovenia
    Balance:
    676Coins
    Ratings:
    +95 / 1 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino
    So basicly it works better?
    • Like Like x 1
  18. Nick Moxley

    Nick Moxley Well-Known Member

    Joined:
    Dec 13, 2013
    Messages:
    2,779
    Occupation:
    Owner/Operator- Moxleys Rantals
    Location:
    Winnipeg Manitoba Canada
    Balance:
    17,054Coins
    Ratings:
    +2,504 / 30 / -2
    My Motion Simulator:
    2DOF, 3DOF, DC motor, JRK
    i went back and forth between 2.1 and 2.2 its marginally better, but not i question how sensitive the game will be to those micro presses, I really need to fire it up, IN game and see how it responds to those mis clicks.
  19. tadythefish

    tadythefish Active Member

    Joined:
    Jul 8, 2009
    Messages:
    148
    Occupation:
    Process automation engineer
    Location:
    Slovenia
    Balance:
    676Coins
    Ratings:
    +95 / 1 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino
    I will post the complete version.. But I doubt we can get a better response...
    The main problem here is the encoder.
    There are two types of encoders , mechanical and optical.
    Mechanical have problems with debounce because they have switches inside that get pressed in a certain order when you turn the shaft.
    Optical encoder work differently. They have a glass dick inside that has black lines on it. They pass trough two light barriers. The fotoresistors record the lines that pass trough.
    Otical encoders don't have debounce problems and can be turned very fast.
    Chinese clones can go up to 5000 rpm.
    In your case i don't think you will find any optical types that include the d-pad.
    But manufacturers typically have these switches custom built and have some kind of pulse shaping schmitt triggers between the encoders and microcontrollers.
    The biggest problem is that I don't have one of your d-pads. So i can't test myself.
    I will post you the complete version amd you will test
    • Winner Winner x 1
    • Informative Informative x 1
  20. Nick Moxley

    Nick Moxley Well-Known Member

    Joined:
    Dec 13, 2013
    Messages:
    2,779
    Occupation:
    Owner/Operator- Moxleys Rantals
    Location:
    Winnipeg Manitoba Canada
    Balance:
    17,054Coins
    Ratings:
    +2,504 / 30 / -2
    My Motion Simulator:
    2DOF, 3DOF, DC motor, JRK
    a fellow buddy who's actually making the PCB for this Alps switch has asked me to ask you this.

    "Have you tried running the encoder in Interrupt mode rather than polling ?

    In interrupt mode you wouldn't have the issue of running too slow, you just have to worry about denouncing"