View previous topic :: View next topic |
Author |
Message |
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Mon Jun 06, 2016 8:18 am |
|
|
One last comment: Resolution and "position repeatability" are BIG factors in these cheap hobby servos.
I found during testing of the project where i (foolishly) started with these cheap gadgets that there was a LOT of slop when it came to trying to recover a previous position even using a very accurate, crystal time based, pulse position command but finding that the actual goto-position could easily be off by much more than a degree. Let me add that the greater the load the worse the repeat position error in my work.
HITEC were the best brand i found BTW. |
|
|
gjs_rsdi
Joined: 06 Feb 2006 Posts: 468 Location: Bali
|
|
Posted: Mon Jun 06, 2016 10:17 am |
|
|
Quote: | HITEC were the best brand i found BTW |
I agree with you asmboy
Also regarding repeat ability, can have big changes on temperature changes, external environment and internal heat.
I am working with Hitec servo's from the time they were considered junk because Korean products were considered low quality.
Futaba, Multiplex, JR are also top brands
Best wishes
Joe |
|
|
samuel
Joined: 04 May 2016 Posts: 14
|
how to return from an interrupt routine in ccs |
Posted: Tue Jul 26, 2016 8:14 am |
|
|
Hello! to everyone in the forum.
I am trying to control the left and write rotation of my servo using port B interrupt. I want that when the interrupt occurs, the servo should rotate 180 degrees to the right and then back to the left, and then STOP.
However what i have been getting so far in my Proteus simulation is a continuous rotation of the servo left to right without stopping. Please go through the code and point out or if possible correct me where i have gone wrong. Thanks.
Code: |
#include <fnalyearproject01.h>
#fuses HS, NOWDT, PUT, NOPROTECT
#use delay(crystal=8000000)
void turn_servo(){
output_high(PIN_A0);
delay_ms(50);
output_low(PIN_A0);
delay_ms(1000);
output_high(PIN_A0);
delay_ms(1.7);
output_low(PIN_A0);
delay_ms(1000);
return;
}
#INT_RB
void rb_isr(void)
{
clear_interrupt(INT_RB); // Clear RB port change interrupt flag bit
turn_servo();
delay_ms(1);
}
void initializeServo(){
output_high(PIN_A0);
delay_ms(1.7);
output_low(PIN_A0);
}
void main()
{
set_tris_b(0xF0);
clear_interrupt(INT_RB); // Clear RB port change interrupt flag bit
enable_interrupts(INT_RB); // Enable RB port change interrupt
enable_interrupts(GLOBAL); // Enable all unmasked interrupt
initializeServo();
while(TRUE) ; // Endless loop
}
|
|
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Tue Jul 26, 2016 12:19 pm |
|
|
YOU CAN'T TRUST PROTEUS...
BUILD REAL HARDWARE - THEN COME ON BACK...... |
|
|
gjs_rsdi
Joined: 06 Feb 2006 Posts: 468 Location: Bali
|
|
Posted: Tue Jul 26, 2016 2:12 pm |
|
|
Regarding Proteus:
http://www.ccsinfo.com/forum/viewtopic.php?t=47549
1. Servos are usually +/- 45 or +/- 60 degree, find one of +/-180
The pulse should be between 1020us to 2020us, middle 1520us.
Cycle 20ms.
2. Your microcontroller? Not defined
3. Compiler?
4. Post a program that compiles.
Best wishes
Joe |
|
|
samuel
Joined: 04 May 2016 Posts: 14
|
|
Posted: Thu Aug 18, 2016 4:29 pm |
|
|
hello!!! please check this code i actually loaded it but it did not work
what i got was just a servo tick.
what i did was to generate a 20 ms pulse by putting the pin B1 on for the duty cycle and off for the remaining time.
1020 + 18980= 20 ms
2020 + 18980= 20 ms
i am using MG90S servo motor. please i need real help for this thing to work
thanks!!!
Code: |
#include <16F877.H>
#fuses NOWDT, NOPROTECT
#use delay(clock=4000000)
//#USE PWM(OUTPUT=PIN_C1, FREQUENCY=50Hz )
#define NUM_PULSES 10
//======================================
void main()
{
int16 count=0;
//int16 period=1246;
//setup_ccp1(CCP_PWM); //configures CCP1 as a PWM
//setup_timer_2(T2_DIV_BY_16, period, 1); //T2_DIV_BY_1 IS THE PRESCALER, PERIOD OF OUR PM,P
int8 final=NUM_PULSES;
while(TRUE)
{
if(count==final){
while(--count >= 1){
output_high(PIN_B1);
delay_us(1020);
output_low(PIN_B1);
delay_us(18980);
}
}
else {
output_high(PIN_B1);
delay_us(2020);
output_low(PIN_B1);
}
delay_us(18980);
count++;
}
}
|
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9286 Location: Greensville,Ontario
|
|
Posted: Thu Aug 18, 2016 6:33 pm |
|
|
your main() makes no sense to me
first you decrement the variable 'count' then you increment it...
BTW int16 is both +ve AND -ve numbers in CCS C. I prefer to use unsigned intxx for 'counters'...0,1,2,3.......
make your test code simpler
do forever...
turn servo bit on,
delay for 1ms,
turn servo bit off,
delay for 19ms
while true
that should turn servo one direction when plugged in
change delay to 2ms, 18 ms and it'll go the other way
You should use an oscilloscope to LOOK at the waveform on the 'servo bit pin'. If you don't, use an LED and 470r. A good eye can see the difference in LED intensity.
If you don't have ascope, save your money,even a 30 year old analog 20MHz scope WILL work fine for you !
Also BASIC 1HZ LED program, does it work ??
Jay |
|
|
|