Let's Make Robots!

Dim LEDs on PCF8574AP IO expander - FIXED w/vid and code snippet

So I have the I/O expander running an LED on every output but they all are dim (like 25%) compared to plugging the LED (and its resistor) straight into the 5V source. I checked the expanders outputs and it's putting out 5V but it sure isn't acting like it. Anyone know what I'm doing wrong?

I have a viddy I took of the situation but it's taking forever to U/L. I'm hoping this problem is something "duh" that doesn't require visuals but I got it coming just in case.

edit- Grog asked so I thought I'd add that the chip can output 100mA. Small detail that might be a question for others. Also when I use a 5V LED (the ones with built-in resistors) it is also super dim. Hmm...

edit #2- found there is only 0.11mA being output on the pins. I have no idea why. Therein lies my new question, dear reader.

Successful code excised from my main program:

-------------------------------

symbol seed = w5 'seed for random number generator; = TIMER SFR
symbol rndnmbr = w6 'led
symbol sprout = w7 'led
symbol leds = b20 '%00000000 LED n
symbol LED_decimal = b12 'first byte from rndnmbr
symbol LED_bcd = b24

rndnmbr = 3

HI2CSETUP I2CMASTER, %01110000, i2cfast, i2cbyte 'set for I/O expander I2C


Alert:
  for b1 = 1 to 10
  hi2cout 0, (%11111100) 'red and blue siren effect
  
  pause 250
  
  hi2cout 0, (%11001111)
  
  pause 250
 next b1

locked:
  {
  for b1 = 1 to 100
  LEDs = 254
  call rand_led
  'debug
  if LED_bcd = %11111111 then goto locked 'always random colored lighting, never all LEDs off
  
  hi2cout 0, (LED_bcd)
  
  LEDs = 3500 'maximum delay time
  DO
   call rand_num
  'debug
  LOOP until rndnmbr <= LEDs 'AND rndnmbr > 250
  
  pause rndnmbr
  next b1
  
looking:
  for b1 = 1 to 3
  {
  
  hi2cout 0, (%11111100) 'red
  
  pause 650
  
  hi2cout 0, (%11111111)
  
  pause 300
  
  hi2cout 0, (%00111111) 'yellow
  
  pause 650
  
  hi2cout 0, (%11111111)
  
  pause 300
  
  hi2cout 0, (%11110011) 'blue
  
  pause 650
  
  hi2cout 0, (%11111111)
  
  pause 300
  
  hi2cout 0, (%00111111) 'yellow
  
  pause 650
  
  hi2cout 0, (%11111111)
  
  pause 300
    
}
next b1

goto alert

rand_led:
{
'DO
 seed = time
 RANDOM seed
 rndnmbr = seed // leds '- 1
'LOOP UNTIL sprout <> rndnmbr
LED_bcd = LED_decimal / 10 * 16 'convert first byte from RNDNMBR word var to BCD byte for IO expander
LED_bcd = LED_decimal // 10 | LED_bcd
return
}
rand_num:
{
'DO
 seed = time + 250
 RANDOM seed
 rndnmbr = seed // leds + 1
'LOOP UNTIL sprout <> rndnmbr
LED_bcd = LED_decimal / 10 * 16  'convert first byte from RNDNMBR word var to BCD byte for IO expander
LED_bcd = LED_decimal // 10 | LED_bcd
return
}}
 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Here is a link to my blog where I demonstrate a project using the PCF8574 I/O expander. It might help you out a bit. http://hobbybotics.wordpress.com/projects/hobbybotics-pcf8574a-i2c-io-expander/

QuasiBidirectional ports......it sounded a bit sketchy to me so I looked it up....and this one resource I found interesting.

http://cgervasi.com/blog/?p=26

I recently tried using a mcp23s18 IO expander which is an openDrain type...threw me off as I'd not used anything like it. They work a bit differently from what ya might want or expect. I now have on order the mcp23s17 which should give me what I want(logic High/Low) 

Look up open drain port as well....it's good to know these things.  :D

Brightness is where it should be for all the LEDs. Now I just gotta go change a bunch of 1's into 0's. The Freak! BW2K \o/ ! The Voodoo that yoo doo! And my shoutbox helpdesk, where you at! :) Thanks fellas.

I swear when I first tested this chip I had it sourcing current with nice bright LEDs but... gah, the specs don't lie.

You guys rock. Thanks for the rented brain cells!

You can do what BW2k suggests minding the max sink limit or alternatively use a transister(2n3904) with the base connected to the output pin.

Try sinking the current instead of sourcing the current.

 

The PCF8574 can not drive much current when the output is in HIGH state, as you can see in the datasheet (page 15). Reverse the polarity of your LEDs and drive them with LOW state.

Total chip power = 400mW - is it running hot at all

 

Pete