I'm having trouble trying to drive 12V relays with a ULN2803A Darlington array through a MCP23S17 16 channel port expander.
Both are functioning perfectly independently on either 5V or 3.3V, but when I combine them the ULN2803A will not switch from the MCP23S17 output.
When I directly connect the ULN2803A input to the Arduino 5V power supply it will happily switch. When I test the MC23S17 output I'm connecting to I get 4.93V - some drop, but the ULN2803A works fine also on only 3.3V or with a resister to drop voltage.
I am a total electronics noob sorry for terrible drawing
CrossRoads:
Got the MCP23S17 power & Gnd connected also?
Yes, the MCP23S17 is working perfectly to drive LEDs directly - power, ground, reset, and the relevant serial ports are all connected. Apologies for the drawing not reflecting that. Here I changed it to show grounds.
Next time use a TPIC6B595 shift register.
Can switch up to eight <= 100mA relays with three control pins.
More TPIC chips can be daisy-chained, using the same three pins.
Leo..
Should rule out software issue - You don't happen to be setting the pins to work as open drain with pullup enabled do you? That would result in behavior like you describe...
DrAzzy:
Should rule out software issue - You don't happen to be setting the pins to work as open drain with pullup enabled do you? That would result in behavior like you describe...
It looks like it was software!
I haven't got to the bottom of it yet but I tested some much simpler code and the hardware is working as expected.
Thanks all! I will post the explanation when I figure it out more fully.
Probably it was driving open-drain so could not source any current. The 2803 requires current sourcing for
its inputs (or put another way the 2803 sinks current).
The multimeter is sensitive enough to be fooled by leakage currents in the MCP23S17 output stage - the
fact its output wasn't a hard 5V was a clue here - the 0.1V drop into the 10M multimeter load indicates
the output could only source 10nA, which is 5 orders of magnitude too small for the 2803 inputs...
So you need to use a TPIC6B595. ULN2803s are more-or-less obsolete and you are getting nowhere with it.
Mind you, if you were to connect a 2k2 pull-up from each ULN2803 input pin to 5 V it would probably work except for one small and unfortunate glitch.
One other question - What 5 V source are you using to power the Arduino? You do need a proper 5 V source to power your project - such as a "Phone charger" connected to the USB socket.
But you need to figure out how to drive the MCP23S17 push-pull anyway, if its to be of use for almost anything,
and then it can drive the ULN2803 with its free-wheel diodes. The TPIC doesn't have free-wheel diodes
so you have to calculate whether the avalanche energy rating is being exceeded with it - and since the
application is a relay this matters.
MarkT:
The TPIC doesn't have free-wheel diodes so you have to calculate whether the avalanche energy rating is being exceeded with it - and since the
application is a relay this matters.
The TPIC family has active clamping (a zener between drain and gate) just for that.
Makes the relays turn off faster as well.
Leo..