Multiplexing question

amcalpine

New Member
I have 2 18x's. I need to control 35 LEDs. My idea is to split the task and i2c half to the other 18x. However, I do not understand, nor have a good code example of how to do this. Can anyone help? Specifically how do I get a bit from a byte to correspond to a pin?


Thanks!
 

westaust55

Moderator
Welcome to the PICAXE forum.

Why not use a single 18X and use some MCP23017 IO expanders. A couple of MCP23017 wills cheaper than a second 18X and you keep the 18X for another project.

Each MCP23017 provides 16 IO configured as two 8-bit ports where each IO can be an input or an output. Have a look at www.futurlec.com.au or www.futurlec.com as potential suppliers. Alto these are for “shop fronts in Australia and the US, the is a warehouse in Thailand from which the parts come at very reasonable postage rates (AU$4 for a handful of components).
With the MCP23017, if you have a value say “5” in a byte variable then just write/send that to one of the two 8-bit ports. That would then give in bit format %00000101.
I suspect that possibly your biggest challenge in the bit manupilation could be getting from the BCD encode value read from the DS1307 to basic decimal or binary values.
You may need to explain more clearly exactly which part of the project you are having difficulty with.
Note also, that you can edit your previous post to add more information rather than needing to start a second post immediately after in the same thread.

EDIT:
Just checked on Futurlec AUD$1-50ea thru Aust storefront and US$1-20ea thru the US storefront

EDIT2:
Have a look here: http://www.picaxeforum.co.uk/showthread.php?t=10836&page=4 at a project I did using two MCP23017 to drive 64 RBG LEDs


Any further questions just post them
 
Last edited:

inglewoodpete

Senior Member
My idea is to split the task and i2c half to the other 18x
The 18x can't be configured as an i2c slave. Only the 'x1s and 'x2s can.

I would follow WA55's suggestion. Alternatively, use a string of 74HC595s as output expanders.
 
Last edited:

westaust55

Moderator
Good spotting there IWP wrt 18X having no slave i2c capability.


While the use of the 75HC595’s will physically work, from some past tests I did comparing 40X1 at 4MHz and 8MHz driving a series of 74HC595 with the SHIFTOUT command versus i2c comms at the same two clock speeds,
The i2c comms gave 1.5 time the SHIFTOUT command data speeds.
With no X1/X2 part, needing to bit-bash in BASIC code, that difference would increase.
 

vttom

Senior Member
6x6=36. So, if you have a 6-bit data bus, and 2 control signals which independently clock outboard data registers (a total of only 8 bits), you can "address" a grid of up to 36 LEDs, 6 rows of 6 bits each.
 

amcalpine

New Member
Thanks, I'm off to buy the part. I have a stupid question though. why not sync the second pic to toggle five pins to low in sequence then after each pin send a go ahead to the main pic to scan the seven pins for sec, min, hour, etc.? Is it just too slow for persistence of vision?
 

amcalpine

New Member
NEAT!

Ok, I've got some MCP23017s on order... I need Hours Minutes Seconds and Date (month, year). I have figured the conversion of BCD to base 10. But reading the data sheet for the MCP23017 I'm getting a little confused. How do I assign specific pins to the word I am sending it? I know this is a noob question but if I could just get a push in the right direction that would help.. Thanks!



Datasheet:

http://ww1.microchip.com/downloads/en/DeviceDoc/21952a.pdf
 

BCJKiwi

Senior Member
If there are specific patterns required (akin to letters/numbers on a 7 seg display) then the simplest way is to create the 8 bit patterns in eeprom
e.g.
Code:
; 7 Segment Display
;   b0
eeprom 0,(%00111111)    ;0
eeprom 1,(%00000110)    ;1
eeprom 2,(%01011011)    ;2
eeprom 3,(%01001111)    ;3
eeprom 4,(%01100110)    ;4
eeprom 5,(%01101101)    ;5
eeprom 6,(%01111101)    ;6
eeprom 7,(%00000111)    ;7
eeprom 8,(%01111111)    ;8
eeprom 9,(%01101111)    ;9
;          .gfedcba      
eeprom 20,(%00000000)   ;all digits OFF
These were actually for a philips chip.
or
Code:
eeprom 214,(%00000000,%11111100) '0
eeprom 216,(%00000000,%11111110) '1
eeprom 218,(%00000000,%11111111) '2
eeprom 220,(%10000000,%11111111) '3
eeprom 222,(%11000000,%11111111) '4
eeprom 224,(%11100000,%11111111) '5
eeprom 226,(%11110000,%11111111) '6
eeprom 228,(%11111000,%11111111) '7
eeprom 230,(%11111100,%11111111) '8
eeprom 232,(%11111110,%11111111) '9
eeprom 234,(%11111111,%11111111) '10
eeprom 236,(%11111111,%11111101) '11
eeprom 238,(%11111111,%11111100) '12
eeprom 240,(%01111111,%11111100) '13
eeprom 242,(%00111111,%11111100) '14
eeprom 244,(%00011111,%11111100) '15
eeprom 246,(%00001111,%11111100) '16
eeprom 248,(%00000111,%11111100) '17
eeprom 250,(%00000011,%11111100) '18
eeprom 252,(%00000001,%11111100) '19
eeprom 254,(%00000000,%11111100) '20
for both banks of an MCP32017 directional display

In your code the result that needs to be displayed is converted to the eeprom address which is then 'read' and output.
 
Top