Fellow Enthusiasts,
Thank you in advance for any PICAXE programming insight and/or direction you can provide regarding my rather simple application that follows. Please excuse if this gets a bit “wordy”, but I hope that providing more info about what I am trying to do initially will be better than too little.
My basic questions can be found by jumping to the Bottom Line Questions section of this document if you wish, but for a little more in-depth please read on. Thank you.
Background:
I am relatively new to PICAXE and microcontrollers for that matter, and my basic programming knowledge has been quite limited up to this point. However, I do have many past years of electronics training and experience, so I should hopefully be able to comprehend and pick-up on your advice / instruction somewhat quickly.
Intent:
In general, I was looking for a flexible solution that would allow me to control a multi-grouped, four-color array of LED’s, when one day I happened to stumble across an application utilizing the PICAXE microcontroller. After some preliminary investigation, I was certain enough that the economical PICAXE microcontroller would in one way or another serve my application needs. Based upon my initial I/O requirements and noting some script and forum commentary that the PICAXE I/O could perhaps be expanded across to at least a second microcontroller via the serout/in commands and/or possibly the I2C bus, I proceeded to purchase (3) 40X1’s, AXE022 proto-boards and EEPROMS (not knowing if these would be needed or not as things developed). Whether these methods of I/O (primarily output) expansion would pan out was not of great importance because I felt that for what I’m trying to do that I could always configure the (3) 40X1’s to control the LED color channels individually; each board receiving their respective digital control inputs out of the projected 8-10 that will be incorporated. Somewhat undesirably, it appeared that this would also involve then having (3) separate programs, one for each 40X1 chip. I know that some of you more experienced may be shaking your heads right now - rightfully so, and that is why I think it would be best if I could consolidate the programming for all color channels into one 40X1; not only to seemingly simplify matters from the programming/downloading perspectives, but there is also the strong possibility that I may want to coordinate sequencing of the (4) multi-output LED color channels; which I would envision to be quite difficult if the control programming would be spread out over the (3) individual 40X1’s as demonstrated in the Preliminary Program Code that follows below.
Application:
My application is a relatively simple one with a couple of “catches”. As mentioned, I have a predetermined number of outputs that exceeds the capacity of a single (or two for that matter) 40X1 chip(s). Also, the color channels (Blue, Green, Amber/Red) could be controlled independently, each 40X1 tentatively assigned as shown in the following Specification and Preliminary Program Code; but with inter-color sequencing as a desired possibility, I think it best (in my naive experience to date) that the control programming be consolidated on one 40X1 chip.
General Interfacing and Control Specifications:
Fast processing speed is not overly a concern. However, in the event that the outputs of the 2nd and 3rd 40X1 chips would be controlled by either the serout/in commands or possibly the I2C bus, it would be preferred that these outputs react somewhat quickly to the input states of the 1st 40X1.
Outputs (color channels): (36) total – (11) Blue, (11) Green, (7) Amber and (7) Red.
Insignificant Note: Each output is fed to a ULN2803A which will further drive as follows: (11) groups of (7) series connected Blue LED’s (75 LED’s total), (11) groups of (7) series connected Green LED’s (73 LED’s total), (7) groups of (12) series connected Amber LED’s (74 LED’s total), and (7) groups of (12) series connected Red LED’s (73 LED’s total). Total number of LED’s = 295
Inputs: (8-10) To be opto-coupled from an existing programmable logic controller (PLC) based Modicon Compact 984A (circa 1994) 24vdc outputs and also directly from other voltage level input switches and output indicators.
Note: You may ask why I don’t just add the programming for these additional LED displays to this existing controller? The answer is that I very well could, but I’m unable to practically utilize or expand on the PLC outputs due to lack of spares available and portable enclosure limitations, not to mention parts availability and cost. Besides, I would like to learn more about the PICAXE and microcontrollers in general. I think it’s a neat little solution for this application if it can be configured to work as envisioned.
Due to length of this message I have removed my preliminary code from this location. However, I have presented it (abridged) in two subsequent posts.
Bottom Line Questions:
I don’t expect anyone to fully comprehend what I’m attempting to do here, nor is there the need for one to do so. What I’m hoping to learn as a result of this inquiry are some basic answers to the following questions, concerning possible effective use of the serout/in commands and the I2C bus for the purpose of possibly expanding the I/O to the two other 40X1 chips and having the primary program consolidated and downloaded to only one 40X1 chip; This before I would commit to fabricating any I/O interface board(s) for the microcontroller (AXE022 board) and a custom LED display board:
1. Would use of the Serin/Serout commands work for this application? And if so…
a. On the 1st 40X1 chip: Am I limited to using the 0-7 output pins (portb) or could I use the portc pins as an alternative? When bread boarding, I’ve tried to assign portc as in the last two examples of the above Test Program Code and the syntax was accepted; but when downloaded, only the corresponding portb output 7 of the 1st 40X1 flashes a test LED (serial communication?), even though I’ve essentially told it to use output 15 (portc output 7) in this case.
b. Also, when trying to send a test copy of the outpin values (e.g. %11111111) of the 1st 40X1 chip via these serial commands to the 0 input of the second 40X1 chip, only the two MSB LED’s on portb of the 2nd 40X1 chip illuminate when activating the appropriate input(s) on the 1st 40X1 chip. Upon releasing the input pushbutton(s) the remaining portb outputs of the 2nd 40X1 light only momentarily but I am not clear as to why this is based upon my test programming code. I understand that timeouts and transmission-received acknowledgments can be issues as I’ve read in the forums, but I am really not up-to-speed with much of this yet.
2. I’m just now starting to look into possible use of the I2C bus for this purpose, but in reading some posts, I am not clear if this will work simplistically and effectively between what I’m led to believe are multiple, (3) in my case, bus master? devices (40X1’s).
a. It appears that the I2C portc pins 18 and 23 (SCL/SDA) of the 40X1 need to be reserved and configured for special use with the ic2slave command, then pulled-high using a 4k7 resistor in each line. It would seem then that these pins can no longer be assigned as digital inputs or outputs; is this assessment correct? If so…
b. Would it be correct then to configure portc as follows: let dirsc = %11100111 where the “00” bits are assigned to the I2C pins (assuming one would like to configure the remaining portc pins as outputs)?
In Conclusion:
Available information concerning the use of either of these two methods appears quite sketchy and limited from what I have seen so far. If something similar to what I’m trying to accomplish in addressing multiple outputs across several PICAXE chips has been effectively done by anyone utilizing either of these methods, I would greatly appreciate any insight.
In retrospect, perhaps there‘s a more suitable approach / product to handle this, but I plan to persevere with the PICAXE nonetheless. Thanks again so much for your help.
Thank you in advance for any PICAXE programming insight and/or direction you can provide regarding my rather simple application that follows. Please excuse if this gets a bit “wordy”, but I hope that providing more info about what I am trying to do initially will be better than too little.
My basic questions can be found by jumping to the Bottom Line Questions section of this document if you wish, but for a little more in-depth please read on. Thank you.
Background:
I am relatively new to PICAXE and microcontrollers for that matter, and my basic programming knowledge has been quite limited up to this point. However, I do have many past years of electronics training and experience, so I should hopefully be able to comprehend and pick-up on your advice / instruction somewhat quickly.
Intent:
In general, I was looking for a flexible solution that would allow me to control a multi-grouped, four-color array of LED’s, when one day I happened to stumble across an application utilizing the PICAXE microcontroller. After some preliminary investigation, I was certain enough that the economical PICAXE microcontroller would in one way or another serve my application needs. Based upon my initial I/O requirements and noting some script and forum commentary that the PICAXE I/O could perhaps be expanded across to at least a second microcontroller via the serout/in commands and/or possibly the I2C bus, I proceeded to purchase (3) 40X1’s, AXE022 proto-boards and EEPROMS (not knowing if these would be needed or not as things developed). Whether these methods of I/O (primarily output) expansion would pan out was not of great importance because I felt that for what I’m trying to do that I could always configure the (3) 40X1’s to control the LED color channels individually; each board receiving their respective digital control inputs out of the projected 8-10 that will be incorporated. Somewhat undesirably, it appeared that this would also involve then having (3) separate programs, one for each 40X1 chip. I know that some of you more experienced may be shaking your heads right now - rightfully so, and that is why I think it would be best if I could consolidate the programming for all color channels into one 40X1; not only to seemingly simplify matters from the programming/downloading perspectives, but there is also the strong possibility that I may want to coordinate sequencing of the (4) multi-output LED color channels; which I would envision to be quite difficult if the control programming would be spread out over the (3) individual 40X1’s as demonstrated in the Preliminary Program Code that follows below.
Application:
My application is a relatively simple one with a couple of “catches”. As mentioned, I have a predetermined number of outputs that exceeds the capacity of a single (or two for that matter) 40X1 chip(s). Also, the color channels (Blue, Green, Amber/Red) could be controlled independently, each 40X1 tentatively assigned as shown in the following Specification and Preliminary Program Code; but with inter-color sequencing as a desired possibility, I think it best (in my naive experience to date) that the control programming be consolidated on one 40X1 chip.
General Interfacing and Control Specifications:
Fast processing speed is not overly a concern. However, in the event that the outputs of the 2nd and 3rd 40X1 chips would be controlled by either the serout/in commands or possibly the I2C bus, it would be preferred that these outputs react somewhat quickly to the input states of the 1st 40X1.
Outputs (color channels): (36) total – (11) Blue, (11) Green, (7) Amber and (7) Red.
Insignificant Note: Each output is fed to a ULN2803A which will further drive as follows: (11) groups of (7) series connected Blue LED’s (75 LED’s total), (11) groups of (7) series connected Green LED’s (73 LED’s total), (7) groups of (12) series connected Amber LED’s (74 LED’s total), and (7) groups of (12) series connected Red LED’s (73 LED’s total). Total number of LED’s = 295
Inputs: (8-10) To be opto-coupled from an existing programmable logic controller (PLC) based Modicon Compact 984A (circa 1994) 24vdc outputs and also directly from other voltage level input switches and output indicators.
Note: You may ask why I don’t just add the programming for these additional LED displays to this existing controller? The answer is that I very well could, but I’m unable to practically utilize or expand on the PLC outputs due to lack of spares available and portable enclosure limitations, not to mention parts availability and cost. Besides, I would like to learn more about the PICAXE and microcontrollers in general. I think it’s a neat little solution for this application if it can be configured to work as envisioned.
Due to length of this message I have removed my preliminary code from this location. However, I have presented it (abridged) in two subsequent posts.
Bottom Line Questions:
I don’t expect anyone to fully comprehend what I’m attempting to do here, nor is there the need for one to do so. What I’m hoping to learn as a result of this inquiry are some basic answers to the following questions, concerning possible effective use of the serout/in commands and the I2C bus for the purpose of possibly expanding the I/O to the two other 40X1 chips and having the primary program consolidated and downloaded to only one 40X1 chip; This before I would commit to fabricating any I/O interface board(s) for the microcontroller (AXE022 board) and a custom LED display board:
1. Would use of the Serin/Serout commands work for this application? And if so…
a. On the 1st 40X1 chip: Am I limited to using the 0-7 output pins (portb) or could I use the portc pins as an alternative? When bread boarding, I’ve tried to assign portc as in the last two examples of the above Test Program Code and the syntax was accepted; but when downloaded, only the corresponding portb output 7 of the 1st 40X1 flashes a test LED (serial communication?), even though I’ve essentially told it to use output 15 (portc output 7) in this case.
b. Also, when trying to send a test copy of the outpin values (e.g. %11111111) of the 1st 40X1 chip via these serial commands to the 0 input of the second 40X1 chip, only the two MSB LED’s on portb of the 2nd 40X1 chip illuminate when activating the appropriate input(s) on the 1st 40X1 chip. Upon releasing the input pushbutton(s) the remaining portb outputs of the 2nd 40X1 light only momentarily but I am not clear as to why this is based upon my test programming code. I understand that timeouts and transmission-received acknowledgments can be issues as I’ve read in the forums, but I am really not up-to-speed with much of this yet.
2. I’m just now starting to look into possible use of the I2C bus for this purpose, but in reading some posts, I am not clear if this will work simplistically and effectively between what I’m led to believe are multiple, (3) in my case, bus master? devices (40X1’s).
a. It appears that the I2C portc pins 18 and 23 (SCL/SDA) of the 40X1 need to be reserved and configured for special use with the ic2slave command, then pulled-high using a 4k7 resistor in each line. It would seem then that these pins can no longer be assigned as digital inputs or outputs; is this assessment correct? If so…
b. Would it be correct then to configure portc as follows: let dirsc = %11100111 where the “00” bits are assigned to the I2C pins (assuming one would like to configure the remaining portc pins as outputs)?
In Conclusion:
Available information concerning the use of either of these two methods appears quite sketchy and limited from what I have seen so far. If something similar to what I’m trying to accomplish in addressing multiple outputs across several PICAXE chips has been effectively done by anyone utilizing either of these methods, I would greatly appreciate any insight.
In retrospect, perhaps there‘s a more suitable approach / product to handle this, but I plan to persevere with the PICAXE nonetheless. Thanks again so much for your help.
Last edited: