SERVO PROBLEM

36 views
Skip to first unread message

Hans van Veldhuizen

unread,
Apr 17, 2024, 1:30:40 PMApr 17
to jallist

Hello all,

I have a servo problem that I don't understand.

When I run the servo on my old tester (based on the sample from back then for the 16F877a with 20 Mhz xtal)) it moves neatly between 0 and 255.

I now have a circuit (also with a 16F877a with 20 mHz xta) where the servo position is indicated with the measurement (a kind of radar). Then I have to vary the servo from 0 to 180. Higher values do nothing

Attached:

a. two pictures of the tester (left above the ADC measurement) and the servo at these values.

b. A picture of the “radar” circuit

c. The “RADAR” program”

Who can help me solve this riddle?

regards

Hans

16F877a_RADAR_2.jal
Message has been deleted
Message has been deleted

Rob CJ

unread,
Apr 18, 2024, 12:48:41 PMApr 18
to jallist
Hi Hans,

I do not understand exactly what you mean but I have 2 questions/requests:
  1. Can you first fix the program that you do not get any warnings? Warning may lead to issues. 
  2. Can you add the serial interface and print the value of dist so that you are sure that the issue is not in the distance that you measure? 

I always recommend that if you need to debug an issue to reduce the problem to the smallest possible size.

So if you measure a distance and control a servo with that distance then first verify if the distance that you measure is OK instead of looking at the servo position since the problem can be hidden in one of the two but now you do not know which one.

Kind regards,

Rob


Van: jal...@googlegroups.com <jal...@googlegroups.com> namens Hans van Veldhuizen <hanz...@zeelandnet.nl>
Verzonden: woensdag 17 april 2024 19:30
Aan: jallist <jal...@googlegroups.com>
Onderwerp: [jallist] SERVO PROBLEM
 
--
You received this message because you are subscribed to the Google Groups "jallist" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jallist+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jallist/0013368b-69ed-4dd4-9c57-4352e92ff8b4n%40googlegroups.com.

Hans van Veldhuizen

unread,
Apr 18, 2024, 3:19:06 PMApr 18
to jallist
----- OPSTART
  delay_1S(2)
--- test servo position
    for 5 loop
    servo_move(0,1)
     delay_1S(2)
     servo_move(180,1)<< if this value is higher then no result. Normally it goes to 255!!!!!!
     delay_1S(2)
    end loop

Op donderdag 18 april 2024 om 18:48:41 UTC+2 schreef Rob CJ:

Rob CJ

unread,
Apr 18, 2024, 3:57:56 PMApr 18
to jal...@googlegroups.com
Hi Hans,

Ah. I did not see that so you already isolated the problem. Good work.

I can see nothing wrong. The only think I can think of at this moment is that if the crystal clock would not be 20 MHz but higher that the pulse for the Servo would be incorrect.

Maybe Matt has a suggestion as servo expert.

Kind regards,

Rob


Verzonden: donderdag 18 april 2024 21:19
Aan: jallist <jal...@googlegroups.com>
Onderwerp: Re: [jallist] SERVO PROBLEM
 

Matthew Schinkel

unread,
Apr 18, 2024, 6:08:39 PMApr 18
to jallist
Rob is right, you should check your clock frequency is correct. Does a blink sample blink at the correct speed or do you have an oscilloscope to check with?

Does the provided sample 16f877a_servo_rc_master.jal work? you can take the first part from there for 16f877a

Does it work if you manually enter a value over 180 at this part?
    for 5 loop
    servo_move(0,1)
     delay_1S(2)
     servo_move(180,1)
     delay_1S(2)
    end loop

You can try another timer or switch the timers. You only have one servo, why have both of these defined?
const byte SERVO_USE_TIMER = 1            -- timer for servo's 1 to 8
const byte SERVO_9_TO_16_USE_TIMER = 0    -- timer for servo's 9 to 16

Try another servo

You should try to fix the truncation and signed/unsigned mismatch warnings.

Matt.

Hans van Veldhuizen

unread,
Apr 19, 2024, 4:28:17 AMApr 19
to jallist
Hello Rob and Matt
Even though my toy worked fine, I replaced the crystal set. No improvement. Finally borrowed a pic from another circuit and ………. Dissolved!!!!!!
Old men, old business, old stuff, brand new problems.
regards
Hans

Op vrijdag 19 april 2024 om 00:08:39 UTC+2 schreef Matthew Schinkel:

Hans van Veldhuizen

unread,
Apr 21, 2024, 10:45:26 AMApr 21
to jallist
I can never just leave riddles behind. I have extensively tested the problem PIC. Flashing LEDs, applying ADC, etc. that worked, but the usart no longer works.
I also loaded the content with a good working program, but that is a different story.
  I realized that this PIC comes from my old “SMART METER” that has monitored and displayed my electricity imports and exports for years.
The fact that the thing has now become lame, is that wear and tear?
  If so, I hope the electronics in my chest won't be affected.
Anyway, this one is now resting in the trash.
regards
Hans

Op vrijdag 19 april 2024 om 10:28:17 UTC+2 schreef Hans van Veldhuizen:

Matthew Schinkel

unread,
Apr 21, 2024, 3:25:03 PMApr 21
to jallist
It may work with an internal oscillator if that's an option, or try a 4 pin crystal oscillator.

Matt.

Hans van Veldhuizen

unread,
Apr 22, 2024, 1:49:00 AMApr 22
to jallist
Hi Matt, 
Does the 16F877a has an internal    oscillato?
Hans

Op zondag 21 april 2024 om 21:25:03 UTC+2 schreef Matthew Schinkel:

Matthew Schinkel

unread,
Apr 22, 2024, 11:46:02 PMApr 22
to jallist
Hi Hans, 16F877a does not have an internal oscillator but it can take a external 4 pin crystal oscillator.

Try 18f4620 sometime or another pic with an internal oscillator. It saves parts and may prevent issues like this.

Matt.

Message has been deleted

Hans van Veldhuizen

unread,
Apr 23, 2024, 3:12:49 PMApr 23
to jallist
Hello Matt,
I'm happily working with my old WISP again and luckily I still have a few old ones that are doing fine with it
 If possible, I like to use the internal occilator, but I have experienced that if you want to do something with that horrible MIDI baud rate, a crystal is usually a must.
Your Servo lib is still a great thing for me.
regards
Hans

Op dinsdag 23 april 2024 om 05:46:02 UTC+2 schreef Matthew Schinkel:
Reply all
Reply to author
Forward
0 new messages