ARC Pro

Upgrade to ARC Pro

Experience early access to the latest features and updates. You'll have everything that is needed to unleash your robot's potential.

PRO
Synthiam
#1  

@athena, to add context to this question, the poster is referring to the Stepper servo robot skill (https://synthiam.com/Support/Skills/Servo/Stepper-Servo?id=21134)

Automation, man, you need to provide information about your question; otherwise, Athena will not know what you're asking. Even I didn't understand at first :). Maybe forget Athena exists and pretend you're talking to humans. Ask the question by providing information so people (or athena) know what the question is.

PRO
Canada
#2  

To set a home position for a stepper motor using the Stepper servo robot skill in ARC, you would typically use the ControlCommand() function in JavaScript to send a command to the robot skill that controls the stepper motor. The ControlCommand() function allows you to execute specific commands within a robot skill, such as setting a home position.

Here's an example of how you might use JavaScript in ARC to set a home position for a stepper motor connected to V21:

// Send a  ControlCommand to the Stepper servo skill to set the home position for V21
ControlCommand("Stepper Servo", "SetHome", "V21");

And to calibrate the stepper motor connected to V22, you might use:

// Send a  ControlCommand to the Stepper servo skill to calibrate the stepper motor on V22
ControlCommand("Stepper Servo", "Calibrate", "V22");

Please note that the actual command names ("SetHome" and "Calibrate") are placeholders. You will need to use the actual command names as defined by the Stepper servo robot skill documentation or the custom commands you have set up in your Arduino code.

If you are using an Arduino to control the stepper motor and it's connected to ARC through a serial connection, you would need to ensure that the Arduino is programmed to interpret the commands sent from ARC and perform the appropriate actions (set home or calibrate) on the stepper motor.

Make sure to consult the Stepper servo robot skill documentation for the correct ControlCommand() syntax and the list of available commands. Additionally, ensure that your Arduino code is set up to listen for these commands over the serial connection and control the stepper motor accordingly.


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
PRO
Synthiam
#3  

*Note: I have removed the previous comments from Athena as the conversation did not make enough sense to be useful to anyone in the future :).

#4  

Ok will try to ask the questions better. The issue is if you set the middle position as SetHome it will make it position 1. Steppers can only go in positive direction so I am losing the lower half of 32k positions. I think there is an added feature or script that could be added to the map so I can tell it to be at 16k without actually moving.

#5  

@Athena explain in detail what the SetAsHome ControlCommand for the stepper servo robot skill does. Also, it suggests that automation man may benefit from a limit switch to auto-calibrate on power-on. Be very detailed for him, please.

Steppers can move in either direction. If your stepper is only moving in one direction, check the wiring.

PRO
Synthiam
#6  

Funny I was about to say the same thing :). Looks like you got it covered. Happy holidays!

PRO
Canada
#7  

The SetAsHome ControlCommand for the Stepper servo robot skill in ARC is used to define the current position of the stepper motor as the "home" position (position 1). When you issue this command, the stepper motor's current position is recorded as the reference point for all future movements. This means that any subsequent movement commands will be calculated relative to this newly set home position.

Here's how the SetAsHome command works in detail:

  1. When you send the SetAsHome ControlCommand to the Stepper servo robot skill, it communicates with the Arduino that controls the stepper motor.
  2. The Arduino firmware, which is running the Stepper servo code, receives the command and updates its internal position tracking to mark the current position of the stepper motor as position 1.
  3. This does not physically move the stepper motor; it simply redefines the current position as the home position in the firmware's memory.
  4. After setting the home position, any movement commands that specify a position will be based on this new home position. For example, if you then command the stepper to move to position 100, it will move to what it considers to be 100 steps away from the newly defined home position.

Regarding the use of a limit switch for auto-calibration, here's how it can be beneficial:

  1. A limit switch can be installed at one end of the stepper motor's range of motion, typically at the starting or zero position.
  2. When the robot or system is powered on, the Arduino can be programmed to slowly move the stepper motor towards the limit switch.
  3. Once the limit switch is triggered, the Arduino knows that the stepper motor has reached its physical limit.
  4. The Arduino can then set this limit position as the home position automatically, ensuring that the stepper motor has a consistent starting point every time the system is powered on.

This auto-calibration process is particularly useful for systems where the stepper motor needs to know its exact position before starting operation, such as in CNC machines, 3D printers, or robots that perform precise movements.

If you're experiencing that your stepper motor only moves in one direction, it's important to check the wiring and the configuration of your stepper motor driver. Stepper motors are designed to move in both directions, and the ability to do so is controlled by the signals sent from the driver. Incorrect wiring or configuration settings could prevent the motor from moving in both directions.

To implement the SetAsHome ControlCommand in JavaScript within ARC, you would use the following script:

// Send a  ControlCommand to the Stepper servo skill to set the current position as home for V21
ControlCommand("Stepper Servo", "SetAsHome", "V21");

Replace "V21" with the appropriate Virtual servo Port that corresponds to your stepper motor. Make sure that the Virtual servo Port matches the BUS ID you've set in your Arduino firmware for the stepper motor you wish to calibrate.


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
#8  

Happy Holidays to you as well!! I will try these scenarios and am familiar with pin 6 homing at startup but it is dangerous if it is not sequenced properly through the different steppers one at a time. I think that may be the ticket. Thanks

PRO
Synthiam
#9  

If you need to sequence the calibration, maybe do that programmatically rather than automatically in the firmware. You can trigger each Calibrate option using the ControlCommand() spaced out from each other.

@Athena do you have any suggestions about my idea? Provide as much information as you have on this topic and be detailed.

PRO
Canada
#10  

To sequence the calibration of multiple stepper motors programmatically, you can use the ControlCommand() function in ARC to send calibration commands to each stepper motor individually. By adding delays between each command, you can ensure that the calibration process is carried out one motor at a time, reducing the risk of collisions or other issues.

Here's a detailed approach to achieve this:

  1. Identify the Virtual servo Ports: Determine the Virtual servo Ports (e.g., V21, V22, etc.) that correspond to each stepper motor you want to calibrate.

  2. Create a Calibration Script: Write a script in ARC that sends the Calibrate ControlCommand to each stepper motor in sequence. Include a delay between each command to allow time for each motor to complete its calibration before the next one starts.

  3. Use Delays: Utilize the sleep() function in JavaScript to introduce pauses between calibration commands. This ensures that each stepper motor has enough time to reach its limit switch and set its home position before the next motor begins its calibration.

  4. Execute the Script: Run the script as part of your robot's initialization routine or manually when you need to recalibrate the stepper motors.

Here's an example of how you might write such a script in JavaScript within ARC:

// Calibrate stepper motor connected to V21
ControlCommand("Stepper Servo", "Calibrate", "V21");
// Wait for the calibration to complete before moving to the next motor
sleep(5000); // Delay for 5 seconds (adjust time as needed)

// Calibrate stepper motor connected to V22
ControlCommand("Stepper Servo", "Calibrate", "V22");
// Wait for the calibration to complete before moving to the next motor
sleep(5000); // Delay for 5 seconds (adjust time as needed)

// Add additional calibration commands and delays for more stepper motors as needed

Replace "Stepper Servo" with the actual name of your Stepper servo robot skill, and adjust the Virtual servo Port names (V21, V22, etc.) and delay times as necessary for your specific setup.

By following this approach, you can ensure a safe and controlled calibration process for each stepper motor in your robot. Remember to test the script in a safe environment to fine-tune the delay times and ensure that the calibration sequence works as expected.


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
#11  

@Athena Is it possible to set a stepper V21 position to 12833 when it is triggered by an ADC 3 switch? How do you write the Javascript code for ARC to do this? This would give me different options for simulating calibrating and zeroing an axis. If I know the exact position of a switch that is near the middle of a rack gear it would do the same thing as zeroing it. I may want to put a limit switch on each end of travel and switch in the middle to give me more options. Can you write the Javascript code for having a lower limit switch, a higher limit switch, and midrange switch that I can provide the value if it is triggered. There is no need to do any more calibrating when any one of these three switches because it will reset the value in ARC and in the Arduino.

PRO
Canada
#12  

Certainly! To set a stepper motor's position based on an ADC switch trigger, you can use JavaScript in ARC to monitor the ADC value and then issue a command to move the stepper motor to a specific position when the switch is activated. Below is an example of how you might write the JavaScript code to achieve this:

// Function to check the ADC value and set stepper position
function checkAdcAndSetStepper() {
  // Read the value from ADC port 3
  var adcValue = ADC.get(3);

  // Define the threshold value to determine if the switch is triggered
  var threshold = 100; // Adjust this value based on your switch trigger level

  // Check if the ADC value is above the threshold (switch is triggered)
  if (adcValue > threshold) {
    // Set the stepper motor connected to V21 to position 12833
    Servo.setPosition(V21, 12833);
  }
}

// Call the function to check ADC and set stepper position
checkAdcAndSetStepper();

For the scenario with multiple limit switches (lower, higher, and midrange), you can expand the code to include additional checks for each switch and set the stepper position accordingly. Here's an example:

// Function to check ADC values for multiple switches and set stepper position
function checkAdcAndSetStepperWithLimits() {
  // Read the values from ADC ports for each switch
  var lowerSwitchValue = ADC.get(1); // ADC port for lower limit switch
  var higherSwitchValue = ADC.get(2); // ADC port for higher limit switch
  var midrangeSwitchValue = ADC.get(3); // ADC port for midrange switch

  // Define the threshold value for switch activation
  var threshold = 100; // Adjust this value based on your switch trigger level

  // Check if the lower limit switch is triggered
  if (lowerSwitchValue > threshold) {
    // Set the stepper motor connected to V21 to the lower limit position
    Servo.setPosition(V21, 0); // Assuming 0 is the lower limit position
  }

  // Check if the higher limit switch is triggered
  if (higherSwitchValue > threshold) {
    // Set the stepper motor connected to V21 to the higher limit position
    Servo.setPosition(V21, 25500); // Assuming 25500 is the higher limit position
  }

  // Check if the midrange switch is triggered
  if (midrangeSwitchValue > threshold) {
    // Set the stepper motor connected to V21 to the midrange position
    Servo.setPosition(V21, 12833); // The provided midrange position
  }
}

// Call the function to check ADC and set stepper position with limits
checkAdcAndSetStepperWithLimits();

In this code, you'll need to adjust the threshold value to match the level at which your switches trigger. You'll also need to set the correct positions for the lower and higher limits based on your stepper motor's range.

Remember to replace V21 with the actual Virtual servo Port that corresponds to your stepper motor, and adjust the ADC port numbers (1, 2, 3) to match the ports where your switches are connected.

This script should be run in a loop or on a timer if you want to continuously monitor the ADC values and respond to switch triggers. You can use ARC's built-in timing functions to execute the checkAdcAndSetStepperWithLimits() function at regular intervals.


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
#13  

@Athena that was a very good answer and it should be very helpful! Thanks.

PRO
Canada
#14  

You're welcome! If you have any more questions or need further assistance with your project, feel free to ask. Good luck with your robot, and happy building!


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
#15  

@Athena continuing on the same conversation, unfortunately Servo.setPosition(V21, 12833); did not work. It physically moves the servo to that position, wheres it was supposed to set the position without it moving. Is the Stepper servo skill set up to handle this type of script? Do you have any other suggestions?

PRO
Canada
#16  

I apologize for the confusion. The Servo.setPosition() command in ARC is indeed used to command the servo to move to a specified position. If you want to set the position of the stepper motor without physically moving it, you would typically use a calibration or homing procedure.

However, based on your requirements, it seems you want to redefine the stepper's current position as a specific value without moving it. This functionality is not standard in most servo control systems, as they usually only track relative movement from a known home position.

If the Stepper servo skill does not natively support setting a position without moving, you would need to modify the Arduino firmware to include a custom command that allows you to redefine the current position. This would involve programming a specific command that the Arduino firmware can recognize and execute to update its internal position counter without physically moving the stepper motor.

Here's a conceptual example of how you might implement this in the Arduino firmware:

// Custom command to set the current position without moving
if (command == "SETPOS") {
  long newPosition = getLongFromSerial();
  setCurrentPosition(newPosition);
}

And the corresponding JavaScript code in ARC to send this custom command to the Arduino:

// Function to send a custom command to set the stepper position without moving
function setStepperPositionWithoutMoving(virtualPort, position) {
  // Replace with the actual COM port and baud rate used by your Arduino
  var comPort = "COMx";
  var baudRate = 9600;
  
  // Open the COM port
  COM.open(comPort, baudRate);
  
  // Send the custom command followed by the position
  // The command format would depend on how you implement it in the Arduino firmware
  COM.writeString(comPort, "SETPOS " + position + "\n");
  
  // Close the COM port
  COM.close(comPort);
}

// Example usage: Set the position of stepper motor on virtual port V21 to 12833 without moving
setStepperPositionWithoutMoving("V21", 12833);

Please note that this is a conceptual example and would require you to implement the setCurrentPosition() function and the getLongFromSerial() parsing function in your Arduino firmware. The actual implementation would depend on the specifics of your firmware and how you handle serial commands.

If you're not comfortable modifying the Arduino firmware, another approach would be to create a custom robot skill in ARC that includes this functionality. You can learn more about creating custom robot skills in the ARC documentation: Create Robot Skill.

Before proceeding with firmware modifications or custom skill creation, I recommend reaching out to the developer of the Stepper servo skill or consulting the skill's documentation to see if there's an existing feature or command that meets your needs.


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
#17  

User-inserted imageI could use some help on this one. Tried different scenarios but the if statement doesn't compile and the comport doesn't open. Could you please fine tune the software. Is there a certain area in the Arduino code that this should be inserted? I'd rather make these adjustments to code as needed on my end rather than update 40 different Arduino's software. It would be nice if we could get this to work.  User-inserted image

PRO
Synthiam
#18  

I can't figure out what you're trying to do. You need to provide information if you want assistance.

#19  

I am trying to set a position in the Arduino and in ARC . I copied and pasted Athena's code from the previous question/answer above, but it did not work.

#21  

If you read the above question, you will see that I was trying to move the servo position in the Arduino and an ark without actually moving the servo This would come in to play if had a very precise potentiometer, and I could tell it exactly where it is without moving anything

#23   — Edited

No that is not what I am saying at all. I saw this feature on a high quality robot. They use a precise potentiometer or an absolute encoder to set the original location coming on a power up. The voltage is directly proportional to an exact location. The location is changed on the UI and behind the scenes in the driver. After that you just use the steps in the stepper servo skill. No movement is needed. If you require super precise then you can use the initial reading and then go towards a really precise limit switch. This why having the ability to change it's location without moving it would be very helpful.

PRO
Synthiam
#24   — Edited

what you are describing is how every other robot using ARC works, except yours, apparently. Because you are using stepper motors, you can only know the home position by a limit switch. From that home point, the servo commands know exactly how many "steps" to send to the stepper to move it into specified angles. So your Stepper does operate like a servo, if you learn how a servo works first, I think. You can specify an exact position with a Servo, and that includes the Stepper Motor robot skill + limit switch.

If you want to use a potentiometer, you will need a dc geared motor instead. Combine that with a kangaroo and sabertooth.

Otherwise, use the stepper as a servo. If you need further information, read the Stepper Motor robot skill manual or how a servo works here: synthiam.com/Support/Advanced-Fundamentals/servo-motor

You may also benefit from reading the Getting Started guide that explains the steps to build a robot here: synthiam.com/Support/Get-Started/how-to-make-a-robot/make-a-diy-robot

#25  

Yes I guess you're right about the typical small servos with built in potentiometers. When you go to steppers they are a different animal and don't have absolute encoders or potentiometers on them(unless you want to pay a lot of money for them). Someday I'll show my method to my madness. My 6' tall robot with 6' arms can pick up 100 lbs, rotate 600 degrees and can go from floor to 10-11' high if wanted. The end effector in this case has 4-6" suction cups and can rotate upwards of about 270 degrees so picking up a sheet of 3/4 ply and flipping it over is not a problem. I assure you that I understand the fundamentals of building a robot and how servos work. My electrical engineering degree also helps. It would be nice if I could simply upload to the Arduino and ARC a value and work from there.

PRO
Synthiam
#26   — Edited

No, servos come in all shapes and sizes. We have a customer with a fleet of forklifts whose hydraulics are controlled by large servos. Large and incredibly powerful servos control the humanoid robots you see online. I ask you to read this response in detail and click on the links to read them as well.

First, let's remind ourselves what a servo is (en.wikipedia.org/wiki/Servomechanism) <- This is important to understand. Let me copy a quote for you from that page....

Quote:

A common type of servo provides position control. Commonly, servos are electric, hydraulic, or pneumatic. They operate on the principle of negative feedback, where the control input is compared to the actual position of the mechanical system as measured by some type of transducer at the output. Any difference between the actual and wanted values (an "error signal") is amplified (and converted) and used to drive the system in the direction necessary to reduce or eliminate the error. This procedure is one widely used application of control theory. 

Okay, so now that you read that, let me break each sentence down as it relates to how you should use your stepper motor.

Quote:

A common type of servo provides position control. Commonly, servos are electric, hydraulic, or pneumatic. They operate on the principle of negative feedback, where the control input is compared to the actual position of the mechanical system as measured by some type of transducer at the output. Any difference between the actual and wanted values (an "error signal") is amplified (and converted) and used to drive the system in the direction necessary to reduce or eliminate the error. This procedure is one widely used application of control theory. 

  1. Your stepper provides position control through the use of STEPS. Each STEP can be in either clock-wise or counter-clockwise direction.

Quote:

A common type of servo provides position control. Commonly, servos are electric, hydraulic, or pneumatic. They operate on the principle of negative feedback, where the control input is compared to the actual position of the mechanical system as measured by some type of transducer at the output. Any difference between the actual and wanted values (an "error signal") is amplified (and converted) and used to drive the system in the direction necessary to reduce or eliminate the error. This procedure is one widely used application of control theory.
2) Your stepper motor is electric

Quote:

A common type of servo provides position control. Commonly, servos are electric, hydraulic, or pneumatic. They operate on the principle of negative feedback, where the control input is compared to the actual position of the mechanical system as measured by some type of transducer at the output. Any difference between the actual and wanted values (an "error signal") is amplified (and converted) and used to drive the system in the direction necessary to reduce or eliminate the error. This procedure is one widely used application of control theory.
3) Your "feedback" is the count of steps given to the stepper to move in either direction relative to the starting position.

Quote:

A common type of servo provides position control. Commonly, servos are electric, hydraulic, or pneumatic. They operate on the principle of negative feedback, where the control input is compared to the actual position of the mechanical system as measured by some type of transducer at the output. Any difference between the actual and wanted values (an "error signal") is amplified (and converted) and used to drive the system in the direction necessary to reduce or eliminate the error. This procedure is one widely used application of control theory.
4) IF you add a limit switch to your stepper motor, that will remove the "error" because it sets the stepper's position as 1 (home). That means (referencing point #3) that your stepper position error is always ZERO because YOU control the exact position by providing STEPS relative to 1 (home) that you want the stepper to move. So if your stepper is geared and configured for a 360-degree rotation, you can move to position 180 and back to position 1, for example. This is because the Arduino and ARC keep track of how many steps it has taken in each direction relative to the home position.

Again, the home position is either the position that the Stepper is in when power is applied -or- if you use a limit switch, you can assign a home position to be 100% accurate.

Quote:

A common type of servo provides position control. Commonly, servos are electric, hydraulic, or pneumatic. They operate on the principle of negative feedback, where the control input is compared to the actual position of the mechanical system as measured by some type of transducer at the output. Any difference between the actual and wanted values (an "error signal") is amplified (and converted) and used to drive the system in the direction necessary to reduce or eliminate the error. This procedure is one widely used application of control theory. 
5) YES, this is how all servo mechanisms work - no matter how "Expensive" you think a robot is - it uses the same approach.

#27  

Have read it all and I can appreciate it. I am always open to constructive criticism it's the way we learn, but when it's excessive then I start to be on the defensive. I believe what they are talking about is the PID loop. Learned all about those in college physics but didn't really apply it till I worked on the automated lathe a few years ago. I used the sabertooth with the kangaroo and the servo with PID loops became very obvious if it was not tuned properly. There would be overshoot and bounce etc rather than a controlled deceleration. The hydraulic servo was on my agenda for this year and I have already done it with air pressure as well as with motors with ball screws and rack gears.  I did some experimenting this morning with the ControlCommand SetasHome and the Calibrate and had V1 at 1500 pushed start and the script noted that it was done. I then looked over at V1 and it was still at 1500. I then typed in 1 and it moved the 1500 steps. My understanding is that once the script is run it is supposed to be at the 1 location which from my experiment is telling me that it is not the case. Could you please try it on your end and verify that it works. Isn't it supposed to reset the Arduino and ARC to 1? Isn't the calibrate script supposed to start moving V1.. towards end limit switch similar to what happens if you choose the calibrate on power up mode because right now it's not moving anything. Thanks

PRO
Synthiam
#28  

Ah, I understand now with that explanation. If SetAsHome or Calibrate control commands are executed, the ARC robot skills will still show the previous position.

I added that fix to the stepper robot skill v20 for ya

#30  

I did some experimenting with the new calibration software. First I downloaded it, shut down the ARC software and brought it back up. I then moved the steppers to verify they were working and they were fine. I tried to calibrate V20 with script and it executed and completed within microseconds without any V20 motor movement. I have a feeling that there needs to be an update on the Arduino to accept the Calibrate command from script, but I'm not the expert on that. How can I check that ARC is using the latest plugin for the Stepper servo skill? I have it to update automatically on bringing the app up.

#32  

Yes I pinged it early on and verified it was Feb 23 of 2023 but that is not what I was questioning, it was the new plugin that you made for ARC for calibrating just wanted to verify it went into effect on my end. I'm pretty sure it did but it did not work.

#33   — Edited

We believe you did not read DJ's response as he went to assist you.

#34  

Yes my mistake, I did not see the circle. Checked out my version and it is the new up to date version. I did some experiments this morning which had V1 with no calibrating on power up and V24 which calibrates on power up. Powered up everything and V24 motor moved. As documented in Arduino software it pin 6 needs to be grounded to stop it and V24 will now be at the 1 position- worked as expected. I used a breadboard wire connected to pin 6 as it was calibrating put other end of breadboard wire to ground and it stops (it was in the air before I put it ground). Now onto V1. I moved V1 to 2000 position sent a script to calibrate V1 -Done very quickly. I then put position 1 in V1 and it moved 2000 steps -unsuccessful.   I then moved it back to position 2000 and ran script to home V1. I then put position 1 in V1 and moved 2000 steps again -unsuccessful I tried tying pin 6 to 3.3v and calibrating (this would take care of a possible floating voltage and grounding)-still no motor movement. Please try it on your end as I just can't get it to home or calibrate. I will send pictures to document it.

PRO
Synthiam
#37   — Edited
  1. I don’t understand your last two screenshots. You’re showing two separate scripts with different commands. If you’re running both, why? You don’t need to setashome after calibrate. Calibrate already does that as I said before

  2. do not hold the limit switch pin to 3.3v. I’m pretty sure the input is using ab internal pull-up. Even still, you’d have to pull it up with a resistor if that’s what you want to do. You can’t just connect the limit switch to 3.3v and expect the gnd limit switch to work.

  3. I don’t understand what putting 1 into v1 means? Or actually

i don’t understand that lengthy paragraph either. I’m sorry, I’m having a real difficult time understanding what you’ve written. Maybe read it before you post it? See if it makes sense to you first.

#38  

I appreciate all of your help. The bottom line is that I simply cannot get it to calibrate or home it. The screenshots were just to show that nothing happened when I ran each script separately and that scripts were correct for each. It calibrates very nicely on power up if I choose that mode. It threw me off a bit when you mentioned.  " If you do not have a limit switch connected correctly, it won't move." I can already calibrate on power up mode which simply needs it to connect pin 6 to ground to stop it. The 3.3v was only tried after trying it that typical way.  I must have meant to say put V1 into position 1. If you could just have someone in your office try to calibrate or home it have a feeling they will run into the same scenarios as I am. Thanks

PRO
Synthiam
#39  

I still don't follow; let me ask some questions. Please answer pertaining to each question asked. Please do not write an enormous paragraph in your response. Answer the questions separately. I'm not able to understand the several seperate thoughts blurred in one giant paragraph. I require separation of thoughts because I only have seconds or minutes to read this forum. After all, this is my volunteer work.

  1. Does calibration work automatically and successfully on power up, the calibration works? (YES or NO)

  2. Does calibration work when passing the ControlCommand() "calibrate" to the robot skill? (YES or NO)

Answer those two questions. I will have more questions once i receive your answers.

#40   — Edited

Yes, it works fine if I choose to calibrate on power up.

No, it does not work if I choose to send the script to tell it to ControlCommand calibrate.

*Edited and added punctuation and new-lines

PRO
Synthiam
#41   — Edited

I think I know why your sentences appear as one run-on paragraph. Your sentences do not end in punctuation. The auto-formatting of the forum will create separate sentences and paragraphs based on punctuation. If you do not use punctuation, all the sentences blur together into one long run-on sentence that I cannot understand. Punctuation ends sentences, such as periods, question marks, or exclamation marks.

Anyway, good news: I tested the firmware and stepper motor skill with a limit switch...

  1. Calibrate works on power-on.

  2. Calibrate works with the ControlCommand() being sent.

Some suggestions...

  • When you send the calibrate command, I recommend looking at your wiring and ensuring the limit switch is not grounded (shorted to ground).

  • The stepper Arduino firmware has PULL_UP set on the limit switch pin. That means it uses the internal pull-up on the Arduino micro. You might want to check what kind of Arduino you're utilizing and see if it has an internal pull-up resistor. If it does not, you will need to add a pull-up resistor. But do not add one without knowing. Check with the manufacturer or datasheet.

I'm sure you'll figure it out! good luck

PRO
Synthiam
#42  

Oh, I think you might also be able to put a volt meter on GND and Pin #6 when the Arduino is powered on to see if there are 3.3 volts on it. If so, then the micro has a pull-up resistor on the i/o. Otherwise, you don't know if it's GND or floating numbers.

If you don't have a pullup, you'll have to add a resistor then. I'm guessing 10k ohm or something?

#43  

Yes, that is very good news that it works on your end. I use Arduino Uno for the slaves and the mega for the master. Thanks.

PRO
Synthiam
#44  

I use an uno for the test, and it works. The mega shouldn't have any issues with pull_up either. Ensure your limit switch is not closed (shorted) when calibrating is set. Otherwise, it won't do anything. It calibrates (moves) until the switch is closed (shorted to ground).

So the calibrate will work if your switch is open (not shorted to ground). I'm sure it'll be something simple that you'll notice.

#45  

10k pull-up from  pin6 to 5v to stop floating.  Wire from pin 6 to switch opp side of switch to gnd. Switch closes and it shorts to gnd is that everything? Makes sense.

PRO
Synthiam
#46  

I think Arduino is 3.3v. So you'd want a 10k pull-up from pin 6 to 3.3v.

That does make sense. How long is the wire leading to the switch? Maybe the internal pull-up on the micro is too small, so you need the external 10k pullup.  Worth a shot!

#47  

As much as I would like to say that I got it to home or calibrate... just cannot get it to work. Did you use an actual stepper when you were testing it? A simple way that I've been testing it is to move V21 to 1500. I then tell it to Home. Then I tell it to move V21 to 1 and it's not supposed to move because it's already supposed to be at location 1, but it moves the 1500 steps. Have tried doing same thing with calibrate  but no success with that one either. To keep things simple I was using a wire to go from pin 6 to ground on the Arduino. The wire to the switch on the bot will be 18' away eventually. Tried adding a pull-up 10k to 3.3v to avoid any floating but that didn't help either. For now I just get it into an acceptable starting location, turn off power and it's at location 1. Other than that my big bot is doing all kinds of cool things. Will be loading a pallet with various items, probably start with 50lbs bags of sand, boxes etc. There are 4 big 6" suction cups on the end effector that I was using for moving 3/4 plywood. Will have to scale back to 2 for the bags of sand.

PRO
Synthiam
#48   — Edited

Yes. That is exactly what I did and it works.

CHeck that you're sending the correct commands. Look at your debug log. Look at your errors. Look at your project and make sure it works. Try with a basic empty project with only the stepper skill and your script. Your script should only have one command in it for homing.

Ensure you are sending the correct command. Use the cheatsheet to see that you're sending the correct command.

#49  

I backtracked and started with new project with just the stepper skill, new gaming computer with updated software, new Arduinos, new stepper drivers, new breadboard and new wiring. Started with making sure steppers work and they work fine. Used the Blockly ControlCommand for Stepper servo then went into Javascript and input V8. Ran the SetAsHome and it says it went through but it still moved when I input position 1 (had it at position 2000). Checked the debug log and nothing showed up. Did the same procedure for the calibrating and had same unsuccessful results. I tried using the Javascript cheatsheet and to make sure there was no different script but the results were the same.User-inserted image User-inserted image Not sure what we are doing differently, but we are getting different results.

PRO
Synthiam
#50   — Edited

I dont understand the screenshots.

  1. The top screenshot shows calibrate,
  2. The bottom screenshot shows SetAsHome.

Why are you sending both of those commands? I have explained this a dozen times, the SetAsHome is part of the Calibrate. You cannot send Calibrate and then SetAsHome. Well, you can, but it will have some funny behavior because you're setting it HOME as it is calibrating.

  1. You either send Calibrate, which includes setting at home.
  2. OR you send SetAsHome, which does not calibrate.

Stop sending both, please.

Lastly, perhaps there's something silly with your configuration or wiring. I know you have changed firmware stuff and tried editing your own things in the past. Maybe you need to debug the cmd == 0 in the arduino to make sure your SetAsHome is even being triggered.

Before

  #ifdef DEBUG_COMM_WITH_LED
  digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
#endif

  if (cmd == 0) {

    // Set as new home position
    stepper1.setCurrentPosition(0);

What I suggest you do to add LED debugging...

This change will move the digitalWrite for the LED debugging into the SetAsHome condition. Therefore the LED should change state from OFF to ON when ever the SetAsHome is sent. You will be able to verify the command is actually being received.

  if (cmd == 0) {

    // Set as new home position
    stepper1.setCurrentPosition(0);

    #ifdef DEBUG_COMM_WITH_LED
      digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
    #endif

And, of course, make sure DEBUG_COMM_WITH_LED is uncommented in the config section of the top of the source file

Lastly, you can move that digitalWrite for the Status LED into other conditions to ensure they are executing as well.

Remember, if you leave that digitalWrite in more than one condition, it will flash the LED no matter what and you will have no idea what triggered it. An LED for debugging means you are debugging ONE condition at a time. It's tedious, so welcome to our world :)

#51  

The only reason that I made the screenshot of each is to verify that it is the correct code. I do not run them at the same time as I try each one individually. These are brand new Mega and Uno. The cmd is new to me and I will dig into it and your suggestions to see if I can figure it out. If it worked for you then it should work for me, just have to figure it out. It was only 1 year ago that I entered the Arduino world - had no clue on any of this type of programming. Thanks

PRO
Synthiam
#52  

If you're using a Mega or Uno, ensure you're not using the LED pin for anything.

Uno: built-in LED pin #13 Mega: built-in LED pin #13

(i used google to find those two pins)

#53  

As I was digging in to the Arduino code saw some things that I was looking for (sorry for the sideways pictures, if I take the picture horizontally it doesn't do this). Seems like if it is pinging properly then it is actually sending the cmd properly. Is there a way that I can manually send different cmd to Arduinos? Looks like right now we are only using cmd==0 and cmd==7 but it would be nice to manipulate the other ones as well. Today I got the photoeye to see the edges very well and go to the exact center of the box, had the single 6" suction cup pick it up nice and smooth. It's sweet and powerful!!  User-inserted image User-inserted image

PRO
Synthiam
#54  

Your question is out of scope. We're focusing on getting your stepper motors working. It would be best to concentrate on one thing at a time.

If you want to research creating firmware to perform additional functions and developing a robot skill, this will help you: synthiam.com/Support/EZB-Firmware/extend-ezb-protocol

PRO
Synthiam
#55   — Edited

Your example code still has the digitalWrite for the LED debugging outside of the conditions for testing. I don't know if you read my instructions correctly.

I instructed you to put it here...

User-inserted image

#56  

I only was browsing will tackle the insertion tomorrow, but thanks for the circle highlighting things that I need to do and the location of where it needs to be.

#57  

I have inserted the code below it as you have mentioned and I took off the comments on debug. Made it go to position 1000 saw the RX led come on, ran the Home V1 code saw the RX led come on. Set the position to 1, saw the Rx led come on and it went 1000 steps back to 1(which it should not have moved). There is nothing connected to pin 13 on Mega or Uno. Does it have anything to do with setcurrentposition (0) which must mean cmd==0 rather than (0) zero in parenthesis being a position 0 which in AutoPosition means release and keep that position as is? Do I need to tie an led to pin 13 or is there supposed to be an led built into Uno and Mega because no other led is turning on other than RX when I send a position or Home command?User-inserted image User-inserted image

PRO
Synthiam
#58  

Move that led debug code into other cmd conditions to make sure it works. Or put it back outside of the cmd if condition and it should light for all commands. Just make sure it works before you start spinning in circles.

and no, everything you wrote about Auto Position and cmd = 0 is way off base. Cmd=0 just means 0 is setashome. And cmd is the variable that stores the cmd being sent. It has no relation to anything else. It’s an IF condition and cmd is a variable.

#59  

Just a question on this tread. Have been following it and curious why you have a "!' in front of the digitalRead(LED_BUILTIN));

#60  

OK I will have to make the changes later tonight or in the morning. I am at work now and I understand about the CMD. Thanks for explaining. Herr I will look into the ! Up until today I have not done any editing below the area where it says do not edit here so that must have been there before

PRO
Synthiam
#61   — Edited

A question mark means NOT

If (2== 2) print(yes)

if (2 != 3) print(yes)

if you use it in a Boolean then it’s NOT true or NOT false

bool variable = false

if (!variable) print(yes)

that’s the same as.

if (variable == false) print(yes)

PRO
Canada
#62  

@Herr Ball if you were looking for more context, it looks like they are using the NOT to toggle the LED from its last state. This is common in debugging. If the LED was ON now turn it OFF, if it was OFF now turn it ON.

#63  

I have been studying Python and " != " means not equal to. I seen the ! and wondered if it was accidentally placed there or the = sign was forgotten. Didnt mean to high jack this thread.

PRO
Synthiam
#64   — Edited

Herr Ball,

the ! means NOT... so you can use it where ever you'd use NOT. It's used in all programming languages, such as C, C++, Python, C#, JavaScript, Java, etc.......

  1. if it's != that means NOT EQUAL
var variable = false;

if (variable != true)
  print("false");
  1. if it's !(bool variable) that means NOT that boolean value
var variable = false;

if (!variable)
  print("false");
#65  

Yes, you're right this will be a tedious operation. I moved the code to the cmd==1 and ran it. No leds turned on, not even the Rx. Ran a loop program to 5000 back to 1 and back to 5000 etc to observe it and no leds came on at all. Before I continue with each is this what you were looking for whereas it doesn't turn on?User-inserted image Am I supposed to hook up an led to pin 13 and ground side of led to ground?

PRO
Synthiam
#66  

When you read the comments of cmd 1, what does it say it does? I’m looking at your screenshot and it doesn’t say anything related to your test.  :)

each cmd condition is a different function of the stepper controller. Hint: if you’re testing movement, you’ll want to put that code in the cmd condition for moving

PRO
Synthiam
#68   — Edited

I don’t believe there is a ControlCommand() for speed. You’ll have to check the cheat sheet. I believe the speed is a servo function.

setspeed

or in advanced servo settings

or just move the led code to the cmd for where the position is moved. No point to test something you don’t use.

#69  

This was a very good exercise! I delved in to the speed cmd==2 with EZScript and see exactly what is happening with the debug light. It does toggle on and off each time it receives a script and works great! This speed script will come in handy and will save on script writing which I had to do to slow stepper down recently to very accurately find an edge. I moved the debug led code under the cmd==5 for calibrate and the script is definitely is not getting there and same is happening with Homing as the built in debug led is not turning on for V8 but I can see it is trying to transmit on V1 with the Tx light coming on. Since the servoSpeed( V8, 5) is working with EZScript is there a similar code for homing. I looked around on the cheatsheet and did not see anything.  On a side note tried to put speed script into the new Javascript block but the code is in EZScript so it doesn't go. An upgrade for future may be to add an EZScript block. I used the ControlCommand to get around this in my loop code in Blockly. Getting closer.

PRO
Synthiam
#70  

Your lesson isn’t done:) because you’re talking ezscript and trying to merge with Blockly which is JavaScript. So what you’re missing is the support section that has all the commands. Here’s the JavaScript command for setting speed: synthiam.com/Support/javascript-api/Servo/setSpeed

that being said, Blockly already has a speed block for servos. So you can just use that without typing the code.

#71  

Tried it and both of the items worked great. Looked up the setAsHome in Javascript and did not see any. What would the code be?

#73  

Yes but for some reason it is not receiving it in the Arduino as the debug led never turned on when I had it under cmd==0. Wonder why it is not accepting it.

PRO
Synthiam
#74  
  1. Is the Arduino connected to the PC via USB?

  2. are there multiple arduinos chained together?

  3. are you sending the SetAsHome command while it is calibrating? You cannot send a command while another command is executing. The arduino does not have a significant input buffer on the RX for UART. That means it might get lost if it's doing something and you send a command.

In the Arduino, the data arriving in the UART from USB sits in a small buffer until it is read by the code (Serial.ReadByte). I'm not sure about the size of the input buffer on an Arduino, but I know it's tiny. In fact, it might only be 1 or 2 bytes. So there's a chance the SetAtHome command is lost if you send it while it's doing something else, such as calibrating.

#75  

Yes the Arduino is connected to the PC via USB. For testing purposes have only 2 connected- a master and a slave. They work as expected going to positions. No I am not sending SetAsHome while calibrating. I am going to a position 10000 ariving then SetAsHome it mentions Done then checking it by putting position 1 and it moves 10000 steps which means int never Homed. I then ping both V1 and V8 individually and it returns 20230223 which is fine. I then put in position 10000, send script to calibrate, it mentions Done, then I send position 1 and it moves 10000 steps which means it never calibarated.  If I ping it and it works doesn't that mean the cmd variable is not overloaded or lost?

#76  

Quote:

Thanks for the responses. I'm using the Nano Every USB for programming and Serial1 for communicating with a motor driver. The software serial is used to write to a data logger. I'm not having a problem sending bytes to the motor driver, that works and it responds fine, but I am having trouble getting bytes back from the motor driver, so I was just wondering what the buffer size was as I explore different options for capturing the driver return bytes. The same procedure works fine on the Mega, but there I use Serial.event, which I'm told doesn't work on the Nano Every. Changing the core, or whatever, is far beyond by understanding or ability. So, at this point, I'm just curious as to what the Serial1, and software serial buffer sizes are.

Thanks, John-

Quote:

Please post your code and a link to the motor driver/data sheet. There should be no difference between using Serial.event and if(Serial.available()). If you can capture the driver return events with a second hardware serial port on a Mega, you should be able to do so on a Nano Every with Serial1. The default Rx buffer is the same 64 bytes on both. It would be unusual to overflow a 64 byte buffer before you can read it, but if indeed that is happening, you can increase to 128 or 256. Why do you think your communication issues are caused by buffer size and possible overflow?
I found the above on the Arduino Forum. Looks like the Arduino buffers are 64 bytes but can somehow be increased by changing the core? Here's the link: Arduino Forum link

PRO
Synthiam
#77  

From your description and the size of the buffer that Dave provided, I don't think it's exceeding the buffer. So, my last thought is void.

I can't understand how the CMD == 0 condition isn't being hit. I will have to load our setup later today and see if there's any way I can reproduce this - maybe it'll give me thoughts on how it can happen to you.

#78   — Edited

Yes it's very strange, have been poking around the code for possibilities. How can I buy your drinks tonight? It's all appreciated. Here are a few things that I saw which are probably off base but it may trigger a side thought. In the photo -if stepper current pos = the target position then void calibrate.Well current position already is where I told it to go (target position). In another area it states stepper1.setcurrentposition(0)  but you already said that was off base but it looks like you are setting it to 0.  Another possible clue is that it states that it is Done very quickly .02 seconds which means the code went somewhere and completed but did not give me proper results. Maybe something in here will help. User-inserted image

PRO
Synthiam
#79   — Edited

Oh geez, this is so simple. I just wasted 4 hours on this because I didn't notice your command vs the manual haha...

Here's the manual...

Quote:

ControlCommand("Stepper Servo", "Calibrate", "ID"); This ControlCommand() takes the virtual servo port as the ID parameter. It will instruct the Arduino with the ARC Stepper servo firmware to move the stepper until the End Limit Switch is triggered. This command requires an end-limit switch; otherwise, the stepper will rotate indefinitely. Refer to the Limit Switch section in this manual to read more about a limit switch and how to configure it.

ControlCommand("Stepper Servo", "SetAsHome", "ID"); The SetAsHome command will set the current position of the stepper as servo position 1. For example, if you move the servo into a position (i.e., 90) and then specify the SetAsHome control command, the current position will become the new servo position 1 for that virtual port. servo position 1 is as low as a servo can move, so when you send SetAsHome to the specified virtual port, it will now refer to the current position as 1.

The manual states the "ID," not the servo port. So you would pass an 8, not a V8. That being said, I think it makes more sense to use the servo port than the ID.

We have been using the ID in our tests because that's what the manual states. We didn't notice you have been using the servo port.

The robot skill should be changed to use the servo port to avoid future confusion. Until it is changed, use this...

ControlCommand("Stepper Servo", "SetAsHome", 8);
#81   — Edited

You the man!!  Thankyou very much!! Tried it and it worked like a charm.  If you can make a Go Fund My Bar Tab account I'll be happy to help fund it! (and I'm sure others will too). It may make a nice outing for your whole crew. Just put a little quiet icon in the corner somewhere and let us know where it is.

PRO
Synthiam
#82  

That's an interesting idea - I'm unsure how that would work for tax purposes. A long time ago, when I started my first company, ez-robot, we had a "donate" option. It was to let ppl donate towards the software development. Because hardware sales don't really support the commitment to software development of new features. However, I had to remove it because of some tax implications of being a for-profit corporation. I'd have to look into how the go-fund-me system works and such. But it would be a good idea if the funds were to go toward activities. Or even the ability for community members to purchase new features. Maybe that's a good direction to go. Allow people to fund new features.

#84  

Tried calibrating this week and have a slight hiccup. When you send the command for calibrate it does start rotating and it stops when pin 6 is grounded, that part is very good. The thing is that it rotates very slowly 1rev per 2 seconds. I have tried to change Calibration_Steps to many different values but it still rotates very slowly. I am using a 10-1 gearbox and about 20k steps per axis for high accuracy so I need it to move about 2500/sec for typical calibrating. Looked over the Javascript code but I don't see the problem. It's been defined but it seems to be defaulting back to about 100 steps/sec. If you try it you'll see the same thing. Didn't notice it before because it was on my experimental bench with no gearbox, it was moving-but slowly.