Page 1 of 1

Servo motor

Posted: Wed Apr 17, 2019 8:25 pm
by Lariekoek
Hello,
I'm using the PIC16f18325, but I think there is something wrong with the "servo controller" component.
As soon as I try to compilea program using the component, I get following error log.

Code: Select all

Test 16f18325 enkel servo.c: FCD_0dd21_Servo_Controller1__Initialise()
  1127:	PIE1bits.CCP1IE = 1;
	                ^ (255) not a member of the struct/union ""
	                   ^ (182) illegal conversion between types
int -> volatile union S84
  1130:	PIE2bits.CCP2IE = 1;
	                ^ (255) not a member of the struct/union ""
	                   ^ (182) illegal conversion between types
int -> volatile union S86
Test 16f18325 enkel servo.c: myisr()
  1264:	if ((PIR1bits.CCP1IF) && (PIE1bits.CCP1IE))
	                    ^ (255) not a member of the struct/union ""
	                                         ^ (255) not a member of the struct/union ""
	              (199) logical type required ^
	              (199) logical type required ^
  1457:	PIR1bits.CCP1IF = 0;
	                ^ (255) not a member of the struct/union ""
	                   ^ (182) illegal conversion between types
int -> volatile union S33
  1463:	if ((PIR2bits.CCP2IF) && (PIE2bits.CCP2IE))
	                    ^ (255) not a member of the struct/union ""
	                                         ^ (255) not a member of the struct/union ""
	              (199) logical type required ^
	              (199) logical type required ^
  1634:	PIR2bits.CCP2IF = 0;
	                ^ (255) not a member of the struct/union ""
	                   ^ (182) illegal conversion between types
int -> volatile union S35
(908) exit status = 1
(908) exit status = 1

Error returned from [xc8.exe]

C:\Program Files (x86)\Flowcode\Common\Compilers\pic\batch\pic_xc8_comp.bat reported error code 1



FINISHED
Am I doing something wrong, or is it a bug in FC8?
Thanks!

Re: Servo motor

Posted: Thu Apr 18, 2019 12:17 pm
by Benj
Hello,

Many thanks for letting us know.

I believe I have now found and fixed the problem and pushed the updated components to the v8 update system.

Let us know how you get on.

Re: Servo motor

Posted: Fri Apr 19, 2019 1:54 am
by Lariekoek
Great, thanks!
I can't see any updates when checking. When will the update be available?

Re: Servo motor

Posted: Mon Apr 22, 2019 1:33 pm
by Lariekoek
My current version is V8.0.0.6, there are no updates available in the "check for updates" window.
So I don't know if I have your fix already, but the problem is still there.

Re: Servo motor

Posted: Mon Apr 22, 2019 2:33 pm
by medelec35
Hi.
Version 8.0 does not allow updates.
You must update to 8.1.1.11,
updates will then work.
Have a look at this post.

Re: Servo motor

Posted: Wed Apr 24, 2019 6:07 pm
by Lariekoek
Thanks, I was not aware of that!

The program seems to be compiling and working now, but the servo is not responding correctly.
When I measure the PWM signal going to the servo motor, I see the period is +- 16 ms instead of the usual 20 ms.
Image

I think there is something off with the timing (clock?) of the 16f18325 microcontroller. I noticed this before and couldn't get it right, but managed to work around it. But using the servo component, it seems it needs to be right.
Maybe some setting I did wrong?

I'm using the internal 32MHz oscillator. I'm aware this isn't the most accurate clock source, but it should do the job.
I set the "Clock speed" to 32.000.000Hz in the "General Options". (If I understand correctly, this is the value FC uses to calculate Delays?)
Here is a screenshot of my "Configure" tab, did I set something wrong?

Image

Image

Help would be greatly appreciated!!! :)

Re: Servo motor

Posted: Wed Apr 24, 2019 11:13 pm
by chipfryer27
Hi

This post may help if you haven't included a C-code box to set registers already.

viewtopic.php?f=76&t=20546&p=91158&hili ... tor#p91158

Regards

Re: Servo motor

Posted: Sat Apr 27, 2019 4:27 pm
by Lariekoek
Included following code to make sure the HFINTOSC clock source is selected, but this made no difference.

Code: Select all

OSCCON1bits.NOSC = 0b000;
OSCCON1bits.NDIV = 0b0000;
I noticed the Servo Component Macro "SetPosition" is working fine, even tho the period of the PWM signal is also +-16ms.
It is the "AutoMoveToPosition" that seems to have problems. When I look at the PWM signal, I see that when the pulse duration is shortening, suddenly the output just goes HIGH and that's why the servo starts doing weird things. After this happens, the PWM output stays high, even if I give the command to go to an other position. Bug in this component macro?

Image

Re: Servo motor

Posted: Sat Apr 27, 2019 5:56 pm
by Lariekoek
EDIT
Ok, it seems that you can only enter position values in the "AutoMoveToPosition" macro that are multiples of the "SetAutoMoveSpeed" value.

So:
SetAutoMoveSpeed = 1 => AutoMoveToPosition range 0-255
SetAutoMoveSpeed = 2 => AutoMoveToPosition working values 0 - 2 - 4 - 6 - ...
SetAutoMoveSpeed = 3 => AutoMoveToPosition working values 0 - 3 - 6 - ...

With other values than those that are multiples of the autospeed, the output goed HIGH after a few seconds and doesn't respond to new position-commando's. Is it supposed to work like this??

Re: Servo motor

Posted: Mon May 06, 2019 10:29 pm
by Lariekoek
Still having this problem.. Anybody had the time to look into it?
As far as I can see it's a bug in the flowcode component.

Re: Servo motor

Posted: Tue May 07, 2019 11:35 am
by Benj
Hello,

Please can you attach your program so I can try and replicate here.