Hello everyone,
I'm new to the forum here and a beginner with electronics. I am working with a dual auxiliary feeder unit that has been added to an injection molding machine. The feeder unit, in its original state, would meter two materials simultaneously on each cycle. I have added an arduino to interrupt the output signals to each brushless motor to allow an alternating pattern of each material. For example in its original form each repeating cycle was AB, AB, AB... What I want is A, B, A, B...
After fabricating everything the bench tests worked well with the exception of a feedback of some sort through the signal wire on pin D2 which caused a slow rotation of each brushless motor. To combat the feedback I installed a 1N4007 diode which did the trick.
Next this whole unit was installed on the molding machine which required a longer run, approx. 12 ft, to the external signal relay. With the longer run I started experiencing a single flash for the output from D3 and D4 instead of the steady low signal I expected. I thought wire resistance might be a factor and upped the wire gage with no changes. If I short the signal wires closer to the arduino everything works as expected.
Thank You for your help.
//Constants
const int ChargeSig = 4;
const int Feeder1 = 2;
const int Feeder2 = 3;
const int chargeSigInterval = 100;
//Variables
int z = 2;
int count = z;
int x = 2;
int y = 1;
int PreviousScrewState = HIGH;
int ScrewState = HIGH;
unsigned long currentMillis = 0;
unsigned long previousChargeSigMillis = 0;
void setup() {
Serial.begin(9600);
Serial.println("Starting Shini Mixer");
pinMode(ChargeSig, INPUT);
pinMode(Feeder1, OUTPUT);
pinMode(Feeder2, OUTPUT);
}
void loop() {
int reading = digitalRead(ChargeSig); //Reading in signal from injection machine
if(reading != PreviousScrewState) { //compare to previous state low signal is on
previousChargeSigMillis = millis();
Serial.println("AAAA");
}
if((millis()-previousChargeSigMillis) > chargeSigInterval) { //debounce check .1 seconds
if(reading != ScrewState){
ScrewState = reading;
Serial.println("BBBB");
if(ScrewState == LOW){
count--;
while(digitalRead(ChargeSig) == LOW){
if(count == 0){
count = z;
}
if(count == x){
digitalWrite(Feeder1, LOW);
}
if(count == y) {
digitalWrite(Feeder2, LOW);
}
}
}
}
}
PreviousScrewState = reading;
digitalWrite(Feeder1, HIGH);
digitalWrite(Feeder2, HIGH);
Serial.println(digitalRead(ChargeSig));
Serial.println(reading);
}
