RC servo testing

Questions on other types of hardware and getting it talking to the ARM CPU
Post Reply
olzeke51
Posts: 414
Joined: Sat May 17, 2014 4:22 pm
Location: South Carolina

RC servo testing

Post by olzeke51 »

As part of a project utilizing a lightweight RC servo, I wanted to test the limits and some 'stepping' values.
My project needed some small steps. [?More to come in a future 'Project"!?]
'
This utilizes Coridium's HWPWM11.bas file - as I used a Prostart board.
It also includes a 'Bit Bang' routine using a manually controlled (OUTPUT) designated pin.
'
Tried to 'pretty' up the code !!!!

Code: Select all

#include "LPC11xx.bas"
'tiankongrc SG90 servo  - - 180 degrees  .5ms to 2.5ms 1.5=center

CONST Cycletime = 20000
main:
dim ms20, ms_var, k, highTime, bigstep
'ms20 = 1
'ms_var = 500		'.5 ms for this servo - low volume

print "starting"
wait(2000)
output(9)
pwming:
'HWPWM ( channel, cycleTime, highTime )  '/microsecs
'HWPWM ( 2, 20000, highTime )
'// grz so I need to clear the old hightime and put in the new one
'//     else I get 'chatter'

highTime = 500		'.5 ms for this servo - low volume
	for k = 1 to 100
HWPWM ( 2, Cycletime, highTime ) ' chan 2 utilizes pin 9
		wait(18)
	next k
//
while bigstep < 9
	print "input a value of 0 to 7 "
	debugin bigstep
//
	hightime = bigstep * 200 +500

	T2_MR1 = 20000 - highTime + 1
	wait(12)
//  wait times could effect the chatter, had to experiment
	'wait(1000)
loop
'	highTime += 20
'	if (ms20 mod 10) = 0
'		print ms20, highTime
'	endif
'	if highTime > 1922 then stop
'next ms20
HWPWM ( 2, Cycletime, 700 )
print "done with PWM"
stop
//--------------------------------------------------
//		Manual testing, using 'bit banging' a port pin
//--------------------------------------------------
zeroing:
ms_var = 500		'.5 ms for this servo - low volume
	for k = 1 to 20
		out(9) = 1
		waitmicro(ms_var)
		out(9) = 0
		wait(18)	'just less than the max 20ms repetition rate
	next k
	stop
//
little_steps:
// searching for a 'little_step' value
for ms20 = 1 to 180 ' adjust upper limit to match the RC servo specification 
	for k = 1 to 10		'lets the servo settle
		out(9) = 1
		waitmicro(ms_var)
		out(9) = 0
		wait(18)	'just less than the max 20ms repetition rate
	next k
	
	ms_var += 11			// adjust as desired for 'little_step'
	if (ms20 mod 10) = 0
		print ms20, ms_var
	endif
next ms20
print "done"
[u]// use the Basic Tool - <STOP> button as needed[/u]
goto zeroing
end
 
Attachments
servo-test-BB.bas
(1.84 KiB) Downloaded 99 times



olzeke51
Posts: 414
Joined: Sat May 17, 2014 4:22 pm
Location: South Carolina

Re: RC servo testing

Post by olzeke51 »

Hey Y'all, - - heads up
I connected some more components to my board, and started getting random failures.
One status-type LED would light up from time to time - randomly.
Chased it down to the SERVO setup - mainly the +5v line - - preliminary troubleshooting.
Not sure if the USB power cable [also had been on the serial/dongle connector]
OR if the PWM under load from the servo was/is the issue
*
an analog multimeter is showing a varying current of 3.5-4 ma - hmmm
[~4.9+ volts]

olzeke51
Posts: 414
Joined: Sat May 17, 2014 4:22 pm
Location: South Carolina

Re: RC servo testing

Post by olzeke51 »

Y'all,
It seems that a .1uf (100nf) capacitor across the 5 & gnd at the arduino connector resolved the spurios triggers.
Only did about a 2 hour power on test.
Olzeke51

Post Reply