I'm brand new to the world of Arduino. I have robotics project where I need to send a signal from the robot controller's digital i/o to a Teknic servo motor. The motor requires a short pulse on the enable input to rotate, which I'm trying to set up at the moment. The current code I wrote continually pulses the motor, bypassing the digital read command on the input which should trigger the pulse. At this point I'm completely lost as to how to make it work. Any advice would be greatly appreciated.
Code and wiring diagram below
Thanks!
Mike
const int Enable = 6; // ClearPath ~enable input; +enable = BLU wire; -enable = ORN wire
const int InputA = 8; // ClearPath Input A; +InputA = WHT wire; -InputA is BRN wire
const int InputB = 9; // ClearPath Input B; +InputB = BLK wire; -InputB = YEL wire
const int triggerInput = 12;
void setup()
{ // put your setup code here, to run once:
pinMode(Enable, OUTPUT);
pinMode(InputA, OUTPUT);
pinMode(InputB, OUTPUT);
pinMode(triggerInput, INPUT);
// start off by ensuring thet the motor is disabled before proceeding
digitalWrite(Enable, LOW);
delay(10);
// set the two outputs to their initial states
digitalWrite(InputA, LOW);
digitalWrite(InputB, LOW);
delay(10);
digitalWrite(Enable, HIGH);
delay(15);
}
// end of setup code
// put your main code here, to loops indefinitely:
void loop() {
if (digitalRead(triggerInput) == HIGH) {
digitalWrite(Enable, LOW);
delay(15);
digitalWrite(Enable, HIGH);
delay(5000);
digitalWrite(Enable, LOW);
}
}
// end of main code, will loop indefinitely
Do you know how to use Serial.print for debugging? Code does not bypass things it runs things exactly as coded. Stick a serial print after your if to print the digitalread. Is your logic inverted? Maybe you should change the HIGH to LOW?
I would use serial in any event and maybe put one before the if to see if you get any low readings
a DC motor where with a driver card can be controlled in speed using a PWM signal and direction
a stepper motor which commonly has 4 or 6 pins with a polarity applied across pairs of wires in a sequence which steps the motor in either direction
an RC servo motor which has 3 pin: power, ground and signal. the signal is a 1-2 msec pulse that causes the motor to rotate to a position dictated by the width of the pulse
your drawing is unclear.
there are only 2 leads from your controller. may make sense if it is simply a single switch
your motor has just 2 leads. but if it's a DC motor, it's unlikely it can be driven by just a digital output which can only provide ~40 ma
could you provide part/model #s for your motor and controller?
The motor is powered by it own 24v supply. its connects with an 8pin molex connector, but I'm only using the enable pins at the moment as that is sufficient for testing, hence the 2 leads from the robot controller. The motor itself has a built in controller that is set to to rotate in precise increments based base on which input is triggered and is configured to accept a pulse between 10-20 ms.
I'm not familiar with serial.print for debugging but I'll look into that now.
momentary switches are typically connected between the pin and ground, and the pin configured for INPUT_PULLUP to use an internal pullup resistor that pulls the pin HIGH. pressing the switch grounds the pin, pulling it low
instead of of doing
if (digitalRead(triggerInput) == HIGH)
try
if (digitalRead(triggerInput) == LOW)
and configure the pin as
pinMode(triggerInput, INPUT_PULLUP);
when the switch is press, you code generates a active HIGH pulse for 15 msec and then waits 5 sec. may be better to just wait 500 msec
but i'm still a confused about the motor. how far, angle, is it configured to rotate with each pulse?
I'm not using a switch to trigger the motor, its a signal coming from the the digital output of the robot controller. Would the above code still apply? When the enable pin is pulsed the motor is set to rotate a turntable 10 degrees, which equates just of 4000 counts in the motor.
@mikeydubs642 what is the nature of the signal from the grey box robot controller? What is the robot controller able to say about what the motor should do?
Why is the Arduino the middle?
It would be nice to read what I assume is the copious and thorough user manual for your motors, but I'm not going to become a potential customer of Yeknik in order to take a peak.
For all I know, that spendy motor is controlled by a serial protocol, or each of the wires invokes or receives commands from the alleged four ways to make it do something…
Oh wait,
Now there's something I can waste spend some time on.
The robot controller is simply passing a 5V signal to the arduino from one of it's digital outputs. The robot program is running via roboDK which controls both a UR10 and UR5 robot. The native output of the digital i/o on the robot controller is 24V but has been stepped down with a buck converter and the lower voltage has been confirmed with a multimeter. For whatever reason I couldn't get RoboDK to pulse the motor consistently so it only works 90ish percent of the time which brings us to the Arduino. The motor itself has 3 inputs and 1 output. the inputs are Enable, InputA and InputB. The output is called an HLFB, or high-level-feeback, which can send a signal back indicating that the motor has completed its rotation. Currently, the motor is configured to rotate a turntable 10 degrees, when the enable input is pulsed and inputA and B read 0, absent an A & B signal produces the same result. Combinations of A&B on/off tell the motor to rotate in smaller or bigger increments, but the pulsed enable input is always required.
It should be configured for the low signal to pulse off for 15ms. Once the motor sees the signal is cut and engages in the set time, it begins to rotate.