Searching \ for '[PIC]: Servo Pulse Problem' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ios.htm?key=servo
Search entire site for: 'Servo Pulse Problem'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Servo Pulse Problem'
2003\06\15@013311 by Joel Middleton

picon face
part 1 2932 bytes content-type:text/plain; charset=us-asciiI believe I am having a problem with the pulse I am
sending to a servo connected directly to portb pin 3.
I have tmr0 set to overflow ever .0001 seconds. The
variable 'count' is incremented each time tmr0
overflows when count reaches 200 it is reset to 0.
When count is equal to zero I set portb pin 3 and when
count equals pw1 I clear the pin. I believe this
should give me a 1ms pulse every 20ms. This was not
working like I thought and I wanted to take a look at
the pulse so I downloaded one of those ocilloscopes
that runs through a sound card as I did not have
access to a real one. Well I found out that I am not
getting a nice square wave. The rising edge looks fine
but the falling edge is a slope. Can anyone tell me
how to correct this? I have included my code and also
attached an image I captured from the occiloscope.
Thanks.


LIST R=DEC

INCLUDE "p16f84a.inc"

CBLOCK 0x0C
_w
_status
_pclath
_fsr
count
pw1
ENDC

__CONFIG _CP_OFF & _WDT_OFF & _XT_OSC & _PWRTE_ON

push    macro
       movwf   _w                      ;Save registers
       movf    STATUS, w
       movwf   _status
       movf    PCLATH, w
       movwf   _pclath
       clrf    PCLATH
       endm

pull    macro
       swapf   _pclath, w
       movwf   PCLATH
       movf    _status, w      ;Restore registers
       movwf   STATUS
       swapf   _w, f
       swapf   _w, w
       endm

PAGE

       org             0
       nop

       goto    Main

       org             4                       ;Interrupt

       push

Timer0
       btfss   INTCON, T0IF
               goto    Iend
       movlw   165
       movwf   TMR0
       bcf             INTCON, T0IF
       incf    count
       movlw   200
       subwf   count, W
       btfss   STATUS, Z
               goto    Step1
       movlw   0
       movwf   count
Step1
       movlw   0
       subwf   count, 0
       btfsc   STATUS, Z
               bsf             PORTB, 3
       movf    pw1, W
       subwf   count, 0
       btfsc   STATUS, Z
               bcf             PORTB, 3
Iend

       pull

       retfie

Main

       bsf             INTCON, GIE
       bsf             INTCON, T0IE

       bsf     STATUS, RP0
       bcf             OPTION_REG, T0CS
       bsf             OPTION_REG, PSA
   bcf         STATUS,RP0          ; RAM PAGE 0

       movlw   156
       movwf   TMR0

       clrf    PORTB

       bsf     STATUS, RP0
       bcf     TRISA ^ 0x080, 1
       bcf     TRISA ^ 0x080, 2
       clrf    TRISB
       bcf     STATUS, RP0

       clrf    PORTA
       clrf    PORTB
       clrf    count

       movlw   10
       movwf   pw1

Loop
       nop
goto    Loop
end


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu



part 2 3080 bytes content-type:image/pjpeg; name="pulse.jpg" (decode)


part 3 2 bytes
-

2003\06\15@091717 by Olin Lathrop

face picon face
> Well I found out that I am not
> getting a nice square wave. The rising edge looks fine
> but the falling edge is a slope.

This depends on the external circuit.  Something must be sourcing lots of
current (almost certainly above spec) when the PIC tries to lower the pin,
or the low side driver is blown.  Did you forget a flyback diode?

If the timing is otherwise right, then it's not a software problem.

<undocumented absolute mode code ignored and snipped>


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu>

2003\06\15@125040 by rneel

picon face
part 1 4234 bytes content-type:text/plain; charset=ISO-8859-1 (decoded 7bit)

I'm certainly no expert, but it looks like a classic capacitor discharge issue to me.  If you have a cap on this output, it will take time for it to discharge causing the slow decay in voltage instead of a nice sharp corner.  I can't see your circuit but do you have a cap connected across the pin you measured with the scope?
{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamspam_OUTmitvma.mit.edu




part 2 4117 bytes content-type:image/pjpeg; (decode)


part 3 2 bytes
-

2003\06\15@125110 by Joel Middleton

picon face
Yes I do not have a flyback diode. I am not sure how
to implement this with a servo, are they any examples
on the web that I can look at?

--- Olin Lathrop <@spam@olin_piclistKILLspamspamEMBEDINC.COM> wrote:
{Quote hidden}

*****************************************************************
> Embed Inc, embedded system specialists in Littleton
> Massachusetts
> (978) 742-9014, http://www.embedinc.com
>
> --
> http://www.piclist.com hint: To leave the PICList
> KILLspampiclist-unsubscribe-requestKILLspamspammitvma.mit.edu


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu>

2003\06\15@142017 by Sean H. Breheny

face picon face
I don't know why Olin suggested a flyback diode. If this is a regular RC
servo, this is simply a command input, not PWM being fed directly to a
motor. Have you tried looking at the output of the pin without anything
connected (besides the scope)? Also, although it is difficult to imagine
how it could show one edge nice and clean and the other edge incorrectly, I
am a bit suspicious of the accuracy of the sound card as a scope. If
configured properly, I guess it could be fine, but it could be a challenge
in some cases to make sure it is all set up properly, especially since it
is not designed for this purpose. You might also try a different pin on the
PIC or a different PIC to rule out damage to the point pin drivers.

Finally, I took a quick look at your code and I don't see how this could be
happening, but what you are seeing is consistent with switching the port
pin's DIRECTION (input vs output) rather than value. In other words, if you
somehow have the PORTB register's bit # 3 permanently high and you are
switching TRISB's bit 3 instead, you would be switching the pin between
high and tristate rather than high and low. This is remotely possible since
PORTB and TRISB are the same address but in different banks (depends on the
setting of RP0 in the STATUS register).

Sean

At 08:19 AM 6/15/2003 -0700, you wrote:
{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestEraseMEspam.....mitvma.mit.edu>

2003\06\15@142021 by Joel Middleton
picon face
part 1 5536 bytes content-type:text/plain; charset=us-asciiI found this schematic on the web and this is my exact
circuit except the servo signal is connected to pin 3
on portb. Also I have all the unused pins connected to
ground. Anyone see anything wrong with the circuit?


--- EraseMErneelspamCOX.NET wrote:
{Quote hidden}

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestKILLspamspammitvma.mit.edu



part 2 5907 bytes content-type:image/gif; name="fig02.gif" (decode)


part 3 2 bytes
-

2003\06\15@143925 by John Ferrell

face picon face
What kind of servo (brand/model).
John Ferrell
6241 Phillippi Rd
Julian NC 27283
Phone: (336)685-9606
johnferrellSTOPspamspamspam_OUTearthlink.net
Dixie Competition Products
NSRCA 479 AMA 4190  W8CCW
"My Competition is Not My Enemy"

{Original Message removed}

2003\06\15@151742 by stanton54

picon face
Make sure the wires are connected properly (black is ground, the [usually red] middle wire is positive, signal is often white or yellow)
Also, try using a separate power supply for the servo. It will draw quite a bit of current when it tries to move, possibly pulling the voltage down enough that the PIC resets or does something else unpleasant.

--{Original Message removed}

2003\06\15@152600 by Joel Middleton

picon face
Futaba S3004
--- John Ferrell <spamBeGonejohnferrellSTOPspamspamEraseMEEARTHLINK.NET> wrote:
> What kind of servo (brand/model).
> John Ferrell
> 6241 Phillippi Rd
> Julian NC 27283
> Phone: (336)685-9606
> KILLspamjohnferrellspamBeGonespamearthlink.net
> Dixie Competition Products
> NSRCA 479 AMA 4190  W8CCW
> "My Competition is Not My Enemy"
>
> {Original Message removed}

2003\06\15@152602 by David VanHorn

flavicon
face
At 10:12 AM 6/15/2003 -0700, Joel Middleton wrote:

>I found this schematic on the web and this is my exact
>circuit except the servo signal is connected to pin 3
>on portb. Also I have all the unused pins connected to
>ground. Anyone see anything wrong with the circuit?

A couple potential problems. (pun)

Running a servo motor from your logic supply is a bad idea.
The motor has relatively large stall current demands, and produces a lot of noise. These both have the potential to reset or crash the micro.

Try providing a separate supply for the servo motor, like four AA cells.
Keep the ground tied between the supplies though as that provides the reference for the pulse.

Also, I've found that I need a series resistor of 100 ohms to 1k between the micro and the servo's pulse input. I've never investigated why, but I've had a few chips blown (Atmel AVRs) when I didn't have that series resistor.

It's never a real good idea to take uP I/O pins directly into the real world.

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspamEraseMEmitvma.mit.edu>

2003\06\15@174339 by Kyrre Aalerud

flavicon
face
One thing...
Turn off BOD.  It may reset the circuit if voltage drops too far.  This can
happen if the servo does hard work or just as it starts to move...

   KreAture

{Original Message removed}

2003\06\15@174819 by Olin Lathrop

face picon face
> Yes I do not have a flyback diode. I am not sure how
> to implement this with a servo, are they any examples
> on the web that I can look at?

I thought you were driving a motor directly.  When you say "servo", do you
mean those hobby units that decode pulse length, then contain a servo
mechanism to control position?  Keep in mind that "servo" is a general term
referring to a type of control loop, but has also been hijacked for those
hobby assemblies.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: To leave the PICList
@spam@piclist-unsubscribe-request@spam@spamspam_OUTmitvma.mit.edu>

2003\06\15@174822 by Joel Middleton

picon face
I put a resistor between the PIC and the servo signal
wire and this does not seem to help. I get the same
slope on the falling edge whether to servo is
connected or not. I guess I will order a couple more
pics and see if that helps.


--- David VanHorn <spamBeGonedvanhornspamKILLspamCEDAR.NET> wrote:
{Quote hidden}

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

--
http://www.piclist.com hint: To leave the PICList
TakeThisOuTpiclist-unsubscribe-request.....spamTakeThisOuTmitvma.mit.edu>

2003\06\15@174825 by Picdude

flavicon
face
Your duty-cycle technique sounds like it should give you what you expect since I use the same technique to vary LED brightness.  I played with servos in the past, and did not have this problem.  Have you tried separating the PIC ckt from the servo to isolate the problem?  If you have an oscope, put a small load resistor at the output instead of the servo and see what you get then.  If clean, then the servo is causing the problem, and you could try swapping for another.  If you still get that decay pattern, you have PIC problems.  Try another port or PIC.

Cheers,
-Neil.



On Sunday 15 June 2003 09:55, TakeThisOuTrneelKILLspamspamspamCOX.NET scribbled:
{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
TakeThisOuTpiclist-unsubscribe-requestspamspammitvma.mit.edu>

2003\06\15@175221 by Picdude

flavicon
face
I think Olin is thinking motor from a servo, whereas I thought you meant complete servo.  If the latter, you should not need a flyback diode, as the servo has it's own interface to covert the digital PWM signal to a motor-drive signal.

Cheers,
-Neil.



On Sunday 15 June 2003 10:19, Joel Middleton scribbled:
{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
@spam@piclist-unsubscribe-requestRemoveMEspamEraseMEmitvma.mit.edu>

2003\06\15@191651 by Dale Botkin

flavicon
face
On Sun, 15 Jun 2003, Joel Middleton wrote:

> I put a resistor between the PIC and the servo signal
> wire and this does not seem to help. I get the same
> slope on the falling edge whether to servo is
> connected or not. I guess I will order a couple more
> pics and see if that helps.

Let me get this straight - you 'scope the output of the PIC with nothing
connected, and still see the slope on the trailing edge?  Sounds like a
sound card thing to me.  A nickel says it looks far different on a real
'scope.

Dale
--
It's a thankless job, but I've got a lot of Karma to burn off.
Get a PicoKeyer: http://www.hamgadgets.com

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspam@spam@mitvma.mit.edu>

2003\06\15@201640 by John Ferrell

face picon face
I just duplicated your set up with a 16F628, Futaba 9101 servo and 4 AA
batteries as a power supply.
The wave form was nice and square on a Tektronix 475A scope.

The servo locked up nice & tight indicating all is working...

Be certain that
  Black is ground
  Red is Vcc (center lead)
  White is signal

John Ferrell
6241 Phillippi Rd
Julian NC 27283
Phone: (336)685-9606
@spam@johnferrellspam_OUTspam.....earthlink.net
Dixie Competition Products
NSRCA 479 AMA 4190  W8CCW
"My Competition is Not My Enemy"

{Original Message removed}

2003\06\15@202138 by Joel Middleton

picon face
Thanks everyone for the help, I think I am going to
try and find a real scope that I can use and check
things out.

--- John Ferrell <spamBeGonejohnferrellEraseMEspamEARTHLINK.NET> wrote:
{Quote hidden}

> {Original Message removed}

2003\06\16@123609 by Carlos Ojea

flavicon
face
> so I downloaded one of those ocilloscopes
> that runs through a sound card as I did not have
> access to a real one.

Could you tell me where can I download one of those scopes?

Regards,
Carlos

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\06\16@160058 by John Ferrell

face picon face
General information:
I duplicated the hardware, copied the program and executed the program. It
works as it is intended and the waveform looks good.
BTW, the code is a good example for calling and returning from an interrupt
with a save/restore on the registers.
It could stand a little more comments though...

John Ferrell
6241 Phillippi Rd
Julian NC 27283
Phone: (336)685-9606
RemoveMEjohnferrell@spam@spamspamBeGoneearthlink.net
Dixie Competition Products
NSRCA 479 AMA 4190  W8CCW
"My Competition is Not My Enemy"

----- Original Message -----
From: "Joel Middleton" <.....chopsuey1973@spam@spamEraseMEYAHOO.COM>
To: <.....PICLISTRemoveMEspamMITVMA.MIT.EDU>
Sent: Sunday, June 15, 2003 8:19 PM
Subject: Re: [PIC]: Servo Pulse Problem


> Thanks everyone for the help, I think I am going to
> try and find a real scope that I can use and check
> things out.
>

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\06\17@083634 by Nigel Orr

flavicon
face
> > so I downloaded one of those ocilloscopes
> > that runs through a sound card as I did not have
> > access to a real one.
>
> Could you tell me where can I download one of those scopes?

Even better than that, I can show you where to find out for yourself!
http://www.google.com/search?q=windows+%22sound+card%22+oscilloscope

I have used the top result (Oscilloscope for Windows v2.51) a few times,
and within the constraints of a sound card it works reasonably well (fixed
limited dynamic range and frequency response 20Hz-20kHz or less).  However,
a real 'scope really really _REALLY_ should be near the top of the tool
list for any aspiring electronics hobbyist, above a screwdriver and pair of
pliers... definitely before a multimeter.  And at the typical auction
prices for old Teks and HPs on ebay, the prices are about the same as a
cheap multimeter too!

It saves _so_ much puzzling and conjecturing, even if someone isn't paying
for your design time it makes the hobby more enjoyable!

Nigel
--
Nigel Orr, Design Engineer                 .....nigelSTOPspamspam@spam@axoninstruments.co.uk
Axon Instruments Ltd., Wardes Road,Inverurie,Aberdeenshire,UK,AB51 3TT
              Tel:+44 1467 622332 Fax:+44 1467 625235
                  http://www.axoninstruments.co.uk

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

More... (looser matching)
- Last day of these posts
- In 2003 , 2004 only
- Today
- New search...