Arduino IO Expansion

More
2 years 7 months ago - 2 years 7 months ago #295212 by AlexMagToast
Replied by AlexMagToast on topic Arduino IO Expansion
The Leds are counted from 0-total number of LEDs. So 0- 31 in your case. M0:1 turns on the first LED. M1:1 the second. By doing this you should see which way the rows are counted in your case. (left/right/up or down).
Possibly the LEDs are messed up because the Pin definitions dont match with the actual pcb.
I'd expect that M0:1 M7:1 lights up top left and top rigth LEDs in your setup.
I think you can go from there and try to debug your setup this way.
Also what Keys are you useing? Are they all normally open?
Last edit: 2 years 7 months ago by AlexMagToast.

Please Log in or Create an account to join the conversation.

More
2 years 7 months ago - 2 years 7 months ago #295216 by blazini36
Replied by blazini36 on topic Arduino IO Expansion
The keys and LEDs are exactly as shown in the drawing, that is the schematic for the PCB so yes, they are all normally open. If you look at the example sketches I posted for the Key and LED matrix's they work perfectly as shown in the video. The key matrix test only prints 1 character to the serial terminal so I reused characters but there's nothing strange about it, no stuck keys or anything like that.

Possibly the LEDs are messed up because the Pin definitions dont match with the actual pcb.

Not quite sure what this means, it would be very unlikely that the key numbers "matched" the Arduino pin numbers, nobody would wire it like that. The keys/LEDs are in reverse order opposed to the pin numbers but I asked about this before and you said before that this does not matter, it follows the order they are defined, which is why I defined them backwards.

I tried disabling the key matrix, the LEDs work the same. I'm not good with code but it looks like something is hardcoded to start the next row @ 4, as if it always assumes it is a 4 column keyboard. I made a note of how they print, this is why there is duplicates. Turning on an LED seems to grab one of the duplicates which is why it didn't make sense. All the keys that rapid print are duplicates, and they are colored green in my notes. I've checked and I don't think I misconfigured anything but I will post my current ino as well

 

Your browser does not support embedded PDFs. Please download the file here: Download PDF.



 

File Attachment:

File Name: LinuxCNC_A...3-05.txt
File Size:32.53 KB
Last edit: 2 years 7 months ago by blazini36.

Please Log in or Create an account to join the conversation.

More
2 years 7 months ago #295260 by AlexMagToast
Replied by AlexMagToast on topic Arduino IO Expansion
I don't understand your drawing. Is this the output of the Keypad / Matrix keyboard?

The duplication issue is obviously wrong and propably the root of the issue with the keyboard.
I think we should focus on one first. Would you like to get the keys or the leds working first?



I know this is confusing, but I decided it was ok, since this is internal communication, but the Feature of Keyboard and Matrixled are both encoded by 'M', so when Arduino sends it, it is a Key pressed. When you type it it refers to an LED. From your wiring the LEDs i'd expect them to be numbered like this: (possibly the keys too)
0 4 8 12 16 etc...
1 5 9 13 17
2 6 10 14 18
3 7 11 15 19

It doesn't really matter, but just imagine your matrix flipped by 90°
In the Py file these keys get their value assigned, and there you can change it to match your setup.

Please Log in or Create an account to join the conversation.

More
2 years 7 months ago - 2 years 7 months ago #295263 by blazini36
Replied by blazini36 on topic Arduino IO Expansion
The drawing is showing you what each key is printing to the serial terminal, this is just the Arduino firmware, it is not the Python stuff. The LEDs seem to match one of the numbered keys but since they are duplicated you would not know which key the LED is actually going to address. If you fix the key numbering issue I suspect the LEDs will work fine.

The Green boxes are the keys that rapid fire, they are also all duplicated M#s so that is likely the issue.

The problem is it should start the 2nd row at M8, not M4. It does this for every row, as it is assuming there are 4 columns when there are 8 columns.

I could be wrong about this but in your videos you were using a 4x4 keypad. You would not catch this issue if you were using a keypad with 4rows and 4columns

My Keypad is arranged 0-7, 8-15, 16-23, 24-31. It sounds like you are suggesting that it is expecting to count down through the rows, I am expecting that it counts across the columns left to right....which is exactly what it does, problem is it starts a new row x numRows, it should start numbering a new row x numCols.
Code:
[code] 
[/code]
Last edit: 2 years 7 months ago by blazini36.

Please Log in or Create an account to join the conversation.

More
2 years 7 months ago #295268 by AlexMagToast
Replied by AlexMagToast on topic Arduino IO Expansion
Can you please try the ino File I send you in the attachments?

Please Log in or Create an account to join the conversation.

More
2 years 7 months ago #295275 by blazini36
Replied by blazini36 on topic Arduino IO Expansion
Found an issue @ line 455. Looks like:
Code:
    keys[row][col] = row * numRows + col;

should have been
Code:
keys[row][col] = row * numCols + col;

Now the key matrix works as expected, no more rapid prints or duplicated M#s, the keys increment left to right and the next row starts next key. It didn't fix the LED issue, I've got a friend hunting that down. Trying to figure out if this is correct, lines 949-961
Code:
  for(currentLED = 0; currentLED < numVccPins*numGndPins ;currentLED ++){     if(ledStates[currentLED] == 1){                         //only handle turned on LEDs       digitalWrite(LedVccPins[currentLED/numVccPins],HIGH); //turn current LED on       digitalWrite(LedGndPins[currentLED%numVccPins],LOW);              Serial.print("VCC: ");       Serial.print(LedVccPins[currentLED/numVccPins]);       Serial.print(" GND: ");       Serial.println(LedGndPins[currentLED%numVccPins]);              delayMicroseconds(interval);                          //wait couple ms       digitalWrite(LedVccPins[currentLED/numVccPins],LOW);  //turn off and go to next one       digitalWrite(LedGndPins[currentLED%numVccPins],HIGH);

(LedGndPins[currentLED%numVccPins] looks like it should be (LedGndPins[currentLED%numGndPins] but simply changing those lines did not fix it.

Please Log in or Create an account to join the conversation.

Time to create page: 0.297 seconds
Powered by Kunena Forum