Discuss What is the best signal interface for PC ? in the UK Electrical Forum area at ElectriciansForums.net
So do you select in software one LED at a time by setting one of the line bits and one of the column bits? And then send this data to the MCP23017? Thus to illuminate say all 35 LEDs you have to sequence through 35 pairs of line and column bits (Column, Line). Each data transfer to the MCP23017 has a cycle time Tc - I have yet to find out what this time is. Thus to refresh completely the 35 LEDs will take a time of 35 x Tc - this is the time necessary to send 35 pairs of (Line, Column) messages. This is a slow way to control the 7 x5 display. You could use the 16 bits data outputs in the format ( C1, C2, C3, C4, C5, X, X, X, L1, L2, L3, L4, L5, L6, L7, X) to illuminate a combination of 7 LEDs in one column using one data transfer, and thus the whole display in 5 data transfers - a considerable reduction in data transfer time from 35 Tc to 5 Tc. (The X means not used).
To do this you would have to add some simple hardware to the 7 x 5 display - some transistors and resistors to interpret the 16 bit data word into switches to control the application of 5V and 0V to the LED array. The scanning has to be done column by column to take advantage of the common cathode arrangement inside the array.
Exactly.So do you select in software one LED at a time by setting one of the line bits and one of the column bits? And then send this data to the MCP23017?
#include "Arduino.h" //core library that contains all of the Arduino’s built-in functions (from 2022)
#include <Adafruit_MCP23X17.h> //this is Adafruit-MCP23017-Arduino-Library version 2.1.0
Adafruit_MCP23X17 mcp1; //Instantiate mcp1 object
void setup()
{
Serial.begin(19200);
mcp1.begin_I2C(0x20);
for(int i = 0; i <= 15; i++)
{
mcp1.pinMode(i, INPUT);
}
for(int i = 0; i <=15; i++)
{
mcp1.digitalWrite(i, LOW);
}
//LED MATRIX DISPLAY - Single LED - one by one
/* LOGIC:
//Columns----------------------------------------
// mcp1.digitalWrite(1, LOW); //A1=1=column A
// mcp1.digitalWrite(10, LOW);//B1=10=column B
// mcp1.digitalWrite(3, LOW); //A3=3=column C middle
// mcp1.digitalWrite(11, LOW);//B2=11=column C middle
// mcp1.digitalWrite(4, LOW); //A4=4=column D
// mcp1.digitalWrite(13, LOW);//B6=13=column E
//Lines----------------------------------------
// mcp1.digitalWrite(5, HIGH);//Line1
// mcp1.digitalWrite(0, HIGH);//Line2
// mcp1.digitalWrite(6, HIGH);//Line3
// mcp1.digitalWrite(2, HIGH);//Line4
// mcp1.digitalWrite(12, HIGH);//Line4
// mcp1.digitalWrite(8, HIGH);//Line5
// mcp1.digitalWrite(14, HIGH);//Line6
// mcp1.digitalWrite(9, HIGH);//Line7
*/
}
void Reset()
{
for(int i = 0; i <=15; i++)
{
mcp1.pinMode(i, INPUT);
mcp1.digitalWrite(i, LOW);
}
}
int dly = 1;
void chr_A()
{
//line1
mcp1.pinMode(5, OUTPUT); //line
mcp1.digitalWrite(5, HIGH);
mcp1.pinMode(10, OUTPUT); //column
mcp1.digitalWrite(10, LOW);
mcp1.pinMode(3, OUTPUT); //column
mcp1.digitalWrite(3, LOW);
mcp1.pinMode(4, OUTPUT); //column
mcp1.digitalWrite(4, LOW);
delay(dly);
Reset();
//line2
mcp1.pinMode(0, OUTPUT); //line
mcp1.digitalWrite(0, HIGH);
mcp1.pinMode(1, OUTPUT); //column
mcp1.digitalWrite(1, LOW);
mcp1.pinMode(13, OUTPUT); //column
mcp1.digitalWrite(13, LOW);
delay(dly);
Reset();
//line3
mcp1.pinMode(6, OUTPUT); //line
mcp1.digitalWrite(6, HIGH);
mcp1.pinMode(1, OUTPUT); //column
mcp1.digitalWrite(1, LOW);
mcp1.pinMode(13, OUTPUT); //column
mcp1.digitalWrite(13, LOW);
delay(dly);
Reset();
//line4-midle
mcp1.pinMode(2, OUTPUT); //line
mcp1.digitalWrite(2, HIGH);
mcp1.pinMode(1, OUTPUT); //column
mcp1.digitalWrite(1, LOW);
mcp1.pinMode(10, OUTPUT); //column
mcp1.digitalWrite(10, LOW);
mcp1.pinMode(3, OUTPUT); //column
mcp1.digitalWrite(3, LOW);
mcp1.pinMode(4, OUTPUT); //column
mcp1.digitalWrite(4, LOW);
mcp1.pinMode(13, OUTPUT); //column
mcp1.digitalWrite(13, LOW);
delay(dly);
Reset();
//line5
mcp1.pinMode(8, OUTPUT); //line
mcp1.digitalWrite(8, HIGH);
mcp1.pinMode(1, OUTPUT); //column
mcp1.digitalWrite(1, LOW);
mcp1.pinMode(13, OUTPUT); //column
mcp1.digitalWrite(13, LOW);
delay(dly);
Reset();
//line6
mcp1.pinMode(14, OUTPUT); //line
mcp1.digitalWrite(14, HIGH);
mcp1.pinMode(1, OUTPUT); //column
mcp1.digitalWrite(1, LOW);
mcp1.pinMode(13, OUTPUT); //column
mcp1.digitalWrite(13, LOW);
delay(dly);
Reset();
//line7
mcp1.pinMode(9, OUTPUT); //line
mcp1.digitalWrite(9, HIGH);
mcp1.pinMode(1, OUTPUT); //column
mcp1.digitalWrite(1, LOW);
mcp1.pinMode(13, OUTPUT); //column
mcp1.digitalWrite(13, LOW);
delay(dly);
Reset();
}
void loop()
{
chr_A();
}
100Hz not 100kHz! - VERY Interesting that you mention this! This is helpful. So my 1ms delay in code might not be a real 1ms at all. The speed in reality is probably somewhere at 20Hz now that I think about it. Hmmmm... very intriguing. They definitely have some issues on their I2C pins on that arduino board.For most people a refresh rate of 50 to 100Hz fools the eye and brain to see a flicker free image as in a conventional TV picture - but modern TV's may do something different these days.
I counted 7 one millisecond delays, one after the other in this sub-routine. I suppose for now that from the start to end of this sub-routine takes of the order 7mS. I cannot quickly work out if 7mS is to generate a single column of 7 LEDs, a single line of 5 LEDs or all 35 LEDs. Please check my analysis because I am pretty sure I have not completely understood your code. You understand how you have written the code so ought to be able to arrive at figure of about 30Hz or lower which you mentioned earlier.Exactly.
Here is the actual program for 'letter A' that I made and presented in the movie.
You may not understand everything but read the entire program anyway and you will get something out of it. I've also put notes what is line and what is column.
(it was imperative to switch to Input everything after each step, with my custom Reset(); method, otherwise it was liting up the entire next line or column)
Remember a line is HIGH because is +5V and a column is LOW because is 0V. So we lit a single line putting +5V on line01(for ex) and 0v on each desired column.
Code:#include "Arduino.h" //core library that contains all of the Arduino’s built-in functions (from 2022) #include <Adafruit_MCP23X17.h> //this is Adafruit-MCP23017-Arduino-Library version 2.1.0 Adafruit_MCP23X17 mcp1; //Instantiate mcp1 object void setup() { Serial.begin(19200); mcp1.begin_I2C(0x20); for(int i = 0; i <= 15; i++) { mcp1.pinMode(i, INPUT); } for(int i = 0; i <=15; i++) { mcp1.digitalWrite(i, LOW); } //LED MATRIX DISPLAY - Single LED - one by one /* LOGIC: //Columns---------------------------------------- // mcp1.digitalWrite(1, LOW); //A1=1=column A // mcp1.digitalWrite(10, LOW);//B1=10=column B // mcp1.digitalWrite(3, LOW); //A3=3=column C middle // mcp1.digitalWrite(11, LOW);//B2=11=column C middle // mcp1.digitalWrite(4, LOW); //A4=4=column D // mcp1.digitalWrite(13, LOW);//B6=13=column E //Lines---------------------------------------- // mcp1.digitalWrite(5, HIGH);//Line1 // mcp1.digitalWrite(0, HIGH);//Line2 // mcp1.digitalWrite(6, HIGH);//Line3 // mcp1.digitalWrite(2, HIGH);//Line4 // mcp1.digitalWrite(12, HIGH);//Line4 // mcp1.digitalWrite(8, HIGH);//Line5 // mcp1.digitalWrite(14, HIGH);//Line6 // mcp1.digitalWrite(9, HIGH);//Line7 */ } void Reset() { for(int i = 0; i <=15; i++) { mcp1.pinMode(i, INPUT); mcp1.digitalWrite(i, LOW); } } int dly = 1; void chr_A() { //line1 mcp1.pinMode(5, OUTPUT); //line mcp1.digitalWrite(5, HIGH); mcp1.pinMode(10, OUTPUT); //column mcp1.digitalWrite(10, LOW); mcp1.pinMode(3, OUTPUT); //column mcp1.digitalWrite(3, LOW); mcp1.pinMode(4, OUTPUT); //column mcp1.digitalWrite(4, LOW); delay(dly); Reset(); //line2 mcp1.pinMode(0, OUTPUT); //line mcp1.digitalWrite(0, HIGH); mcp1.pinMode(1, OUTPUT); //column mcp1.digitalWrite(1, LOW); mcp1.pinMode(13, OUTPUT); //column mcp1.digitalWrite(13, LOW); delay(dly); Reset(); //line3 mcp1.pinMode(6, OUTPUT); //line mcp1.digitalWrite(6, HIGH); mcp1.pinMode(1, OUTPUT); //column mcp1.digitalWrite(1, LOW); mcp1.pinMode(13, OUTPUT); //column mcp1.digitalWrite(13, LOW); delay(dly); Reset(); //line4-midle mcp1.pinMode(2, OUTPUT); //line mcp1.digitalWrite(2, HIGH); mcp1.pinMode(1, OUTPUT); //column mcp1.digitalWrite(1, LOW); mcp1.pinMode(10, OUTPUT); //column mcp1.digitalWrite(10, LOW); mcp1.pinMode(3, OUTPUT); //column mcp1.digitalWrite(3, LOW); mcp1.pinMode(4, OUTPUT); //column mcp1.digitalWrite(4, LOW); mcp1.pinMode(13, OUTPUT); //column mcp1.digitalWrite(13, LOW); delay(dly); Reset(); //line5 mcp1.pinMode(8, OUTPUT); //line mcp1.digitalWrite(8, HIGH); mcp1.pinMode(1, OUTPUT); //column mcp1.digitalWrite(1, LOW); mcp1.pinMode(13, OUTPUT); //column mcp1.digitalWrite(13, LOW); delay(dly); Reset(); //line6 mcp1.pinMode(14, OUTPUT); //line mcp1.digitalWrite(14, HIGH); mcp1.pinMode(1, OUTPUT); //column mcp1.digitalWrite(1, LOW); mcp1.pinMode(13, OUTPUT); //column mcp1.digitalWrite(13, LOW); delay(dly); Reset(); //line7 mcp1.pinMode(9, OUTPUT); //line mcp1.digitalWrite(9, HIGH); mcp1.pinMode(1, OUTPUT); //column mcp1.digitalWrite(1, LOW); mcp1.pinMode(13, OUTPUT); //column mcp1.digitalWrite(13, LOW); delay(dly); Reset(); } void loop() { chr_A(); }
I do not immediately see the connection between the potential of the outputs and its impact on your time problem.Good morning mister @marconi ,
Here is something interesting... Im not sure how much may have been influenced my program testing so far, I will have to make a more extensive research on this particular detail, but in time. For the momment, with the programs I run already, I didnt really observed much of a difference to be honest. But it crossed my mind that this little bugger might be important in some special cases, special programs. Time will tell.
So here it is - full view:
View attachment 100791
The blue lines represent the Ground or 0V. I marked with a square the 0V marking next to the metalic pad from which the wire is going beneath the cardboard to that long track on which, each negative pin for all the LEDs are connected. So what I have there is a pull down connection through each 12k resistor put in series to each LED to ground.
View attachment 100792
This problem I realize it yesterday, when I was programming and was meditating to the fact those pins from the IC are not really floating or inAir. I then realized they are actually pulled to ground through each led. And today, I mounted that little switch only between this rail for all the leds and 0V. I tested a couple of normal programs but no visible difference. Ill have to test some in depth programs that I have 'somewhere' that really needs some floating pins. I really hope it will be a difference this time. If not, then, daaaaeeem.
First off all, congratulation on the movie and showing the full working project. Very fascinating !!!I do not immediately see the connection between the potential of the outputs and its impact on your time problem.
Thank you. I see what you mean. The same applies to the eeprom I used but in its case it did not do anything with the data at its input/output pins until they were selected as such and there was a 'read' signal pulse. I suppose the same applies to the MCP23017. I have not had the time nor inclination to fully understand how the 23017 operates and is used to offer any immediate advice. I remain sceptical though.First off all, congratulation on the movie and showing the full working project. Very fascinating !!!
I still have to try it your way someday, in the future.
-to your question now: - Well, when a pin of the IC is floating , it is not 0V nor 5V. Right? But by having all those leds and resistors to 0V, I efectively put to 0V every IO pin of the chip. THus, not leaving anything really floating. This is important in code, when I am switching from Outputs to Inputs. By switching to Inputs is the programming way of 'floating' the Output. By inversing it. Its a trick learned when I was programming PIC's MCU's. But... having all these pins to 0V ---anyway--- , it doesnt matter if I was switching to Input or to Output in code, because the state was 0V anyway. So the speed was not affected but the entire logic of the code was affected, which is more important and more drastic. I hope is more clear now what I did there.
Dont worry about that. That is my concern.I have not had the time nor inclination to fully understand how the 23017 operates
Im still hesitant at this moment as well. I pick things if I can follow a logic. But right now is 0 in my mind.Brilliant work! Your earlier hesitancy was unfounded. As I suspected, you pick things up quickly.
Yes. But please dont make a BIG box for it, since these mail monkeys here in my town, are looking directly to the size of the package, and then to it's weight. And they tax plentifully if is over-sized or over-weight. My suggestion and please do exactly as Im telling you, put this IC into a simple envelope, the smaller the better. Like this is perfect : (trust me)I have two eeproms left - would you like me to send you one?
Well, look on them and BE SURE are these devices from your links. And not some other brand or #id.I bought over a year ago(! - I lack your motivation) some RF Solutions radio frequency key fobs and receivers boards which I need to turn into a working system. I think it was these items - need too search them out.
Reply to What is the best signal interface for PC ? in the UK Electrical Forum area at ElectriciansForums.net
We get it, advertisements are annoying!
Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features of our website. For the best site experience please disable your AdBlocker.