Hello,
I am writing here as extension for a previous topic : http://www.matrixmultimedia.com/mmforum ... 1&start=25 (MX027 - Controlling a Servomotor with timer0 interrupt)
I am attaching the fcf file that I download to 18F455o that does not work. I have set the expert configuration screen as indicated on the forum.\I even try simple routines as print number 200 on LCD and still does not work!
I know everythng else works because I run other programm with other PICs and work fine!\Could it be flowcode it self, win7 or something else?
I tried 3 different 18F4550.
In respect of the attached file-that was provided by Medelec-Martin( Thanks!) should I have the oscillator switch on XTAL or on RC? Where should I have the oscillator speed set on the > project options> oscillator> at 48Mhz or 19.6? By the way I have also a 20Mhz oscillator. Should I use that?
Regards,
Andreas Achilleos
18F4550 not working with servo/or other
Moderator: Benj
- achillis1
- Posts: 347
- Joined: Thu Oct 09, 2008 9:19 am
- Has thanked: 91 times
- Been thanked: 8 times
- Contact:
18F4550 not working with servo/or other
- Attachments
-
- Servo Controller Kepad V1 FC4 18F4550.fcf
- (19.72 KiB) Downloaded 247 times
-
- 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: 18F4550 not working with servo/or other
Hi Andreas,
Try this version,
I was in a bit of a rush so not properly check flowchart.
But I have founf that you have enabled pll, but not set osc to 48MHz
Martin
Try this version,
I was in a bit of a rush so not properly check flowchart.
But I have founf that you have enabled pll, but not set osc to 48MHz
Martin
- Attachments
-
- Servo Controller Kepad V1 FC4 18F4550 Modified.fcf
- (19.72 KiB) Downloaded 263 times
Martin
- JohnCrow
- Valued Contributor
- Posts: 1367
- Joined: Wed Sep 19, 2007 1:21 pm
- Location: Lincolnshire
- Has thanked: 364 times
- Been thanked: 716 times
- Contact:
Re: 18F4550 not working with servo/or other
Try this one
Ive set the advanced settings to the ones I use
20Mhz xtal, flowcode project options clockspeed set to 48 MHz
Ive set the advanced settings to the ones I use
20Mhz xtal, flowcode project options clockspeed set to 48 MHz
1 in 10 people understand binary, the other one doesn't !
- achillis1
- Posts: 347
- Joined: Thu Oct 09, 2008 9:19 am
- Has thanked: 91 times
- Been thanked: 8 times
- Contact:
Re: 18F4550 not working with servo/or other
Hello
Thanks for the replies.
John your routine didn't work!
Martin, your's did!
Although seems to be working a little bit slow but maybe it is because of the interrupts?
Also, (haven't looked at the routine yet) but zero degrees are not actually at zero and 180 degrees are somewhere about to 90 degrees!
My question is that with the specific fcf, the PIC uses the external crystal or the internal?
If it is the external then why don't I have to set the clock speed in project options to 20Mhz but instead leave it at 48Mhz?
I know that it is set at expert configuration window but what about the project options?
Thank you
Andreas Achilleos
Thanks for the replies.
John your routine didn't work!
Martin, your's did!
Although seems to be working a little bit slow but maybe it is because of the interrupts?
Also, (haven't looked at the routine yet) but zero degrees are not actually at zero and 180 degrees are somewhere about to 90 degrees!
My question is that with the specific fcf, the PIC uses the external crystal or the internal?
If it is the external then why don't I have to set the clock speed in project options to 20Mhz but instead leave it at 48Mhz?
I know that it is set at expert configuration window but what about the project options?
Thank you
Andreas Achilleos
- JohnCrow
- Valued Contributor
- Posts: 1367
- Joined: Wed Sep 19, 2007 1:21 pm
- Location: Lincolnshire
- Has thanked: 364 times
- Been thanked: 716 times
- Contact:
Re: 18F4550 not working with servo/or other
Ok
I'd not tried it on hardware, I'll have to compare it with Martins see what the difference is.
Anyway glad you got it sorted
I'd not tried it on hardware, I'll have to compare it with Martins see what the difference is.
Anyway glad you got it sorted
1 in 10 people understand binary, the other one doesn't !
-
- 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: 18F4550 not working with servo/or other
The target device uses PLL (Phase Lock Loop) who's job is to multiply the oscillator frequency to 48MHz. It is this 48MHz the program counter, timers ect will be running from.achillis1 wrote: My question is that with the specific fcf, the PIC uses the external crystal or the internal?
If it is the external then why don't I have to set the clock speed in project options to 20Mhz but instead leave it at 48Mhz?
I know that it is set at expert configuration window but what about the project options?
Thank you
Andreas Achilleos
Hence in project options the target frequency is set to 48MHz.
With in the advance configuration screen the Osc select must show the speed of xtal you are using for instance if using 19.66MHz, then select 20MHZ as thats near enough.
I believe that 18F4550 only uses external oscillator for driving PLL. Only frequencies of up to 8MHz can only be achieved using internal osc.
As for running slow, My guess is timer0 has not been adjusted to reflect the new osc speed of 48MHz. So I agree with you, its the interrupt. I will look at getting the Flowchart working at the higher resolution when I get a chance.
Martin
Martin
-
- 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: 18F4550 not working with servo/or other
Hi Andreas,achillis1 wrote: Although seems to be working a little bit slow but maybe it is because of the interrupts?
Also, (haven't looked at the routine yet) but zero degrees are not actually at zero and 180 degrees are somewhere about to 90 degrees!
I have hooked up hardware to a scope, downloaded Servo Controller Kepad V1 FC4 18F4550-tweeked.fcf for example, changed target to 18F4455 and Enabled PLL. Sent to target. The pulse duration is spot on. 0 deg = 1.0ms on the scope
and
180 deg = 2.0 ms. So could it be an issue with your hardware?
Does the specification of servo show the pulse duration limits?
Also I have removed timer0 and used servo component for your Servo Controller Kepad V1. I have tested it with 18F4455 and servo pulses appear to be fine.
So If your servo works with timer0, in theory it should work with servo component?
I have altered configuration for 18F4550 (not using PLL so is running at 19.66MHz), but since I have not got a 4550 to test on, I can't say for sure configuration is 100% correct.
Try attached flowchart on your servo, and would you mind letting us know how is goes please.
Martin
Edit, I did notice with test servo component.fcf you posted, there is no error trapping so a value greater than 180 can be sent to servo component which could force the servo against it's stop (e.g scope measured 2.80 ms pulses). Could that be the reason for the excess current drawn your experiencing?
- Attachments
-
- Servo Controller Kepad V1 FC4 18F4550 servo comp.fcf
- (18.15 KiB) Downloaded 287 times
Martin