PDA

View Full Version : Servo Slower?



actionplus
- 26th August 2004, 15:48
I am trying to slow down a servo. Let me explain.
I am using a Futaba radio with a 3rd channel as a switch. When I turn the switch on, the receiver gets the signal and moves the servo to a certain position.

What I want to do is to do the same thing but in a slower rate.SLOW MOTION!!

Is there anyway to take the signal coming out of the receiver,feeding it into a PIC12F ro something and then to the servo?

Thanks

Ingvar
- 26th August 2004, 17:10
Hi,

This is what popped right into my head when i read your post. I haven't tried it but it compiles. All you need to do is declare Input and Output pins, you'll also need to find a "Samples" value that fits your application. I seem to remember that a normal signal from a radio idles low and pulses high at 50Hz. If i'm wrong and your radio outputs a low signal and idles high, you should change "ActiveState to zero and "LOW OutputPin" to "HIGH OutputPin".


InputPin VAR GPIO.0
OutputPin VAR GPIO.1
ActiveState CON 1
InputSignal VAR WORD
FilteredSignal VAR WORD
Samples CON 20

LOW OutputPin
PULSIN InputPin, ActiveState, FilteredSignal
WHILE 1
PULSIN InputPin, ActiveState, InputSignal
FilteredSignal = FilteredSignal * (Samples - 1)
FilteredSignal = FilteredSignal + InputSignal
FilteredSignal = FilteredSignal / Samples
PULSOUT OutputPin, FilteredSignal
WEND

.... this little program will slow your servo down. Increasing "Samples" will slow thing down even more, 1 will give no delay.

/Ingvar

actionplus
- 27th August 2004, 15:46
Thanks

actionplus
- 27th August 2004, 15:56
I am trying to understand what code is doing.

PULSIN InputPin, ActiveState, FilteredSignal
'(receives the pulse from inputpin. What does Activestate do? You have it CON 1)

WHILE 1
PULSIN InputPin, ActiveState, InputSignal
FilteredSignal = FilteredSignal * (Samples - 1)
'(FilteredSignal =FilteredSignal multiplited by(20-1)

FilteredSignal = FilteredSignal + InputSignal
'(Then the same signal is added to the Inputsignal)

FilteredSignal = FilteredSignal / Samples
'(Then this signal is divided by 20)
PULSOUT OutputPin, FilteredSignal
'(results to outputpin)
WEND

actionplus
- 27th August 2004, 15:59
activestate is to set the idle high.
Sorry, I missed that.

actionplus
- 31st August 2004, 02:01
I am getting error when I try to program(ICprog) but getting error for internal osc.
How can set it to use internal Osc?

Melanie
- 31st August 2004, 02:20
FAQ Section... Presetting Configuration Fuses (PIC Defines) into your Program.

Ingvar
- 31st August 2004, 08:27
Hi Actionplus,

Did you figure out how the program works?

/Ingvar

actionplus
- 31st August 2004, 15:56
yes, kind of know what it is doing. just that it compiles fine. but when using ICprog to burn, it is saying that it cannot find calibration for it and if I want to replace with 3FFFF. I click ok, still nothing. says I have error.

Try inserting a Define OSC 4 and still error.
I am trying to get out of using a crystal for now. at least to learn how not use a xtal.

actionplus
- 31st August 2004, 16:02
Do I have type in all of this?

Example: Typical Settings for a 16F628…

@ DEVICE pic16F628, INTRC_OSC_NOCLKOUT
' System Clock Options
@ DEVICE pic16F628, WDT_ON
' Watchdog Timer
@ DEVICE pic16F628, PWRT_ON
' Power-On Timer
@ DEVICE pic16F628, MCLR_OFF
' Master Clear Options (Internal)
@ DEVICE pic16F628, BOD_ON
' Brown-Out Detect
@ DEVICE pic16F628, LVP_OFF
' Low-Voltage Programming
@ DEVICE pic16F628, CPD_ON
' Data Memory Code Protect
' Set to CPD_OFF for Development Copy
' Set to CPD_ON for Release Copy
@ DEVICE pic16F628, PROTECT_ON
' Program Code Protection
' Set to PROTECT_OFF for Development Copy
' Set to PROTECT_ON for Release Copy

********************************************
This what I had on mine

@ DEVICE pic12F629, INTRC_OSC_NOCLKOUT
' System Clock Options
@ DEVICE pic12F629, WDT_ON
' Watchdog Timer

Will this be fine? I was just trying to blink a LED to find out if it worked this way, but still the same message. On the programmer, what setting should I put.

Example:
IntGP4?Tried this
RCGP4?Tried this
XT? I am sure not this
HS? I am sure not this

Anything else I am overseeing?

Ingvar
- 1st September 2004, 08:36
Sorry, i've never used ICprog. Perhaps you should start a new thread .......

Melanie
- 1st September 2004, 09:38
>> Do I have type in all of this?

No you don't, but if you miss out something important then you'll be stuck wondering why things don't work...

>> This what I had on mine...

and something important is the MCLR setting... I don't see it with what you had...

It's no big deal setting up your device header PROPERLY once, and then you've got it for life. But if you want to save yourself those thirty seconds and spend a few hours wondering why your program doesn't work- hell, who am I to suggest any different.

actionplus
- 4th September 2004, 05:03
I am still getting the same error. Now I am really confused. It keep saying that there is no Calibrated Oscillator Value and if I want to replace from 3FFF.

I typed in all the lines that you suggested Melanie. Anything else I should look at?

Melanie
- 4th September 2004, 07:59
Insert this at the beginning of your program...

Define OSCCAL_1K 1

See if this does the trick.

The calibration value is located at address $3FF (3FFh) and the above statement loads it (see PBP manual 2.5.1 on page 13).

I don't have ICprog, but find it strange that it causes you fail to program just because you've not loaded the Factory Calibration value which is pretty irrelevant at best.

Acetronics2
- 4th September 2004, 13:56
Hi, Everybody,

As i had this problem before ... here are some lines:


'************************************************* ****************************
'Lissage du mouvement - motion smoothing
'************************************************* ****************************

Echantillon = 0
Servoposc = Servopos

IF Servopos > ( Servoposold + 1 ) THEN

Servopos = ( Servoposold + 1 ) MIN Servoposc


ENDIF

IF Servopos < ( Servoposold - 1 ) THEN

Servopos = ( Servoposold - 1 ) MAX Servoposc

ENDIF

Limit:

LOW Servo
PULSOUT Servo,Servopos

Servoposold = Servopos

IF NOT ( Echantillon / 10 ) THEN

Echantillon = Echantillon + 1

PAUSE 20

GOTO Limit

ENDIF


There are 2 Things there : first I limit the "growth" of the signal to be sent and second, I only send one pulse every 10 input pulse ...

so, it's the minimum speed for "pseudo continuous" travel of the servo ... after, steps are too much visible.

With a 20 Mhz Clock It would be better ( resolution is 5 times better ... )

The "LOW" just before pulsout is to ensure a good "1" pulse ... just try to connect your servo with power on, and you'll understand ...

Good luck
Alain