Results 1 to 10 of 10
  1. #1
    10+ Posting Member
    Join Date
    Mar 2014
    Location
    Germany
    Posts
    12
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    little Question at the INO files

    Hello Jim,

    i got a question about your Ino files.

    In the void setup you are using pinMode(KoutPin, INPUT) and thereafter digitalWrite(KoutPin, HIGH);

    This in my opinion is the same als pinMode(KoutPin, INPUT_PULLUP);

    is there any reason why you used the two line method ??

  2. #2
    500+ This must be a daytime job Jim NZ's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    764
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: little Question at the INO files

    You are absolutely correct Wiggi.

    The reason I split it up like that is so a "learner" can read the code like a book ,, starting at the top and with working his way down can study each line as he goes.

    All my demo's could be written many ways ,, but I prefer to try to make them as understandable to a new guy as possible.

    I could have also written them with less code but only experienced Guys would be able to understand them ,, which is silly because experienced Guys don't need demo's.

    Cheers ,,, Jim
    www.jimspage.co.nz/intro.htm
    All this and Liz still loves me ! !

  3. #3
    10+ Posting Member
    Join Date
    Mar 2014
    Location
    Germany
    Posts
    12
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: little Question at the INO files

    Yes true story.

    You would also knew the absolute "Profi" code where every oportunity is serverd but then you could hardly understand the code without rip the brain off the dev and connect it to yours.

    Your Tutorial INO's are about the right line between ginvin hints for Programming and let the user understand where he coud tweak the code.

    A BIG THANK YOU for this "little" program

    Cheers Chris

  4. #4
    75+ Posting Member



    Join Date
    Sep 2013
    Location
    California, USA
    Posts
    109
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: little Question at the INO files

    Jim,
    I don't think these two methods are the same.
    PinMode(KoutPin, INPUT) instructs the Arduino to use KoutPin as in "input sourcing" i.e.
    5vdc input = TRUE
    open input = FALSE.
    whereas PinMode(KoutPin, INPUT_PULLUP) instructs the Arduino to use "input-sinking" i.e.
    0vdc (grounding the input) = FALSE
    open input = TRUE
    Regards, Steve

  5. #5
    10+ Posting Member
    Join Date
    Mar 2014
    Location
    Germany
    Posts
    12
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: little Question at the INO files

    Yes there are differences between input and input_pullup. But the point is to set the output HIGH after made him to an output. Most arduinos are in fact atmega IC's and there the comom use is to set a pin to an output and write a one to activate the internal pullup.
    Normaly by something like this:
    DDRD = 0XFF;
    PORTD= 0XFF;

    So input_pullup and input , high. In fact are the same thing. The value check if a pin is true or false - well i recomend to check if high or low. True or false coud be confusing. In some circuits where you have to ensure wire break safety an electrical 0 could be a true statement because the normal state of false is high. ( got what i meant) true and high are not in every case the same.

    On the other hand. Leave a pin open does not mean it is by default false. You could have a static electrical charge wich prevents the pin from falling"low". So you could not be save that no input is true 0.

    Jims way is to make sure we have defined states with minimum effort by using the build in resistors. The other way woud be to place a pulldown on every pin. Wich would be hard for big rigs like the mega (imagine you hat do solder 54 resistors only to ensure basic capailities). Wouldn't be a joy right?

    Cheers Chris

  6. #6
    75+ Posting Member



    Join Date
    Sep 2013
    Location
    California, USA
    Posts
    109
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: little Question at the INO files

    Hi Wiggl,
    Thanks for the schooling. Coming from a background of industrial PLCs I assumed that sink inputs and source inputs would have similar impedance, but I now understand that this is not true of the Arduino architecture. Maybe you can enlighten me as to why the default sourcing input does not have a pulldown resistor.

    Steve

  7. #7
    10+ Posting Member
    Join Date
    Mar 2014
    Location
    Germany
    Posts
    12
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: little Question at the INO files

    Hello Steve
    i apologize if this text bother or insult you.
    It was not meant to. Im not am expert and the text represents my knowing of arduinos/atmegas so far. I amed for the fact that input, high and input_pullup are about the same in the arduino ide afaik.

    At the last section my brain went yust nuts. Sorry for that.

  8. #8
    75+ Posting Member



    Join Date
    Sep 2013
    Location
    California, USA
    Posts
    109
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: little Question at the INO files

    Hi Wiggl,
    No offence taken. I am just beginning to teach myself to use Arduinos, primarily because of Jimís L2FSX program which has given me the opportunity to build the simulator I have always wanted. My industrial background is a clear disadvantage here, as I am used to relying on hardware which has been rigorously developed for process control applications. I was truly dismayed to learn that the Arduinos have trouble resolving an open input circuit, a situation which would never have crossed my mind before this thread.

    I am about 30% complete with my first Arduino project, a radio stack using mechanical frequency selectors, and will quickly admit that I have a lot to learn. Hereís what my project looks like, it has approximately 140 inputs which may be open at any given time so this topic is of immense importance to me.
    Regards, Steve

    [IMG]file:///C:\Users\Steve\AppData\Local\Temp\msohtml1\01\clip_image002.jpg[/IMG]
    Attached Images Attached Images

  9. #9
    10+ Posting Member
    Join Date
    Mar 2014
    Location
    Germany
    Posts
    12
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: little Question at the INO files

    Hello Steve,

    you have a stunning hardware.........
    I wish i had such a Stack.

    To the open Inputs at the Arduino... my testing results in big Problems if you left pins floating and not defined 0 or 1.
    I coud reconstruct that the Pullups work fine if the setup is to use them.
    But when only setting a Pin to input. And leave it open. Sometimes there was read a 1, somtimes there is 0 . ( tested with Arduino Duemillanovo and UNO. Not testet with Aruino Mega2650 ).
    I will crawl trough the Datasheets of the referring Atmel Chips this weekend. Maybe it gets me more info.

    Cheers Chris

    EDIT:

    i looked up the General I/O section in the ATMega328 and 2560 Datasheets. They are the same.
    Now i need your knowledge...... I couldn't figure out anything wich is pulling the pin down if it is left open.
    But i see a steerable pullup.
    Im not sure if the circuit in the lower section will put the Pin in a defined state (be it low or simply defined nothing -> like tri-state). ( Well everything in the lower section looks very wierd to me.)

    Screen Shot 03-31-14 at 03.41 PM.PNG
    Last edited by Wiggl; 03-31-2014 at 10:49 AM. Reason: adding of Information

  10. #10
    75+ Posting Member



    Join Date
    Sep 2013
    Location
    California, USA
    Posts
    109
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: little Question at the INO files

    Chris,
    Yes, that appears correct to me, although I am not any kind of expert on the Arduinos. The simple INPUT argument creates a high impedance input pin which will eventually bleed to zero but is subject to static charge errors if left open. The 2560's have an internal pullup resistor available which creates a low impedance input, but no corresponding pulldown resistor . This explains why using a simple pinMode INPUT presents a problem for switch inputs but INPUT_PULLUP does not. The only issue seems to be a logical one, as the switches have to be connected to ground the input when engaged so turning on a switch sends a 0 instead of a 1. Just something else to trip up the novice programmer.

    As you mentioned earlier, there is always the option of building a hard wired pulldown resistor circuit, which may be an acceptable solution for only a couple of switches, but not when you have a bank of 2560's with 50 switches connected to each one (Uggh).

    I've got my transponder portion of the programming finished (using INPUT_PULLUP) and it works perfectly with fsx. I played with it for a while last night, even touched the connectors with my finger, and could not get it to fail.

    JIM, i owe you a big, fat apology for questioning your reply.
    Steve