Hello,
I just joined the FORUM, and would appreciate it if I can get some help. First,
I designed a robot gripper 2 DOF to work with 2 Herkulex 101 series smart servos, they have their own libraries and use softwareserial to control them, the Arduino Library for Herkulex servos can be downloaded at dfrobot website. I am using the ARDUINO UNO control board. I made small program, and got them working. The gripper is to be used for my SCARA robot arm project which I am currently working on.
The SCARA Robot will be using 3 NEMA 17 stepper motors , for the 2 link arms and
The Z, and 2 servos for the gripper. I have downloaded some open source Arduino code created by another user for a Scara ROBOT , BUT he uses a WEMOS D1 instead of ARDUINO UNO and CNC shield for the SCARA , I compile the program ( only ) with selecting WEMOS D1 as the board and seems to pass with no errors. Now, I’m not program savvy, but in the code he uses normal servos, but I want to use the smart servos that i mentioned above to work with the wemos , is there a way to do this ?? since the code was intended for a Wemos D1 and not ARDUINO UNO .
Or can the entire code just be written to work for an ARDUINO UNO board ?
I’m confused, I could share the program , just message me with your email
So I can send it off.
Thanks
your image
if you are not ready to share your code here, you might want to go to the "Gigs and Collaboration" sub-forum
you dont need to send it via mail, jou can put it in code blocks in the forum itself!
Hi, I attached the Scara Arduino code
scara Arduino code.zip (10.4 KB)
You'll need change all the Serial.printf()
into multiple Serial.print()
--> find all the printf() and modify accordingly. Mind adding bracket {} where needed as 1 expression will become multiple ones I spotted some printf are in a if statement with no brackets.
for example
for (uint8_t i = 0; i < NUM_MOTOR; i++) {
Serial.printf("%s current position: %d", &m_name[i], m[i].current_pos);
if (i == 0)
Serial.printf(" (%.1f mm.)\n", get_zx_height_from_current_position());
else
Serial.printf(" (%.1f deg.)\n", get_angle_from_current_position(i));
}
needs to become
for (uint8_t i = 0; i < NUM_MOTOR; i++) {
Serial.print(m_name[i]);
Serial.print(" current position: ");
Serial.print(m[i].current_pos);
if (i == 0) {
Serial.print(" (");
Serial.print(get_zx_height_from_current_position(), 1);
Serial.print(" mm.)\n");
}
else {
Serial.print(" (");
Serial.print(get_angle_from_current_position(i), 1);
Serial.print(" deg.)\n");
}
}
Also the pins numbers will have to change from Dx
to just x
Everything else is not really ESP specific and should compile on UNO
You will likely have many warnings when compiling as I could see some stuff that are not clean (order of initialization, the declaration of a variable as a uint8_t and then testing if it's strictly negative (eg uint8_t k in ik.ino) which will be always false as an unsigned int can't be negative (so the compiler gets rid of that code)
Also the UNO does not have really true double
, so everything will be float
when it comes to precision.