mcp23016 issues with my bs2p24 :/
trend
Posts: 112
/edit 1/14/05
The issue now isn't the code.. nor the mcp.
It is when we control a relay (through the uln2803a to the mcp23016) and try to control AC current, we get ~50percent sucessrate.. but when we try to control DC, we get nearlly 100percent sucess rate
When controlling AC current.. when the mcp "fails" to close the relay to allow AC.. I still hear the relay close, just the motor doesn't spin..
/end of edit
Hello, I am trying to figure out why my code below works only ~80-90percent of the time... 10-20percent of the time, the mcp23016 doesn't change the output state of the pins·while it is in the loop.
here is my code:
Am I missing anything/need to change anything?
Also, how can I check the pin state through i2cin?
thanks again guys!
Lee
Post Edited (trend) : 1/14/2005 5:35:29 PM GMT
The issue now isn't the code.. nor the mcp.
It is when we control a relay (through the uln2803a to the mcp23016) and try to control AC current, we get ~50percent sucessrate.. but when we try to control DC, we get nearlly 100percent sucess rate
When controlling AC current.. when the mcp "fails" to close the relay to allow AC.. I still hear the relay close, just the motor doesn't spin..
/end of edit
Hello, I am trying to figure out why my code below works only ~80-90percent of the time... 10-20percent of the time, the mcp23016 doesn't change the output state of the pins·while it is in the loop.
here is my code:
' {$STAMP BS2p} ' {$PBASIC 2.5} SDA PIN 0 'MCP.15 SCL PIN 1 'MCP.14 DevType CON %0100 << 4 ' Device type DevAddr2 CON %001 << 1 ' Address = %001 DevAddr3 CON %100 << 1 ' Address = %100 WrMCP2 CON %01000110 ' Write to MCP2 RdMCP2 CON %01000111 ' Read from MCP2 WrMCP3 CON %01000010 ' Write to MCP3 RdMCP3 CON %01000011 ' Read from MCP3 GP0 CON $00 ' register addresses GP1 CON $01 OLAT0 CON $02 OLAT1 CON $03 IPOL0 CON $04 IPOL1 CON $05 IODIR0 CON $06 IODIR1 CON $07 INTCAP0 CON $08 INTCAP1 CON $09 IOCON0 CON $0A IOCON1 CON $0B dataGP0 VAR Byte ' device I/O bank 0 dataGP1 VAR Byte ' -- bank 1 com VAR Byte idx VAR Nib ' loop counter I2COUT SDA, WrMCP2, IODIR0, [noparse][[/noparse]%00000000] ' MCP2 GPO pins are outputs I2COUT SDA, WrMCP2, IODIR1, [noparse][[/noparse]%00000000] ' MCP2 GP1 pins are outputs I2COUT SDA, WrMCP3, IODIR0, [noparse][[/noparse]%00000000] ' MCP3 GPO pins are outputs I2COUT SDA, WrMCP3, IODIR1, [noparse][[/noparse]%00000000] ' MCP3 GP1 pins are outputs top: 'Set states of MCP2 and MCP3 I2COUT SDA, WrMCP2, GP0, [noparse][[/noparse]0, 0] 'Set all MCP2 outputs low. I2COUT SDA, WrMCP3, GP0, [noparse][[/noparse]0, 0] 'Set all MCP3 outputs low. dataGP0 = 128 I2COUT SDA, WrMCP2, GP0, [noparse][[/noparse]dataGP0] PAUSE 1000 'not sure about the delay needed.. but i am sure 1 sec is fine :) I2COUT SDA, WrMCP3, GP0, [noparse][[/noparse]dataGP0] PAUSE 2000 GOTO top
Am I missing anything/need to change anything?
Also, how can I check the pin state through i2cin?
thanks again guys!
Lee
Post Edited (trend) : 1/14/2005 5:35:29 PM GMT
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
thanks for the help Jon!
Lee
how would I verify what pins are high/low inputs/outputs?
thanks-Lee
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
Anyways, I used this code.. Hope it might help other people out with similiar debugging:
·I am about to see what is going wrong with the hardware..
·
I just ran my above code 10x or so without error when the mcp23016 didn't have the uln2803a powered.
I would power my uln2803a.. but I don't have a 12v rectifier and radioshack just closed. So i cannot trace the problem down anymore
Does anyone have any experience with something like this happening?
thanks again!
Post Edited (Paul Baker) : 1/12/2005 5:25:59 AM GMT
but I did touch one of the mcp23016 (there are 2 on the i2c bus).. and the mcp and uln was hot.. I didn't check the temperature of the other one. The reason I checked the temp of the mcp/uln was because somehow 3 of the pins went high for no apparent reason (this was when I was telling another line to go high over and over again..without the line actually going high).
thanks for the idea
Lee
Both mcp23016s act the same way.· I already replaced the 2803. So we should be fine with that.
I took off the mcp23016's boards and put them on a breadboard.. and hooked up the output of the uln2803a to a Bar Graph Display:
http://www.radioshack.com/product.asp?catalog%5Fname=CTLG&category%5Fname=CTLG%5F011%5F006%5F001%5F000&product%5Fid=276%2D081&site=search
And I wrote a program that·brings high·each pin of the mcp23016 for 100ms, then goes to the next pin.· This program goes through GP0 and GP1.
And everything works great.· I see the leds going and going and going around in circles.
Here is a pic of what I mean:
http://webpages.charter.net/trend/bar_graph_test.jpg
·
There is a 5v and 12rectifier.. so I am emulating my relay board fairly well.
·
·
Any ideas?
·
thanks-Lee
hmm.. I guess I can go get the 12v power supply I was using for the relay board
Hope you are right!
thanks-Lee
Good idea though
Thanks-Lee
GP1: 1
OLAT verified: success
IODIR verified: failed.. resetting...END
I get that pretty consistantly when I first plug the power supply in.. but I rememedy that by just pressing the "play button" to upload my code to the bs2 from my computer (after I plug in the power supply ;/ ), and it starts to execute the code flawlessly.
Is this normal? Should I worry about this?
2. You don't set a default state for SA or the other write pins. This means the first I2COUT (which WILL set them as outputs, by the way) may garble the first bit.
3. It's possible the 12V is coming up 'slowly'. A PAUSE 200 in the start of your program may give stuff time to get stable.
I don't understand what you mean by:
2. You don't set a default state for SA or the other write pins. This means the first I2COUT (which WILL set them as outputs, by the way) may garble the first bit.
and on point 3. great answer. I thought that might be the problem.. but for some reason I didnt' see putting a pause 200 in there to fix the problem
thanks! Lee
But I do believe I am telling the mcp to set all the pins to outputs. Were you saying I wasn't doing something else?
thanks-Lee
(These are P0 and P1 from your code).
Should they be 'LOW' when idle? 'HIGH' when idle? Inputs when idle?
The I2COut command will leave them in some 'idle' state. If they are not in that idle state on your first I2COUT command, then the device recieving the first I2COut command may get an extra bit, or miss the first bit.
This may not be an issue with what you are doing. I notice you are now issuing the I2COUT command twice when your program starts up, so that should take care of the issue.
Like I have said above, the uln2803a drives relays (I believe js1-12v...
http://rocky.digikey.com/WebLib/Aromat/Web%20Data/JS%20Relays.pdf·)
Everything works fine as long as there is no power going into Com/NO/NC pins (I am not sure if I said that right.. but basically I unplug my 27vAC 1.3amp powersupply so the relays cannot distribute power to the intended motor).
I have left my program go on for a couple minutes, and the mcp can be written to and read from flawlessly.... But as soon as I plug in the 27vAC 1.3amp power supply, the mcp only operates correctly ~1/3 of the time.
Do you'll have any ideas?
thanks! Lee
I'm pretty new to this, so please forgive this attempt if I'm out in left field somewhere.
The specs on the js1-12 relay give a nominal operating current of 30ma. The specs on the mcp23016 say it can handle 25ma. From the looks of it you are trying to source more current out of the mcp23016 then it is designed to handle.
Jim
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Do you have a Stamp Tester?
http://hometown.aol.com/newzed/index.html
·
thanks for the suggestion though!
Would this have an effect on the situation?
thanks-Lee
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Do you have a Stamp Tester?
http://hometown.aol.com/newzed/index.html
·
AND Ohms = Volts / Amps
So the motor operates off ~7 amps
/side note.. the power supply and motors were designed for each other.. That is why I can do the above
/end
So this should still let me operate within the limits of the relay, right?
thanks-Lee
What we have to determine is if the MCP operates OK if there is a DC device on the relay, but fails when you put an AC device on the same relay.· Let's do it [noparse]:)[/noparse])
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Do you have a Stamp Tester?
http://hometown.aol.com/newzed/index.html
·
So be back in 5 minutes
Doh!
It ran through the test 2 whole loops before an error and i got something like this:
9or8 sucessfull open/closes then the mcp verify state (olat or direction) doesn't verify
any ideas?