Servo Motor Program

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Servo Motor Program

Post by JDR04 »

I'm hoping you guys can put me right with this program.

All I am trying to achieve is to move the servo in one direction and back again with each button press.

I just cant get it to work and am also wondering why the chip diagram is not showing me (in red on the pin concerned) when the pin is high. I think I have done the chip configuration right??

Would appreciate it if somebody could show me where I have gone wrong.......Many Thanks John
Attachments
Servo Program 1.fcf
(13.5 KiB) Downloaded 557 times

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 Motor Program

Post by medelec35 »

Hi John,
First of all you can only use servo component on devices that have two CCP channels.
12F683 is not such target device.
When you go to compile to hex or target device, Flowcode will throw some errors.
I have updated your Flowchart so it just requires you to select a new target device.

Martin
Attachments
Servo Program 2.fcf
(14.5 KiB) Downloaded 567 times
Martin

JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Servo Motor Program

Post by JDR04 »

Thanks Martin, really appreciate that. I see I was a long way off!!Will work on it Sunday. Thanks again...John

JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Servo Motor Program Modified?

Post by JDR04 »

Thanks Martin, I've gone through your program and have tried to do a modified one myself but cannot get it to work. Hopefully you or somebody else can point out where I have gone wrong.

I have chosen the 16F1825 PIC as it is compatable with my PICKIT2 programmer and has the CCP pins as you advised earlier. Am I correct in saying that this PIC will have to run off a external clock as it does not have a internal clock setting??

On the modified program I'm trying to get the servo to "sweep" in one movement fowards, and then backwards also in one movement.

Hope you can help and thanks again..............John
Attachments
Servo-Sweep.fcf
(6.5 KiB) Downloaded 602 times

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 Motor Program

Post by medelec35 »

Hi John,
JDR04 wrote:I have chosen the 16F1825 PIC as it is compatable with my PICKIT2 programmer
Be careful here.
PICkit 2 was never intended to work with 16F18xx series.
What I posted is just a work around, and you have probably read that I use a 10K resistor in series with VPP of programmer and VPP of target device.
Without current limiting resistor PICkit2 WILL damage 16F18xx & 12F18xx devices!
JDR04 wrote:Am I correct in saying that this PIC will have to run off a external clock as it does not have a internal clock setting??
No not at all!
16F18xx devices have a good range of internal oscillator settings:
32 MHz (requires 4X PLL)
16 MHz
8 MHz
4 MHz
2 MHz
1 MHz
500 kHz (Default after Reset)
250 kHz
125 kHz
62.5 kHz
31.25 kHz
31 kHz (LFINTOSC)
To set the internal osc frequency you will have to change configuration setting to

Code: Select all

INTOSC oscillator I/O function on CLKIN pin
The clock sped has to set the same as internal osc value.
He target device internal osc speed wont be correct until a C code block is added at the start with

Code: Select all

osccon=0xzz;
Where zz is the value that's derived from the 16F1825 datasheet page 71,
I have posted about that here
For the rest of the configuration settings take a look here
Before trying the servo out, make sure you complete a flash test described at the start of the last link.
JDR04 wrote:On the modified program I'm trying to get the servo to "sweep" in one movement fowards, and then backwards also in one movement.
That should be straight forward.
If you don't want servo to setp but to sweep straight to a postion then you use Servo SetPosition component macro instead of MoveToPosition,

If you get stuck I can help you further.

Martin
Martin

JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Servo Motor Program

Post by JDR04 »

Thanks for that Martin. To avoid further complications,I've decided to change the chip to a 16F877A. I believe thay are compatible with my PICKIT2 programmer and the Low Pin Count board I have.

I meant to ask you two things;

When doing the circuit, does the control wire of the servo have to connect to one of the CCP pins?
Is this the same for stepper motors?

Thanks a lot guys.....John

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 Motor Program

Post by medelec35 »

Hi John,
JDR04 wrote:When doing the circuit, does the control wire of the servo have to connect to one of the CCP pins?Is this the same for stepper motors?
No, you can connect servo or stepper to any pin that is not input only.
You just right click on the servo/stepper that's on the panel and choose connections.
Martin

Post Reply