Asked

Can you please write the code in Blockly for me for a stepper motor Movement Panel using V21 and V22? I will be inserting it into Auto Position movement panel.
Related Hardware EZ-B v4
Related Control
Stepper Servo
You're welcome! I'm glad I could help. If you have any more questions or need further assistance as you work on your project, feel free to reach out. Good luck with your robot, and have fun building and programming!
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.

@Athena Following along in same previous conversation I have inserted the script in these phots into Forward, Reverse, Stop. I am having a problem stopping the Virtual servo V21 and V22 when in Stop Mose in the movement panel. It also currently only goes in reverse all the way down to zero when in Forward or Reverse. I have also tried to put in $JoystickY1 where $Speed is located in the script but V21 does not move. Which variable am I supposed to use $JoystickY1 or $Speed ? Is there a multiplier in the script where it is supposed to take the value of $JoystickY1 to turn it into pulses? I would like to have the output pulses to be about 500 pulses per second how do I write the code to do that.To control the virtual servos V21 and V22 with variable speed based on joystick input and ensure proper stopping, you need to use the correct variable that represents the joystick's Y-axis value. In ARC, joystick values are typically stored in global variables like
$JoystickY1
, which you can use to determine the speed and direction of the stepper motor.The
$JoystickY1
variable will range from -1 (full down) to 1 (full up), with 0 being the center position. You'll need to map this range to your stepper motor's speed range and convert it into pulses.Here's an updated JavaScript code snippet for ARC that includes mapping the joystick value to a pulse rate and ensuring the stepper motor stops correctly:
In this code, the
map
function is used to convert the joystick value to a speed range suitable for your stepper motor. ThepulseStepper
function is then called with this speed to move the stepper motor.The
stop
function sets both control pins to low to ensure the stepper motor stops moving.Regarding the pulse rate, the
pulseRate
variable is calculated by multiplying the absolute speed value by a factor that determines how many pulses per second you want to achieve. Adjust the multiplier to match your stepper motor's capabilities and the desired pulse rate.Please note that the
sleep
duration in thepulseStepper
function may need to be adjusted to achieve the correct pulse rate for your stepper motor. The current setup withsleep(1)
is a placeholder and may not provide the exact timing you need.Make sure to test this code and adjust the parameters to match the behavior of your stepper motor and driver. If your stepper motor driver has specific requirements for pulse width or timing, you'll need to modify the
sleep
duration 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.
@Athena continuing on this previous conversation, this is very helpful information but could you refer to the StepperServo skill and revise your answer // Stop movement function function stop() { // Stop pulsing the stepper motor by not calling the pulseStepper function digital.set(D21, false); digital.set(D22, false); because it is sending the information to the Arduino for pin 2 and pin 3 for pulse and direction.
Certainly! If you're using the StepperServo skill and need to control the stepper motor using virtual ports V21 and V22, you'll want to send commands to the Arduino that is managing the stepper motor. The Arduino will interpret these commands to control the pulse and direction pins.
Here's a revised version of the JavaScript code snippet for ARC that sends the appropriate commands to the Arduino through the StepperServo skill:
In this code, the
controlStepper
function sends a command to the StepperServo skill with the desired speed. Theforward
andreverse
functions map the joystick value to a speed range and callcontrolStepper
with the appropriate speed. Thestop
function sends a 'Stop' command to the StepperServo skill to halt the stepper motor.Please ensure that the
ControlCommand
syntax matches the actual commands accepted by the StepperServo skill. Thecommand
variable should be set to the correct command names that the StepperServo skill expects for forward, reverse, and stop actions.The
map
function is used to convert the joystick value to a speed range suitable for your stepper motor. Adjust themap
function parameters to match the speed range that your stepper motor and Arduino code can handle.Remember to replace 'Stepper Servo' with the actual name of your StepperServo skill in the project if it's different. The
absoluteSpeed
variable should be calculated based on how your Arduino code interprets speed values. Adjust the mapping range accordingly to ensure the stepper motor operates within its capabilities.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.
The question doesn’t make any sense so she can’t help you. It’s an impossible question. Such as, can you make an engine into a car so I can use it in a car?
To make a movement panel, you need to make a robot skill. The manual to do so is in the support section and does not use JavaScript. JavaScript is not a complied programming language for making software - it’s a scripting language.
you cannot make a Movement Panel that works in a movement panel. Those two things are the same thing and even I don’t understand for question
ill probably be best to answer this by saying a stepper motor robot skill CANNOT be used in a Movement Panel because it works as a servo. A servo has a finite range of movement - which is why you’re experiencing what you’re experiencing - that's by design.
your best option is to connect a stepper driver to an ezb digital port. Then, write a loop in a custom Movement Panel v2 to move the steppers for each direction. This has been discussed many times in previous duplicate questions that you’ve asked. I think you’re stuck assuming a different response or maybe you’re not fully sure what the question is hehe cause I’ve been there before.
but the answer is so what Athena had said in the last twenty times youve posted about this AND she’s even gave you code for it the past to control a stepper directly from an ezb in a custom Movement Panel v2.
please read what a Movement Panel is before continuing. Click on the word Movement Panel from anywhere you see it highlighted.
This is the first time that I have seen this statement ill probably be best to answer this by saying a stepper motor robot skill CANNOT be used in a Movement Panel because it works as a servo. A servo has a finite range of movement - which is why you’re experiencing what you’re experiencing - that's by design. Now that I know that it won't work like this and since I have been poking around asking question and found the proper variables to work with I think can now write the loop that you are talking about. Sometimes I ask similar questions on purpose so that I can find hidden answers in her answers. Bear with me it's a process.
As soon as I heard "you cannot make a Movement Panel that works in a movement panel." it clicked. I figured it out and now I have the Movement Panel working great.