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
Servo Motor Program
Moderator: Benj
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Servo Motor Program
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
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 578 times
Martin
Re: Servo Motor Program Modified?
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
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 617 times
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Servo Motor Program
Hi John,
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!
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
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
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.
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
Be careful here.JDR04 wrote:I have chosen the 16F1825 PIC as it is compatable with my PICKIT2 programmer
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!
No not at all!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??
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
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;
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.
That should be straight forward.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.
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
Re: Servo Motor Program
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
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
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Servo Motor Program
Hi John,
You just right click on the servo/stepper that's on the panel and choose connections.
No, you can connect servo or stepper to any pin that is not input only.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?
You just right click on the servo/stepper that's on the panel and choose connections.
Martin