Hello,
I’m creating a project using servo motors, and have created code that works within the simulation of Flowcode. However when I compile to chip and operate the program, the servo doesn’t quite do as suspected.
On my program I am using a simple potentiometer and returning the byte value to set the position of the servo. On the simulation the servo turns a full 180degrees as it should with byte value from 0-255. But on the real life servo it only turns around 90degrees.
I am using a pic161937 and controlling a servo capable of a full 180degrees rotation.
I hope somebody could please help me out, and tell me what’s wrong.
Servo Programming
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Servo Programming
Hi KarlYoung,
Welcome to the Matrixtsl forums.
It would help us to help you if you posted a flowchart.
When you reply, to add attachments just select attachments tab.
Select Add files, then browse to either .fcf or .fcfx depending on Flowcode version you have.
Welcome to the Matrixtsl forums.
It would help us to help you if you posted a flowchart.
When you reply, to add attachments just select attachments tab.
Select Add files, then browse to either .fcf or .fcfx depending on Flowcode version you have.
Martin
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Servo Programming
Hello,
The first thing I noticed is you have two servo controller components, these use dedicated hardware so you can only currently have one of these. I've changed your program so that both motors are now controlled via a single controller component.
I've also added while loops in between the AutoMoveToPosition macros to ensure we wait until the servo has correctly moved to position.
Finally your movements were 255 (180 degrees) and 128 (90 degrees) so this explains why you are only getting 90 degrees of movement. I've now changed this to 255 and 0.
Let us know how you get on.
The first thing I noticed is you have two servo controller components, these use dedicated hardware so you can only currently have one of these. I've changed your program so that both motors are now controlled via a single controller component.
I've also added while loops in between the AutoMoveToPosition macros to ensure we wait until the servo has correctly moved to position.
Finally your movements were 255 (180 degrees) and 128 (90 degrees) so this explains why you are only getting 90 degrees of movement. I've now changed this to 255 and 0.
Let us know how you get on.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel