Did you make port B digital?
What PIC?
What CONFIG settings?
Do you want default oscillator settings?
What is RX_inp and SERVO1?
Do you want X1 to have initial value?
Robert
Did you make port B digital?
What PIC?
What CONFIG settings?
Do you want default oscillator settings?
What is RX_inp and SERVO1?
Do you want X1 to have initial value?
Robert
Last edited by Demon; - 15th June 2014 at 21:00.
Hello all well
I have a program on the PC that controls the motor ac
I trackbar that for servo motor with avariaves 700-2300
This half confused,
@ DEVICE PIC16F876A
@ DEVICE PIC16F876A,WDT_ON
@ DEVICE PIC16F876A,PWRT_ON
@ DEVICE PIC16F876A,PROTECT_off
@ DEVICE PIC16F876A,XT_OSC
define OCS 4
ADCON1 = 7
TRISC=%10000000:PORTC=%10000000
TRISA=%11111111:PORTA=%11111111
TRISB=%00000000:PORTB=%00000000
SYMBOL SERVO1=PORTB.0 'SERVO1
SYMBOL RX_INP=PORTC.7 'RF
Last edited by cesar35; - 15th June 2014 at 21:18.
Hi,
A couple of issues of the bat:
If, by servo, you mean your typical RC servo it's not enough to send it one pulse. If you want it to move you need to send it pulses, usually at around 50Hz repetition rate, for at least as long as it tkaes for the servo to move to the new position but ideally you send it pulses all the time so that it can keep its position. As far as I can see you're only sending a single pulse - I don't think that's going to work.
You have POS declared as a BYTE but you're trying to store a value between 700 and 2300 - that's not going to work.
pauseus X1*10:X1 = pos
A typical RC servo want pulses with a width of 1-2ms. If you assign 2000 to POS (after changing it to a WORD) you're going to get a pulsewidth of 20000us or 20ms - I don't think that's going to work.
If you change POS to a WORD check the documentation of SERIN to see if it can handle WORD variables directly or if you need to give it the high and low byte separately. And, finally, I'm not sure what the purpose of copying POX to X1 but if there's a specific reason for it make sure you change X1 to WORD as well.
/Henrik.
Thanks for the reply
I made you the servant said he moved to the left and and stop.
I cho I'm really confused.
Could you tell me what is wrong in this program@ DEVICE PIC16F876A
@ DEVICE PIC16F876A,WDT_ON
@ DEVICE PIC16F876A,PWRT_ON
@ DEVICE PIC16F876A,PROTECT_off
@ DEVICE PIC16F876A,XT_OSC
define OCS 4
ADCON1 = 7
TRISC=%10000000:PORTC=%10000000
TRISA=%11111111:PORTA=%11111111
TRISB=%00000000:PORTB=%00000000
SYMBOL SERVO1=PORTC.0 'SERVO1
SYMBOL RX_INP=PORTC.7 'RF
RX VAR BYTE
POS VAR word
X1 VAR word
PROG:
serin2 RX_inp,16468,[wait("PC"),RX,POS]
IF RX = "A" THEN FRE
IF RX = "B" THEN TRA
IF RX = "C" THEN ESQ
IF RX = "D" THEN DIr
if RX = "E" THEN PAR
IF RX = "X" THEN SERV
GOTO PROG
FRE:
PORTB.0 = 0
PORTB.1 = 1
PORTB.2 = 1
PORTB.3 = 0
GOTO PROG
TRA:
PORTB.0 = 1
PORTB.1 = 0
PORTB.2 = 0
PORTB.3 = 1
GOTO PROG
ESQ:
PORTB.0 = 1
PORTB.1 = 0
PORTB.2 = 1
PORTB.3 = 0
GOTO PROG
DIR:
PORTB.0 = 0
PORTB.1 = 1
PORTB.2 = 0
PORTB.3 = 1
GOTO PROG
PAR:
PORTB.0 = 0
PORTB.1 = 0
PORTB.2 = 0
PORTB.3 = 0
GOTO PROG
SERV:
high SERVO1
pauseus X1*10:X1 = pos
low SERVO1
GOTO PROG
Hi,
I thought I did bring up least a couple of things that might be wrong.Could you tell me what is wrong in this program
You've corrected the variable size, that's good.
But,
* You are still doing the times 10 thing in the SERV subroutine, if the PC sends 700 you'll get a 7ms delay, what's the reason for it?
* You are still only sending a single pulse to the servo
* I took a brief look at the manual and as far as I can see SERIN2 can not directly handle WORDs, you need to split it, SERIN2 RX_inp,16468,[wait("PC"),RX,POS.HighByte, POS.LowByte] watch out for big vs little endian. Which brings me to the last thing...
* How is the PC sending the data? If it's sending it as ASCII, ie "1","2","3","4" instead of two bytes 4,210 then you need to use the DEC modifier in the SERIN2 statement.
/Henrik.
Hello Henrik.
As you said I have to send high and low along with varaves between 700 and 2300.
did not know that controls a servo was a yes.
I am very grateful to you.
Hello Henrik
And I do not know much about PicBasic Pro.
To do piquenos project I do.
I never did a project to control a servo motor by pc
You can explain me better.
I have change the vb.net program for this to work.
thank you
Bookmarks