Servo Issue
Moderator: Benj
- JLeith
- Posts: 537
- Joined: Wed Nov 14, 2012 7:49 pm
- Location: British Columbia Canada
- Has thanked: 146 times
- Been thanked: 26 times
- Contact:
Servo Issue
Hello all
Need some wisdom ASAP. I have a working Flowcode project but it will not load into my PIC16F1938
I have about 12 hrs from Jun 23 3:29 PST
My gradson was going to us the Servo to dispense Candy like a vending machine.
The design looked simple and works in flowcode perfect. Press the button and the Servo advance to 125 and zero.
I keep getting a error :
-A Vdd setpoint exceeds maximum for this device of 3.6V
I took a program design that had a pot to advance the servo.
I changed the Pot for solid value. Changed the Chip and the Oscillator to internal
I have attached the program and the picture
The VCC is 4.5V DC from Battery
I have no idea where the setting is for the VDD
Please give me a quick answer I spent 16hrs last night and no luck.
I did confirm the chip is working because I loaded another program into the pic that was not using a Servo design and it worked 100%
John
Need some wisdom ASAP. I have a working Flowcode project but it will not load into my PIC16F1938
I have about 12 hrs from Jun 23 3:29 PST
My gradson was going to us the Servo to dispense Candy like a vending machine.
The design looked simple and works in flowcode perfect. Press the button and the Servo advance to 125 and zero.
I keep getting a error :
-A Vdd setpoint exceeds maximum for this device of 3.6V
I took a program design that had a pot to advance the servo.
I changed the Pot for solid value. Changed the Chip and the Oscillator to internal
I have attached the program and the picture
The VCC is 4.5V DC from Battery
I have no idea where the setting is for the VDD
Please give me a quick answer I spent 16hrs last night and no luck.
I did confirm the chip is working because I loaded another program into the pic that was not using a Servo design and it worked 100%
John
- Attachments
-
- Error36.png
- (14.03 KiB) Downloaded 4276 times
-
- Evan Servo Jan 23.fcfx
- (13.03 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: Servo Issue
Hi John
If you look at the screen shot of the pickit settings, it's showing the device as 16LF1938 (low voltage version) instead of 16F1938.
Check and change your target device.
If you look at the screen shot of the pickit settings, it's showing the device as 16LF1938 (low voltage version) instead of 16F1938.
Check and change your target device.
Martin
- JLeith
- Posts: 537
- Joined: Wed Nov 14, 2012 7:49 pm
- Location: British Columbia Canada
- Has thanked: 146 times
- Been thanked: 26 times
- Contact:
Re: Servo Issue
Thank you Martin
I must have looked at the PIC 7 times and only confirmed the 1638
Martin Back in the day you indicted I should use a Led as a flashing indicator ?
I have this in my design and it doesn't work as I think it should
I have a loop In Main for RA2 and it won't light in the breadboard ?
I have another LED in the 'Candy Macro" for B5 and it should only come on when I press a button on a interrupt on B1
Odd when I step thru the flowcode and trigger B5 Led I appear to trigger the interrupt B1
I set the Interrupt on B1 by selecting the pin.
I have a drawing
And Flowcode
John
I must have looked at the PIC 7 times and only confirmed the 1638
Martin Back in the day you indicted I should use a Led as a flashing indicator ?
I have this in my design and it doesn't work as I think it should
I have a loop In Main for RA2 and it won't light in the breadboard ?
I have another LED in the 'Candy Macro" for B5 and it should only come on when I press a button on a interrupt on B1
Odd when I step thru the flowcode and trigger B5 Led I appear to trigger the interrupt B1
I set the Interrupt on B1 by selecting the pin.
I have a drawing
And Flowcode
John
- Attachments
-
- Candy PIC layout.png
- (189 KiB) Downloaded 4226 times
-
- Evan Servo Jan 26.fcfx
- (17.57 KiB) Downloaded 272 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: Servo Issue
Hi John,
Not a problem
The osccon registor within a c code block sets the internal osc speed.
You have got that C code block disabled.
You are showing nothing connected to MCLR pin, yet that is enabled within configuration settings.
If you have not got anything connected to MCLR pin, then it must be disabled.
Where interrupts are concerned you have to have a little as possible in them.
For example set a flag or increment a variable.
Having the same component and delays within interrupt call macros as you do for non interrupt macros causes corruption.
Remove all you can from within the interrupt!
Not a problem
The osccon registor within a c code block sets the internal osc speed.
You have got that C code block disabled.
You are showing nothing connected to MCLR pin, yet that is enabled within configuration settings.
If you have not got anything connected to MCLR pin, then it must be disabled.
Where interrupts are concerned you have to have a little as possible in them.
For example set a flag or increment a variable.
Having the same component and delays within interrupt call macros as you do for non interrupt macros causes corruption.
Remove all you can from within the interrupt!
Martin
- JLeith
- Posts: 537
- Joined: Wed Nov 14, 2012 7:49 pm
- Location: British Columbia Canada
- Has thanked: 146 times
- Been thanked: 26 times
- Contact:
Re: Servo Issue
Hello Martin
Thank you for the info.
On the MCLR I have a 10K resistor connected to +5 for the PICkit 2 access. So the MCLR is held to logic 1
For the C code I forgot to enable while I was frustrating finding out why my leds would activate as in the flowcode
In the "flag or increment a variable" is this meaning I should set a variable in the interrupt ?
Off to see what I can uncover. Back soon
John
Thank you for the info.
On the MCLR I have a 10K resistor connected to +5 for the PICkit 2 access. So the MCLR is held to logic 1
For the C code I forgot to enable while I was frustrating finding out why my leds would activate as in the flowcode
Martin are you indicating on the "little as possible" for interupts that If I use (B0) as my button trigger I can't use pins (B1-B7) for any action ?Where interrupts are concerned you have to have a little as possible in them.
For example set a flag or increment a variable.
In the "flag or increment a variable" is this meaning I should set a variable in the interrupt ?
Off to see what I can uncover. Back soon
John
-
- 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 Issue
Yes you can but within the interrupt set a variable depending on what button is pressed.JLeith wrote:Martin are you indicating on the "little as possible" for interupts that If I use (B0) as my button trigger I can't use pins (B1-B7) for any action ?
You can have inputs which won't cause any issues to set a value to a variable.
Then within main, you can process the variable and even use a call macro.
Yes by far the best way.JLeith wrote:n the "flag or increment a variable" is this meaning I should set a variable in the interrupt ?
Never use a call macro within an interrupt.
Martin
- JLeith
- Posts: 537
- Joined: Wed Nov 14, 2012 7:49 pm
- Location: British Columbia Canada
- Has thanked: 146 times
- Been thanked: 26 times
- Contact:
Re: Servo Issue
Hi Martin
I changed the Interrupt to DISP=1 so when the Button on B1 triggers the action should work ?
In flowcode it works.
In Breadboard it does not work ???
I have my digital scope on Trigger action on B1 and it does not activate. Only activates when I press B1.
Well in the breadboard My LCD says it registers DISP=1 even when I have the variable set to DISP=0 and I have set the value DISP=0 to ensure the Decision loop should only Loop Why DISP=0.
Putting LCD messages to see where the flow is going I see the loop does go into DISP=0.
For some reason I can't see the breadboard LCD Says it reads DISP=2 and only why I can see that if it thinks the trigger B1 tripped
Can you see anyway in the flowcode that I missed as to why the Breadboard thinks DISP=2.
Can I put my scope some where to trace the breadboard action.
I have attached the current Flowcode Design.
I can't also get my A1 to flash when it enters the Loop in Flowcode it flashes but not in the breadboard it comes on but not on/off.
John
John
I changed the Interrupt to DISP=1 so when the Button on B1 triggers the action should work ?
In flowcode it works.
In Breadboard it does not work ???
I have my digital scope on Trigger action on B1 and it does not activate. Only activates when I press B1.
Well in the breadboard My LCD says it registers DISP=1 even when I have the variable set to DISP=0 and I have set the value DISP=0 to ensure the Decision loop should only Loop Why DISP=0.
Putting LCD messages to see where the flow is going I see the loop does go into DISP=0.
For some reason I can't see the breadboard LCD Says it reads DISP=2 and only why I can see that if it thinks the trigger B1 tripped
Can you see anyway in the flowcode that I missed as to why the Breadboard thinks DISP=2.
Can I put my scope some where to trace the breadboard action.
I have attached the current Flowcode Design.
I can't also get my A1 to flash when it enters the Loop in Flowcode it flashes but not in the breadboard it comes on but not on/off.
John
John
- Attachments
-
- Evan Servo Jan 31.fcfx
- (22.09 KiB) Downloaded 246 times
- JLeith
- Posts: 537
- Joined: Wed Nov 14, 2012 7:49 pm
- Location: British Columbia Canada
- Has thanked: 146 times
- Been thanked: 26 times
- Contact:
Re: Servo Issue
Martin a further note
If I connect the servo it pulse a couple of times and then the LCD flashes like the Servo is killing the power source
John
If I connect the servo it pulse a couple of times and then the LCD flashes like the Servo is killing the power source
John
-
- 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 Issue
Hi John,
Have you done a one second flash test to see if everything is set up correctly?
If so will be surprised if delays are correct as you still got osccon statement commented out.
If the delays are way out then the 1 - 2 ms required for servo will be wrong causing access current and servo to burn out.
That could be why you are seeing the chip resetting?
Have you scoped the servo pulse to see if 1 - 2mA every 20ms?
Also, when pulse is detected then the DISP is set to 2.
The Candy macro is called, then there is a loop within, which is only activated when DISP =1 which is never, so the loop will not be accessed.
However as you reset DISP to 0 within the loop, even if loop was changed to while DISP = 2 or the interrupt wsa changed so DISP = 1 then the loop being there is a complete waste of time.
I have removed goto points as you can use a loop instead.
Much better programming practice.
Not sure why you have seconds variable counting down as its not being used on the display etc.
I have linked the servo controller to the servo motor so the motor will now move within simulation.
Give the attached flowchart a try, but first set up the one second flash test.
.
Have you done a one second flash test to see if everything is set up correctly?
If so will be surprised if delays are correct as you still got osccon statement commented out.
If the delays are way out then the 1 - 2 ms required for servo will be wrong causing access current and servo to burn out.
That could be why you are seeing the chip resetting?
Have you scoped the servo pulse to see if 1 - 2mA every 20ms?
Also, when pulse is detected then the DISP is set to 2.
The Candy macro is called, then there is a loop within, which is only activated when DISP =1 which is never, so the loop will not be accessed.
However as you reset DISP to 0 within the loop, even if loop was changed to while DISP = 2 or the interrupt wsa changed so DISP = 1 then the loop being there is a complete waste of time.
I have removed goto points as you can use a loop instead.
Much better programming practice.
Not sure why you have seconds variable counting down as its not being used on the display etc.
I have linked the servo controller to the servo motor so the motor will now move within simulation.
Give the attached flowchart a try, but first set up the one second flash test.
.
- Attachments
-
- Evan Servo Jan 31 V2a.fcfx
- (21.68 KiB) Downloaded 253 times
Martin
- JLeith
- Posts: 537
- Joined: Wed Nov 14, 2012 7:49 pm
- Location: British Columbia Canada
- Has thanked: 146 times
- Been thanked: 26 times
- Contact:
Re: Servo Issue
Thank you Martin
I follow the double loop for the flashing of the led.
I didn't know about the Button bounce protection. I use to use the Button properties
I cleaned up my LCD messages.
I have printed off your design for future projects.
Some of my patch work was trying to see where my code was going sideways.
I added the Servo back in and it moves but around but the code won't run. (Picture - Servo Loop)
Put the scope on the B1 pin without the servo connected ( Picture 125 or 0)
Looks like the servo is bouncing from 125 to 0 when it is connected. The servo is Model: HXT900
Maybe I should go back to using RS232 communication to the Servo or should it work as I have it designed.
John
I follow the double loop for the flashing of the led.
I didn't know about the Button bounce protection. I use to use the Button properties
I cleaned up my LCD messages.
? Not sure how to do a "one second flash test" ?Have you done a one second flash test to see if everything is set up correctly?
I have printed off your design for future projects.
Some of my patch work was trying to see where my code was going sideways.
I added the Servo back in and it moves but around but the code won't run. (Picture - Servo Loop)
Put the scope on the B1 pin without the servo connected ( Picture 125 or 0)
Looks like the servo is bouncing from 125 to 0 when it is connected. The servo is Model: HXT900
Maybe I should go back to using RS232 communication to the Servo or should it work as I have it designed.
John
- Attachments
-
- 125 or 0.png
- (7.84 KiB) Downloaded 4127 times
-
- Servo Loop.png
- (13.71 KiB) Downloaded 4127 times
- JLeith
- Posts: 537
- Joined: Wed Nov 14, 2012 7:49 pm
- Location: British Columbia Canada
- Has thanked: 146 times
- Been thanked: 26 times
- Contact:
Re: Servo Issue
Here is the cleaned up flowcode
John
John
- Attachments
-
- Evan Servo Jan 31 V1b.fcfx
- (21.19 KiB) Downloaded 163 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:
- JLeith
- Posts: 537
- Joined: Wed Nov 14, 2012 7:49 pm
- Location: British Columbia Canada
- Has thanked: 146 times
- Been thanked: 26 times
- Contact:
Re: Servo Issue
Hi Martin
The A1 pulse works and the Button activates
The servo not so much.
Its like the servo dosen't have a home position and jumps back a forward ?
John
The A1 pulse works and the Button activates
The servo not so much.
Its like the servo dosen't have a home position and jumps back a forward ?
John
-
- 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 Issue
That is only when you use The switch component macros i.e. ReadState, WaitUntilHigh & WaitUntilLow.JLeith wrote:I didn't know about the Button bounce protection. I use to use the Button properties
As they are not used within interrupt, then debouncing will be required.
Just follow the link embedded in the question asking you about one second flash test.JLeith wrote:? Not sure how to do a "one second flash test" ?
Is the server not acting like it is in the simulation?
Waveforms for the servo look correct so not sure what you are stating the issue is.
Can you explain in detail what is happening with hardware and how it's different to simulation?
Martin
- JLeith
- Posts: 537
- Joined: Wed Nov 14, 2012 7:49 pm
- Location: British Columbia Canada
- Has thanked: 146 times
- Been thanked: 26 times
- Contact:
Re: Servo Issue
Hi Martin
Missed the link to second flash test, Printed it off for future knowledge
For the Servo I will retest. Do you know of a test for the servo by it self.
I will send a video of the action
John
Missed the link to second flash test, Printed it off for future knowledge
For the Servo I will retest. Do you know of a test for the servo by it self.
I will send a video of the action
John
-
- 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 Issue
Don't forget to let me know what your expecting the servo to do V what it actually does.
The only test I can think of is either using a pot to control servo or just set variable controling servo to 0, 127, 255 to check for fully clockwise, center and counter clockwise.
The only test I can think of is either using a pot to control servo or just set variable controling servo to 0, 127, 255 to check for fully clockwise, center and counter clockwise.
Martin
- JLeith
- Posts: 537
- Joined: Wed Nov 14, 2012 7:49 pm
- Location: British Columbia Canada
- Has thanked: 146 times
- Been thanked: 26 times
- Contact:
Re: Servo Issue
Try two more Servo and they do the same action
Here is the current Flowcode.
Here is the current Flowcode.
- Attachments
-
- Evan Servo Jan 31 V1b.fcfx
- (21.41 KiB) Downloaded 156 times
- JLeith
- Posts: 537
- Joined: Wed Nov 14, 2012 7:49 pm
- Location: British Columbia Canada
- Has thanked: 146 times
- Been thanked: 26 times
- Contact:
Re: Servo Issue
Hi Martin
I noticed once the Servo is going back a forth the PIC stops running the script. The Button is ignored and I have to reload the flowcode.
I even copied the Flowcode Single Motor that uses the pot to determine the action of the servo.
Just set the "IN: value to 125 or 0 and it still runs back and forth
Here is the flowcode with Macro Servo1
I noticed once the Servo is going back a forth the PIC stops running the script. The Button is ignored and I have to reload the flowcode.
I even copied the Flowcode Single Motor that uses the pot to determine the action of the servo.
Just set the "IN: value to 125 or 0 and it still runs back and forth
Here is the flowcode with Macro Servo1
- Attachments
-
- Evan Servo Jan 31 V1b.fcfx
- (22.8 KiB) Downloaded 147 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: Servo Issue
Sounds to me like a hardware issue.
Could be the power supply not up to the job. The way to find out is scope the servo signal line with servo disconnected.
If it's steady at say 1.5ms every 20ms then is not software. With servo connected and playing up, scope power supply line.
You may have to set up to capture on less 4.5v.
If power supply is dipping then it's power supply not man enough or faulty servo. If power supply is steady then probably a servo fault. What power supply have you got and can't you try with a much better one?
What about decoupling and smoothing caps across the power pins of MCU?
Don't for inside a servo is a DC motor .
When it first starts from the stalled condition, the will be a much higher starting current for a brief period of time.
The power supply has to handle that without output voltage dipping.
Could be the power supply not up to the job. The way to find out is scope the servo signal line with servo disconnected.
If it's steady at say 1.5ms every 20ms then is not software. With servo connected and playing up, scope power supply line.
You may have to set up to capture on less 4.5v.
If power supply is dipping then it's power supply not man enough or faulty servo. If power supply is steady then probably a servo fault. What power supply have you got and can't you try with a much better one?
What about decoupling and smoothing caps across the power pins of MCU?
Don't for inside a servo is a DC motor .
When it first starts from the stalled condition, the will be a much higher starting current for a brief period of time.
The power supply has to handle that without output voltage dipping.
Martin
- JLeith
- Posts: 537
- Joined: Wed Nov 14, 2012 7:49 pm
- Location: British Columbia Canada
- Has thanked: 146 times
- Been thanked: 26 times
- Contact:
Re: Servo Issue
Hi Martin
I have tried 3 Servo and they all do the same action.
The drawing on post ( Thu Jan 31, 2019 3:29 pm ) is with the Servo disconnected.
I used a Trigger on my digital scope ( UTD2052CEX) now I can't get the trigger to stop and go to live. More work on the scope.
The power supply is one I have used on all my projects. From the Scope image it looks like a steady 4.5v output.
From the scope image it looks under 2ms. and 0 degree is under 2ms
In flowcode I don't see how we determine the 2ms on/off it looks like in flowcode i send 125 and then go back to the code.
Would we not have to have the B0 port PWM for 2ms. Maybe the signal is not long enough for the Servo.
Off to see what is happening to my scope.
I have tried 3 Servo and they all do the same action.
The drawing on post ( Thu Jan 31, 2019 3:29 pm ) is with the Servo disconnected.
I used a Trigger on my digital scope ( UTD2052CEX) now I can't get the trigger to stop and go to live. More work on the scope.
The power supply is one I have used on all my projects. From the Scope image it looks like a steady 4.5v output.
From the scope image it looks under 2ms. and 0 degree is under 2ms
In flowcode I don't see how we determine the 2ms on/off it looks like in flowcode i send 125 and then go back to the code.
Would we not have to have the B0 port PWM for 2ms. Maybe the signal is not long enough for the Servo.
Off to see what is happening to my scope.
- JLeith
- Posts: 537
- Joined: Wed Nov 14, 2012 7:49 pm
- Location: British Columbia Canada
- Has thanked: 146 times
- Been thanked: 26 times
- Contact:
Re: Servo Issue
Hi Martin
It looks like the PWM is sending a pulse value on/off when I monitor the PWM without the Servo.
That must be what the Servo is seeing.
Is there a way in PWM only to send and stop ?
John
It looks like the PWM is sending a pulse value on/off when I monitor the PWM without the Servo.
That must be what the Servo is seeing.
Is there a way in PWM only to send and stop ?
John
- JLeith
- Posts: 537
- Joined: Wed Nov 14, 2012 7:49 pm
- Location: British Columbia Canada
- Has thanked: 146 times
- Been thanked: 26 times
- Contact:
Re: Servo Issue
Hi Martin
For some reason the PWM keeps the Signal going out and the servo is trying to follow the beat.
Defiantly PWM is not working the same in Flowcode as in the PIC design.
I noticed when I restart the program the PWM is at logic 0 level and once I ask the PWM to send out a 125 or 90 or 25 is sends it out but doesn't stop sending.
Is there a another timer we could try and send out a value with time of 2ms ?
John
For some reason the PWM keeps the Signal going out and the servo is trying to follow the beat.
Defiantly PWM is not working the same in Flowcode as in the PIC design.
I noticed when I restart the program the PWM is at logic 0 level and once I ask the PWM to send out a 125 or 90 or 25 is sends it out but doesn't stop sending.
Is there a another timer we could try and send out a value with time of 2ms ?
John
- JLeith
- Posts: 537
- Joined: Wed Nov 14, 2012 7:49 pm
- Location: British Columbia Canada
- Has thanked: 146 times
- Been thanked: 26 times
- Contact:
Re: Servo Issue
Hi Martin
Just noticed a servo question in the forum from Benj
This Forum message is in Flowcode 7 is this maybe the same issue in Flowcode 6 ?
John
Just noticed a servo question in the forum from Benj
This Forum message is in Flowcode 7 is this maybe the same issue in Flowcode 6 ?
.......................Post by Benj » Wed Apr 25, 2018 9:54 am
Hello Enrique,
The Servo component requires 2 PWM channels to allow the Servo output to be generated. The 16F819 only has one PWM channel
John