Servo motor

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
Lariekoek
Posts: 23
Joined: Sun Jun 10, 2018 1:24 pm
Contact:

Servo motor

Post 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!

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 motor

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

Lariekoek
Posts: 23
Joined: Sun Jun 10, 2018 1:24 pm
Contact:

Re: Servo motor

Post by Lariekoek »

Great, thanks!
I can't see any updates when checking. When will the update be available?

Lariekoek
Posts: 23
Joined: Sun Jun 10, 2018 1:24 pm
Contact:

Re: Servo motor

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

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

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

Lariekoek
Posts: 23
Joined: Sun Jun 10, 2018 1:24 pm
Contact:

Re: Servo motor

Post 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!!! :)

chipfryer27
Valued Contributor
Valued Contributor
Posts: 617
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: Servo motor

Post 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

Lariekoek
Posts: 23
Joined: Sun Jun 10, 2018 1:24 pm
Contact:

Re: Servo motor

Post 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

Lariekoek
Posts: 23
Joined: Sun Jun 10, 2018 1:24 pm
Contact:

Re: Servo motor

Post 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??

Lariekoek
Posts: 23
Joined: Sun Jun 10, 2018 1:24 pm
Contact:

Re: Servo motor

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

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 motor

Post by Benj »

Hello,

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

Post Reply