Problem about External Library Import Arduino in Embed

Hello community,
I'm programing a basic robot arm, and in my embed file i used 2 external library is AccelStepper and Servo. My file is attached in this post.
My problem is:
1. When i set 1 for Enable Excecution compound Manual, i can control 2 stepper motor with button but only few second.
2. I was setup angle for 2 servo using myservo[0].write($1) and myservo[1].write($2) and 2 servo no responden after i upload code. I tested run single servo with example file in Example -> Embedded -> Arduino -> External Library Import -> Servo-Mega and have the same problem.
3. In compound Auto, i get angle for motor with compound GetEmlementMatrix. But when i upload code seem like all motor don't responden.
Ps: When i test Auto or Manual mode, i set Enbale Excecution for compound to 1.
Answers
-
Hi Phan,
1. Try to Enable compound block as background Thread
Compoundblock->(righclick)Local Timestep ->codegen as background Thread
2. Servo motor can be controlled with PWM signal also.
a. Open attached diagram : ControllingSevowithPWMsig->Ex7_Servo_motor_control_triangular.vsm
3. Servo control using External library
a. Open attached diagram: ServoUsingExternalLibrary->Servo-Uno_0_180.vsm
You can enter the value and verify the servo position. If the servo is already in that angle, try with another value between 1 - 180
b. Open attached diagram : ServoUsingExternalLibrary->Servo-Uno_0_180_backGroundThread.vsm
It will be same as above, but the main task run in background thread instead of Timer.
Please verify 2 and 3, using single servo motor and let me know the status.
0 -
Hi Phan,
My colleague Sreejith has replied, but for some reason it is not showing. Here is his advice:
- Try to Enable compound block as background Thread and compile it
- Verify the servo motor using attached diagram
- Control the servo in 9th pin using direct PWM signal (ControllingSevowithPWMsig->Ex7_Servo_motor_control_triangular.vsm)
- Using External library and set a constant position. On the next cycle try with another value between 0-180
ServoUsingExternalLibrary->Servo-Uno_0_180.vsm
ServoUsingExternalLibrary->Servo-Uno_0_180_backGroundThread.vsm
0 -
Peter Darnell said:
Hi Phan,
My colleague Sreejith has replied, but for some reason it is not showing. Here is his advice:
- Try to Enable compound block as background Thread and compile it
- Verify the servo motor using attached diagram
- Control the servo in 9th pin using direct PWM signal (ControllingSevowithPWMsig->Ex7_Servo_motor_control_triangular.vsm)
- Using External library and set a constant position. On the next cycle try with another value between 0-180
ServoUsingExternalLibrary->Servo-Uno_0_180.vsm
ServoUsingExternalLibrary->Servo-Uno_0_180_backGroundThread.vsm
Thank you for your prompt reply.
I tried with 2 servo control file that you attach. It doesn't work for me. Servo still work with arduino code but i don't know why it doesn't work with External Library.
If i want control using PWM, how can i control angle with pulse?
Thank you!
0