Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Picomites and servos
Author | Message | ||||
Bill.b Senior Member Joined: 25/06/2011 Location: AustraliaPosts: 225 |
The servo command is not listed in the pico command table. Is this and omission or is this command unavailable of picos. Is there an alterative way to drive servos i.e using pulse out. Bill In the interests of the environment, this post has been constructed entirely from recycled electrons. |
||||
phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 1776 |
Quickest way to find out would be to hook one up and see if if the servo command makes it move. If you don't have a servo to hand connect an oscilloscope to the Pico. Another Pico running the Scope program would do. PWM could be another way. Keep the frequency constant and adjust the pulse width to move the servo. Tried it. "Error : Unknown command" so PWM it is. . Edited 2022-05-09 11:01 by phil99 |
||||
lizby Guru Joined: 17/05/2016 Location: United StatesPosts: 3011 |
PWM works. PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 5708 |
The PicoMite doesn't have the SERVO command. This has come up before. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8572 |
The servo command is just a simple repackaging of the PWM command and therefore if included just wastes a command slot PWM n,50,(position_as_a_percentage * 0.05 + 5) Edited 2022-05-09 17:06 by matherp |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 3503 |
Some example code how you can use PWM to move a servo. Servo's work at 50Hz (20mS) PWM The actual math is in "program PWM's", the rest is just an explanation where the numbers come from. 'defines frequency=50 'hz period= 1e6/frequency 'us 'servo characteristics (what PWM gives what angle) PWMmin= 800 'us PWMmax= 2200 'us AngMin=-90 'degrees AngMax=90 'degrees 'calculations AngRange=AngMax-AngMin 'degrees DCmin=100*PWMmin/period '% DCmax=100*PWMmax/period '% DCRange=DCmax-DCmin '% 'system setup PWM 0,off SetPin GP0,pwm0a SetPin GP1,pwm0b 'Control servo, give Angle0 and Angle 1 'for test Angle0=-45 Angle1=45 'Program PWMs DC0=DCmin + ((Angle0-AngMin)/AngRange)*DCRange DC1=DCmin + ((Angle1-AngMin)/AngRange)*DCRange PWM 0,frequency,DC0,DC1 So in essence the formula is (for those who like numbers): DC=7.5 + Angle*0.044 'angle in degrees PWM 0,50,DC Edited 2022-05-11 03:22 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
Print this page |