Home
Prox / RFID
Verichips
Ladder Logic
[interfacing] †
Tube Joints
Key Code From Photo
SolveSpace (3d CAD)
SketchFlat (2d CAD)
Photographs
Miscellany
Resume / Consulting
Contact Me

LDmicro Forum - pwm output - adc input (servo control)

(you are viewing a thread; or go back to list of threads)

pwm output - adc input (servo control) (by Alex)
Hello, i want to control a servo motor sg90 using 16f88 (with internal oscillator), first of all, i want to use 16f88 as a "driver" like 16f628a for serial lcd, which means that i am using a 16f877a (OUTPUT PWM PIN) connected to an 16f88 (ADC INPUT PIN) ,i tried to use it and got this (watch video please):


https://www.youtube.com/watch?v=F8NPTsgG6uY&feature=youtu.be


i have read some information about this connection, it is no accurate, also i have read MGP´s post:

http://cq.cx/ladder-forum.pl?a...;parent=8859&tt=1564052315

i watched MGP´s video:


https://www.youtube.com/watch?v=qZ92GbxMdN8&feature=youtu.be

is there an schematic?
Thu Oct 17 2019, 19:33:46
(no subject) (by Alex)
for 16f877a i have used a simple led brightness control program and for 16f88 an example MGP´s gave me in the past which i made some changes, both attach
Thu Oct 17 2019, 19:40:24, download attachment ladder programs servo.zip
(no subject) (by Alex)
i need hlep to use it the most accurate possible
Thu Oct 17 2019, 19:40:50
(no subject) (by Ziggy)
That is "the most accurate"
What do you actually need?
Thu Oct 17 2019, 19:51:42
(no subject) (by Alex)
i want(need) to do this (watch video please):

https://www.youtube.com/watch?v=r1VRvI2j7dM
Thu Oct 17 2019, 23:29:10
(no subject) (by Alex)
with my program i can not make an entire turn
Thu Oct 17 2019, 23:30:12
(no subject) (by Ziggy)
Alex ,

Ensure the servo driver signal is generated at some lowish frequency at 10 bit resolution. Fool the software by specifying a clock rate in LDmicro but applying some other clock to the micro to ensure signal compliance to drive servo.

Make sure the servo driver signal is within the general tolerances of the signaling.

Pulse repetition rate and duty cycle range.

Servo motors are not meant to turn 360 degrees. Check the specifications of Your motor.
Fri Oct 18 2019, 01:20:43
(no subject) (by Alex)
thank for the explenation , my mistake, by "complete turn"i mean that it moves all the way a potentiometer does
Fri Oct 18 2019, 01:30:55
(no subject) (by MGP)
It's easy, the servo has 105 - 55 = 50 'steps' (-90 to +90)
And the ADC has 1023 steps.
You must divide the ADC (1023) by 1023/55 = 18

See in my program, each 18 units of the ADC is 1 'step' of the servo.

If you use the buttons then duty= duty+18.

After 50 counts you have the full turn of the servo (-90 +90)
Fri Oct 18 2019, 10:04:20
(no subject) (by Alex)
thanks a lot MGP i will try
Fri Oct 18 2019, 10:11:40
(no subject) (by MGP)
It's easy, the servo has 105 - 55 = 50 'steps' (-90 to +90)
And the ADC has 1023 steps.
You must divide the ADC (1023) by 1023/55 = 18

See in my program, each 18 units of the ADC is 1 'step' of the servo.

This is the correct answer, sorry I cant edit my previous answer.
Fri Oct 18 2019, 10:17:34
(no subject) (by Alex)
escuseme, about the pin 6 bug in 16f88, has it been fixed?
Fri Oct 18 2019, 10:54:47
(no subject) (by MGP)
You can see that for yourself in the program, if you have to choose a PWM pin you can only choose pin9 while pin 6 is the output in this case.
I haven't thought about it anymore and it's just a small bug (?).

The latest version of LDmicro is really good.
The last project can be seen here, a chronometer and lap counter, the hardware is from Steelwood from the Netherlands and I wrote the program, there is also an MP4 video to see.

https://www.circuitsonline.net/forum/view/146222/2
Sat Oct 19 2019, 07:57:42
Post a reply to this comment:
Your Name:
Your Email:
Subject:
(no HTML tags; use plain text, and hit Enter for a line break)
Attached file (if you want, 5 MB max):