Strange behaviour on BLADE pins

Forums MPG Level 2 Strange behaviour on BLADE pins

This topic contains 3 replies, has 2 voices, and was last updated by  Cameron Smith 2 years ago.

  • Author
    Posts
  • #4811

    Yakov
    Keymaster

    I’m trying to make a simple application, where if the board detects a signal on one of the BLADE inputs, it turns the light on. My code looks like this:

    
    if(AT91C_BASE_PIOA->PIO_PDSR & RX_PIN) //RX_PIN corresponds to PA11
      LedOn(GREEN1);
    else
      LedOff(GREEN1);
    

    (code may vary; I don’t have the code in front of me right now, just what I remember)

    This is what’s actually happening:

    • Default behavior: light is on (it shouldn’t be)
    • Touch the RX pin with any conductive material (like pencil graphite): light begins to flicker
    • Release the conductive material: light briefly turns off, then turns back on again

    I’m wondering if my code is wrong, or if there’s any physical problems, like poor contacts or soldering.

  • #4843

    Cameron Smith
    Keymaster

    Hello Yakov.

    Like with all debugging problems I cannot know for sure what your issue is without seeing the whole system you have set up but I can take a few best estimates.

    First I am guessing the pin on the blade connector is floating (not tied to a ground or driven high)? This is a third state (neither one or zero) and for most chips, a pins response is unknown to floating inputs. Often it is interpreted as a hi signal but it is hard to know. The same uncertainty would occur when contacting the pin with a conductive material as stray charge may be transferred and the grounded state of, say your hand, is unknown.

    You should be able to configure the pin with a pull down or pull up resistor so that floating inputs get recognized as lo or hi respectively.

    Secondly, I am assuming you are adding to a previously created project. Did you configure the initialization state so that the LED is off at startup? Lastly is this statement in an interrupt or are you polling the pin continuously? If you are polling, what frequency are you polling it at? All of these factors would affect the behavior.

    I hope that helps. Please post your solution when you figure it out as it makes for a nice reference example for other students.
    Cameron

  • #4933

    Yakov
    Keymaster

    Hi,

    Thank you very much for your post! Yeah, I forgot that pins can float, which is why my board was behaving strangely. I’ll have to come up with a solution for that, but a pull-down resistor is probably going to be the best option.

    • #4957

      Cameron Smith
      Keymaster

      Awesome, I’m glad I could help. Depending on the pin you may be able to configure the internal pull down resistors. Could save you a little trouble hardware wise

You must be logged in to reply to this topic.