Servo Component not working
Moderator: Benj
-
- Posts: 14
- Joined: Wed Feb 26, 2020 9:49 am
- Has thanked: 2 times
- Been thanked: 1 time
- Contact:
Servo Component not working
Please help,
I am trying to use the "Servo component", it simulates perfectly but when tried on a chip the waveform is fixed at the lowest setting of the servo timing i.e., "pulse width, min (us) 1000"
I have tried multiple PIC micro's, two programmers, stripped down the code to the minimum to operate a servo at a fixed point (midpoint 1.5ms)
I have tried 8 and 16 bit families, the only thing I found was that the servo component only seems to work at all with higher end micros.
Also, I found higher clock setting caused problems also, so most of my tests are done at 1MHz
Outputs observed on an Oscilloscope are
Osc 2 out = 250Khz (int clock/4), RC5 (program cycle) = on 690ms / off 690ms
RA1(PWM out) = on 1.010ms / off = 16.00ms
I have attached the simplest program I wrote and tried.
At the moment I am using a PIC16F18426, MPLAB X IPE v5.20, PICkit4
I feel I must be missing something common, please can you help?
I am trying to use the "Servo component", it simulates perfectly but when tried on a chip the waveform is fixed at the lowest setting of the servo timing i.e., "pulse width, min (us) 1000"
I have tried multiple PIC micro's, two programmers, stripped down the code to the minimum to operate a servo at a fixed point (midpoint 1.5ms)
I have tried 8 and 16 bit families, the only thing I found was that the servo component only seems to work at all with higher end micros.
Also, I found higher clock setting caused problems also, so most of my tests are done at 1MHz
Outputs observed on an Oscilloscope are
Osc 2 out = 250Khz (int clock/4), RC5 (program cycle) = on 690ms / off 690ms
RA1(PWM out) = on 1.010ms / off = 16.00ms
I have attached the simplest program I wrote and tried.
At the moment I am using a PIC16F18426, MPLAB X IPE v5.20, PICkit4
I feel I must be missing something common, please can you help?
- Attachments
-
- servo_test.fcfx
- (15.69 KiB) Downloaded 86 times
- 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 Component not working
Hello Rob,
The servo component is driven using two output compare peripherals and a timer. Usually this means a device with at least 2 OC based PWM channels.
An oscillator speed of 1MHz is pretty slow. On the device you selected you should be able to use the max speed of 32MHz. Just make sure the clock speed setting matches the configuration setting.
I've adjusted some of the project options in the attached which should hopefully help.
One thing to check would be that you are running the latest version of v8 which is 8.2 and also check that you have all the latest component updates by clicking help -> check for updates and doing a full database update.
If this doesn't get you any further then try SetPosition and see if this is working as expected. It could be there is a bug lurking in the AutoMove and IsMoving functions though we do use these quite regularily so I would hope not. I'll double check at this end that there isn't something specific to this PIC device that would cause say the timer not to run but as you are getting the min pulse width output this seems unlikely.
The servo component is driven using two output compare peripherals and a timer. Usually this means a device with at least 2 OC based PWM channels.
An oscillator speed of 1MHz is pretty slow. On the device you selected you should be able to use the max speed of 32MHz. Just make sure the clock speed setting matches the configuration setting.
I've adjusted some of the project options in the attached which should hopefully help.
One thing to check would be that you are running the latest version of v8 which is 8.2 and also check that you have all the latest component updates by clicking help -> check for updates and doing a full database update.
If this doesn't get you any further then try SetPosition and see if this is working as expected. It could be there is a bug lurking in the AutoMove and IsMoving functions though we do use these quite regularily so I would hope not. I'll double check at this end that there isn't something specific to this PIC device that would cause say the timer not to run but as you are getting the min pulse width output this seems unlikely.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 14
- Joined: Wed Feb 26, 2020 9:49 am
- Has thanked: 2 times
- Been thanked: 1 time
- Contact:
Re: Servo Component not working
Benj,
Thank you for taking the time to get back to me, however I am still having trouble, Sorry for the delay, I have since tried the following options, all at 32Mhz
16F18426 - compiles, hex code fails to load(program) to chip
16F1454 - does not compile - huge list of errors
24F16KA101 - compiles, loads to chip, runs with fixed output, i.e. not working correctly
I experimanted with the 24F chip, I ran the attached program and I got a repeating pwm signal @ 20msec but it is length is 1ms or less and it changes while watching +/- 100us, adc channel set to 2v
Oh I am using
Flowcode v8.2.2.15 I update this everytime I use the program, habit
Professional version
As you will see I tried the "setposition" macro, as you said to try
as always, the program simulates perfectly.
If you have a known code that works with a known chip, I will gladly buy a new chip and try that combo
I look forward to your reply
Thank you for taking the time to get back to me, however I am still having trouble, Sorry for the delay, I have since tried the following options, all at 32Mhz
16F18426 - compiles, hex code fails to load(program) to chip
16F1454 - does not compile - huge list of errors
24F16KA101 - compiles, loads to chip, runs with fixed output, i.e. not working correctly
I experimanted with the 24F chip, I ran the attached program and I got a repeating pwm signal @ 20msec but it is length is 1ms or less and it changes while watching +/- 100us, adc channel set to 2v
Oh I am using
Flowcode v8.2.2.15 I update this everytime I use the program, habit
Professional version
As you will see I tried the "setposition" macro, as you said to try
as always, the program simulates perfectly.
If you have a known code that works with a known chip, I will gladly buy a new chip and try that combo
I look forward to your reply
- Attachments
-
- servo_test_3_24F16KA101.fcfx
- (18.19 KiB) Downloaded 87 times
- 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 Component not working
Hi Rob,
Ok let's try and narrow down the area we are looking.
With the 16F18426 failing to load the program to the chip. What programmer are you using? What error messages are you getting?
With the 16F1454 while it does have 2 PWM channels, they are not the standard Output Compare (OC) PWM channels and don't have the associated interrupts that we can tap into to drive the servo timings. So supporting this chip isn't currently going to be possible.
With the 24F16KA101 the Clock speed and OSCCON register setting was not right and the Watchdog was enabled. I've modified the program a bit in terms of config settings and also added a 1-second flasher debug output so you can confirm if the device is running at the correct rate.
Ok let's try and narrow down the area we are looking.
With the 16F18426 failing to load the program to the chip. What programmer are you using? What error messages are you getting?
With the 16F1454 while it does have 2 PWM channels, they are not the standard Output Compare (OC) PWM channels and don't have the associated interrupts that we can tap into to drive the servo timings. So supporting this chip isn't currently going to be possible.
With the 24F16KA101 the Clock speed and OSCCON register setting was not right and the Watchdog was enabled. I've modified the program a bit in terms of config settings and also added a 1-second flasher debug output so you can confirm if the device is running at the correct rate.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 14
- Joined: Wed Feb 26, 2020 9:49 am
- Has thanked: 2 times
- Been thanked: 1 time
- Contact:
Re: Servo Component not working
Benj,
Thank you for the quick reply, I tried to compile the program, I didn't change in any way and it returned errors
I have attached a screen grab.
As for the others, will gladly work through them later,
However I have to go and do some mill work on prototypes, so I'll be in the workshop most of the remaining day.
Will look at PC asap, thank you again
Thank you for the quick reply, I tried to compile the program, I didn't change in any way and it returned errors
I have attached a screen grab.
As for the others, will gladly work through them later,
However I have to go and do some mill work on prototypes, so I'll be in the workshop most of the remaining day.
Will look at PC asap, thank you again
- Attachments
-
- Screenshot 2021-09-21 110843.png (87.21 KiB) Viewed 2758 times
-
- Posts: 14
- Joined: Wed Feb 26, 2020 9:49 am
- Has thanked: 2 times
- Been thanked: 1 time
- Contact:
Re: Servo Component not working
Benj,
Had a look and realised the Interupt used tm3 as well as the servo component, so I changed it to use tm1 and the code compliled and ran, however I still had the problem of incorrect timing of the servo pwm signal
Had a look and realised the Interupt used tm3 as well as the servo component, so I changed it to use tm1 and the code compliled and ran, however I still had the problem of incorrect timing of the servo pwm signal
- Attachments
-
- servo_test_4_24F16KA101.fcfx
- (19.99 KiB) Downloaded 86 times
- 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 Component not working
Hi Rob,
Did you look at the output pin A0 with a LED, is it blinking on and off at the right rate?
Did you look at the output pin A0 with a LED, is it blinking on and off at the right rate?
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 14
- Joined: Wed Feb 26, 2020 9:49 am
- Has thanked: 2 times
- Been thanked: 1 time
- Contact:
Re: Servo Component not working
Benj,
Am sorry for dealy, was given other work to finish,
anyway, something went wrong with my programming (PICkit4), it started coming up with this error code, which I have never seen,
We have detected some residual VDD voltage at the connector interface.
Connection Failed.
Blank Check Failed
So after some trial and error I fitted a 100R between pins 20(Vdd) & 19(Vss), this seemed to cure it.
The chip gave some signals but not consistant, I looked and tried some bits and found that for some reason, you can't set the MCLR pin to internaL reset? as it causes an error, so I ran with 4k7 pull up and 0.1uF to gnd causing a reset at start up (old style )
I now have a working PWM signal , timings are now
1 sec on/1 sec off pin2
PWM 1msec to 1.96msec, coresponding the the pot (voltage) on pin3
PWM repitition rate is 15.8msec
So now I have a working example at last , however I now need to use the auto move function, which I will do in stages, as and when I reach problems, I will post accodingly
Thank you for your helk and patiences with all this
regards Rob
PS it seems the "INTERNAL OSCILATOR HELPER" does not work on these chips, is this somethingh that can be fixed?
Am sorry for dealy, was given other work to finish,
anyway, something went wrong with my programming (PICkit4), it started coming up with this error code, which I have never seen,
We have detected some residual VDD voltage at the connector interface.
Connection Failed.
Blank Check Failed
So after some trial and error I fitted a 100R between pins 20(Vdd) & 19(Vss), this seemed to cure it.
The chip gave some signals but not consistant, I looked and tried some bits and found that for some reason, you can't set the MCLR pin to internaL reset? as it causes an error, so I ran with 4k7 pull up and 0.1uF to gnd causing a reset at start up (old style )
I now have a working PWM signal , timings are now
1 sec on/1 sec off pin2
PWM 1msec to 1.96msec, coresponding the the pot (voltage) on pin3
PWM repitition rate is 15.8msec
So now I have a working example at last , however I now need to use the auto move function, which I will do in stages, as and when I reach problems, I will post accodingly
Thank you for your helk and patiences with all this
regards Rob
PS it seems the "INTERNAL OSCILATOR HELPER" does not work on these chips, is this somethingh that can be fixed?
- Attachments
-
- servo_test_4_24F16KA101.fcfx
- (19.99 KiB) Downloaded 94 times
- 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 Component not working
Thanks Rob,
Glad you're having some progress.
The 24F16KA101 device only has one internal RC speed of 8MHz but I think it's also got a PLL that's configurable to give you different speeds, Adding PLL stuff into the Int Osc Helper would certainly be very nice so I'll see if it's something we can add.
It might also be nice if the IntOsc helper had a function to set the speed rather then you manually having to use the generated C code.
Glad you're having some progress.
The 24F16KA101 device only has one internal RC speed of 8MHz but I think it's also got a PLL that's configurable to give you different speeds, Adding PLL stuff into the Int Osc Helper would certainly be very nice so I'll see if it's something we can add.
It might also be nice if the IntOsc helper had a function to set the speed rather then you manually having to use the generated C code.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 14
- Joined: Wed Feb 26, 2020 9:49 am
- Has thanked: 2 times
- Been thanked: 1 time
- Contact:
Re: Servo Component not working
Benj,
Agreed on all points, thank you again, I'll post progress next week
I know Im being cheeky but could you recommend a better micro, my only constraint is that it needs to be small and for a moment DIP package ? oh and I only have a PICkit 4 and ICD3 programmers
regards
Rob
Agreed on all points, thank you again, I'll post progress next week
I know Im being cheeky but could you recommend a better micro, my only constraint is that it needs to be small and for a moment DIP package ? oh and I only have a PICkit 4 and ICD3 programmers
regards
Rob