problem driving ULN2803A Darlington with MCP23S17 I/O port expander

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

Got the MCP23S17 power & Gnd connected also?

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.

Thank you for the attempt on your schematic.

At a minimum, you must show all power supply connections (Vcc and GNDs) at least one control connection and your load connections.

Do you have a volt meter?

Print images, cut out, tape to 8 1/2” X 11 paper, draw connections, scan or take picture.

Aw man I'm sorry for being that guy! :confused:

Yes I have a cheap multimeter. Ok I'll do that thanks!!

Measure the 2803 input voltage (when HIGH) which comes from the MCP23S17.

Always nice to see a good image of your circuit wiring.

I get 4.93V with the ULN2803 disconnected and it drops down to 0.01V when I connect the ULN2803

Skipping the MCP23S17 and connecting the ULN2803 input directly to the Arduino 5V I drop down to 4.8V with the ULN2803 switching correctly.

edit: I just updated the schematic to show the Arduino ground is connected to the 9V ground!

What is the voltage on pin 18 of the 2803 when the input is HIGH.

If that’s a 9v PP3 battery, they do not have much current capacity to power things like relays.

A 9v battery will probably not power a 12v relay.

I wasn't sure if it would but the ULN2803 switches the relay fine when connected directly to power.

I just switched the relay out for an LED and it's the same.

I get 7.71V on pin 18 with the ULN2803 when pin 1 is connected to the MCP23S17 output on HIGH

I get 0.70V on pin 18 with the ULN2803 when pin 1 is connected directly to 5V power and the relay clicks/LED lights up

Please show us a good image of your circuit wiring.

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..