Arduino IO Expansion

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 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 to join the conversation.

More
2 years 7 months ago #295276 by blazini36
Replied by blazini36 on topic Arduino IO Expansion

Can you please try the ino File I send you in the attachments?
 
 
That file is has different pin numbers that are not part of my keyboard for LedGndPins, am I supposed to change something?
 
I tried that file as it is, didn't do anything, doesn't print VCC and GND so I think it's not actually setting pins. I see what you were trying to do by tricking it into thinking there were 8 LEDrow pins so I corrected the LedGndPins and used the 4 correct LedRowPins + 4 unused pins to total 8 LedRowPins. Doesn't do anything either.

 

Please Log in to join the conversation.

More
2 years 7 months ago #295288 by blazini36
Replied by blazini36 on topic Arduino IO Expansion
OK so me and a friend got this LED thing figured out. It was exactly what I said before, what I didn't realize is that the uncommented prints  between lines 953 and 958 were clogging the pipe everytime an LED was set. My friend will make a PR tomorrow but this:

Line 455  fixes the key matrix
Code:
keys[row][col] = row * numCols + col;


and this between Line 949 and 963 fixes the LED matrix
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%numGndPins],LOW);  /*            Serial.print("VCC: ");       Serial.print(LedVccPins[currentLED/numVccPins]);       Serial.print(" GND: ");       Serial.println(LedGndPins[currentLED/numGndPins]); */             delayMicroseconds(interval);                          //wait couple ms       digitalWrite(LedVccPins[currentLED/numVccPins],LOW);  //turn off and go to next one       digitalWrite(LedGndPins[currentLED%numGndPins],HIGH);     }   }
 

Please Log in to join the conversation.

More
2 years 7 months ago #295357 by AlexMagToast
Replied by AlexMagToast on topic Arduino IO Expansion
glad you have figured it out. Obviously I have forgotten to edit these Serial prints out, since they are for debugging only.
I'll test your suggestion and update it accordingly.
Does the keyboard and LEDs work now?

Please Log in to join the conversation.

More
2 years 7 months ago #295364 by blazini36
Replied by blazini36 on topic Arduino IO Expansion

glad you have figured it out. Obviously I have forgotten to edit these Serial prints out, since they are for debugging only.
I'll test your suggestion and update it accordingly.
Does the keyboard and LEDs work now?
 
Yes, keypad and LEDs work as expected and it seems to be working well in HAL. My friend has created the PR on the git.

There should be some further improvements to the keypad code. If you hit 2 keys at once, accidentally or otherwise it winds up activating about 6 or so key inputs. That's probably just how the electrical paths work but the firmware should do something to disregard the errored key inputs. Once these key errors activate they also do not self-reset, they will stay active until you press that key.

I'll mention these to my friend, maybe he can find more time to help. I'm also thinking of doing a version that just uses I2C for the keypad as that should avoid any issues with multiple key presses and avoid the LED dimming that happens when the key pins switch from outputs to inputs. I wanted to use a Teensy initially but went with a Mega because of the lack of pins on the Teensy 4.1 and the lower voltage/current. I can get around much of that by just using I2C expanders on the keypad.

Please Log in to join the conversation.

More
2 years 6 months ago #298820 by Mr. Mass
Replied by Mr. Mass on topic Arduino IO Expansion
Great work, thanks for sharing.
Planning to use this in my next machine. Made a small test bench for training so far. I was able to set up almost all the functions I needed, but had a issue with one. It's about the encoder that works in mode 1. In the Arduino IDE in the monitor everything works as it should, but not in LinuxCNC. It practically does not react to the encoder rotation, it is possible to change the value after 20-30 positions of the encoder itself. Maybe I missed something or configured incorrectly? Here is a small video with this issue.

Please Log in to join the conversation.

More
2 years 1 month ago #309395 by vibram
Replied by vibram on topic Arduino IO Expansion
Hello,

Thank you for the work, this help me a lot in my retrofit :)

I run into an issue when I try to run the command loadusr arduino-connector
I get the following error : execv(arduino-connector) permission denied

I verified the chmod and it's executable. I had to modify the python path to /usr/bin instead of usr/bin/env but made no other change.

If I start halrun with sudo, I get the same issue and I don't understand why.
Linuxcnc 2.9.2 from the official iso

Thank you for your help

Please Log in to join the conversation.

More
2 years 1 month ago #310045 by vibram
Replied by vibram on topic Arduino IO Expansion
Hello
I managed to solve the issue with the following command:

loadusr python3 /usr/bin/arduino-collector

Another question regarding the keyboard : is it possible to send a keystroke for a shortcut ?

Thank you for your help

Please Log in to join the conversation.

More
1 year 10 months ago #316233 by angelnu
Replied by angelnu on topic Arduino IO Expansion
Hello everyone.
I am trying to connect an MPG encoder, but it does not work, it does not always count to 0. I connect it to an Arduino Nano in pins 2 and 3 that are the pins with interruptions.

I have modified in the .ino file:
#define Quadencs 1;
Encoder Encoder0 (2,3); // a, b pin
const int quadencsig = {2,2};
const int quadencmp = {4.4};

In the .py file
Quadencks = 1
Quadenck = [2,2]

Please Log in to join the conversation.

Time to create page: 0.351 seconds
Powered by Kunena Forum