Servo Programming

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
KarlYoung
Posts: 2
Joined: Wed Jun 06, 2018 8:14 pm
Contact:

Servo Programming

Post by KarlYoung »

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.

medelec35
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

Post by medelec35 »

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.
Martin

KarlYoung
Posts: 2
Joined: Wed Jun 06, 2018 8:14 pm
Contact:

Re: Servo Programming

Post by KarlYoung »

Here is the program:
ARM.fcfx
(9.97 KiB) Downloaded 215 times

User avatar
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

Post by Benj »

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.
ARM.fcfx
(12.17 KiB) Downloaded 207 times
Let us know how you get on.

Post Reply