more G-Labs products

Author Topic: MCP23017 / Problem with Inputs  (Read 3012 times)

May 28, 2014, 01:10:17 AM
Read 3012 times

Boeky

  • **
  • Information
  • Jr. Member
  • Posts: 31
Hi,


I'm having a strange problem with the Inputs of the MCP23017.

First of all I followed the complete topic http://www.homegenie.it/forum/index.php?topic=145.0 and installation guide of http://skpang.co.uk/blog/archives/454.

After some tests everything seems to work good exept that all inputs are constantly triggering at random. I keep getting messages of status changes of 100 and 0 percent of all digital inputs while nothing is hooked up at the chip.

Outputs seem to work fine : configuring a button with an output switch and hooking up a LED to the MCP23017 works without any problems.

Also running the ledchaser program from http://skpang.co.uk/blog/archives/454 works.

i2cdetect in raspbian shows me the correct address of the module

Changing the address or the IC chip doesn's solve the problem.


Anyone any other ideas what might be the problem that all my inputs keep triggering at random without anything hooked up at the mcp23017?


Thanks,
Christophe

May 28, 2014, 02:19:13 AM
Reply #1

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
Edit the source code of the MCP23017 program and add these lines after line 95:

Code: [Select]
// line 95 is --> deviceConnection.SetDirection(pincfg.Pin, pincfg.Direction);
if (pincfg.Direction == Mcp23017PinDirection.Input)
{
      deviceConnection.SetResistor(pincfg.Pin, Mcp23017PinResistor.PullUp);
}

update the program from action->update and test it again.
Let me know if this solve the issue.

Cheers,
g.

May 28, 2014, 07:56:19 AM
Reply #2

Boeky

  • **
  • Information
  • Jr. Member
  • Posts: 31
Hi Gene,


Thank you for your fast response.

I already found out that putting the inputs to the ground made them stable.
So I figured out that adding a resistor of 10k between each input and the ground (pull down resistors) or to the 3.3v (pull up resistor)  gives a stable 0 and 1 level.

I knew the mcp23017 had internal pull up resistors but I could't find how to use them in the code.

So I made your program adaption and it works fine :
When providing the inputs with the internal pull up resistor all sensors remain stable at 1 without any cable connected to the input pins. Connecting the input pins to the ground gives a stable 0.

Thank you very much for your help.


Just some other questions:

1) I already tried to use PullDown in order to get the sensors to level 0 so I can provide 5v but i guess the mcp23017 only provides a pull up resistor then?
If you want it to work like that I think the only solution is to add pull down resistors to each input? Or is there a way to program the mcp23017 to invers the results so the sensors are low?

2) I left the mcp23017 connected during the night. Is it normal that the ic gets hot over time? I can touch it but it is hot.
Of course I get the same when touching some ic on the raspberry py so i guess this is normal?


Thanks,
Christophe

May 28, 2014, 09:23:12 AM
Reply #3

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
1) Yes it only provide PullUp resistor. Yes you can change the behavior by modifying the source code around line 131:

Code: [Select]
                Program.RaiseEvent(module, "Status.Level",
                               status ? "1" : "0",

just invert "1" and "0" values. Other way is the pull down resistor.

2) I am a software guy, so don't know much about electronic stuff =) But I can make I guess about this. Hg is using polling rather than interrupts, so this may lead to a bit of heating excess (just guessing).

Cheers,
g.

May 28, 2014, 10:54:37 AM
Reply #4

Boeky

  • **
  • Information
  • Jr. Member
  • Posts: 31
1) Thanks again. I'll update my code.

The MPC23017 works fine now so I've started to make a SmartControl addon to use the sensor values of the MCP23017 to trigger On, Off and Dim functions of Dimmer Modules. You can follow progress and problems here -> http://www.homegenie.it/forum/index.php?topic=225.0


2) I thinkt it was my fault the ic overheated. I grounded all input pins without a pull down resistor to get rid of the messages in the homegenie software. They might have drawn some current all night.
For now the IC is on for about 6 hours (with the internal pull up resistors activated) and it remains cool...


BTW The homegenie software is amazingly well designed and very expendable. It is one of the best free home automation software I've ever worked with.


Thanks,
Christophe
« Last Edit: May 28, 2014, 10:57:18 AM by Boeky »