Help help!!!parallax servo controller no response!!!
hi, i use dsPIC6014A as my microcontroller and use UART to communicate with the parallax servo controller. i send the correct baud rate(2400),(no parity,8 bit,2 stop bit) to the servo controller but it doesnt hv response. each time when i press the reset button on servo controller, the servo motor will go to 0 degree(can move). i have check the data that send to servo controller using serial communication with laptop. the baud rate and the data both correct.i check the serial in pin on the parallax servo controller. the data can be detected also. so is it what else the setting that i did not to set? i have check other connection also, but i cant found any problem, i suspect the ic is malfunction already, is it possible? i hope can receive your reply as soon as possible.thanks you
#include <p30f6014a.h>
//==============================================================
//Function prototyte
//==============================================================
void send_data(unsigned char command);
void delay(unsigned int time);
//==============================================================
//·configuration bit
//==============================================================
_FOSC(CSW_FSCM_OFF & XT_PLL4);
_FWDT(WDT_OFF);
_FBORPOR(PBOR_OFF & MCLR_EN);
#define·LED·LATCbits.LATC13·//rc13 output
#define sw2 PORTCbits.RC1······ //input
#define sw3 PORTCbits.RC2······ //input
int main (void)
{
·//io
·TRISCbits.TRISC13=0;·//RC13 output
·TRISCbits.TRISC1=1;··//RC1 input
·TRISCbits.TRISC2=1;···· //set RC2 input
·TRISCbits.TRISC3=1;···· //set RC3 input
·PORTC = 0xffff;
·//UART
·U1MODE=0x8001;···//enable uart,no parity, 8 bit data, 2 stop bit
·U1STA=0x8400;···//tx enable, interrupt when a char is received
·U1BRG=389;····//set baud rate as 2400kbs;
·IFS0bits.U1TXIF=0;··//clear tx interrupt flag
·IEC0bits.U1TXIE=0;··//enable tx interrupt
·while(1)
{
·LED=1;
·if(!sw2)
·{
··LED=0;········· //LED on(active low)
·send_data('!');··//header
·send_data('S');
·send_data('C');
·send_data(0x01);······· //channel
······· send_data(0x3C);······· //ramp
·send_data(0xFA);······· //position
·send_data(0x00);
·send_data(0x0D);······· //terminator
·delay(500);
·}
}
return 0;
}
void send_data(unsigned char command)
{
·U1TXREG=command;···· //move to transmitt buffer
·while(IFS0bits.U1TXIF==0);· //wait interrupt set to 1
·IFS0bits.U1TXIF=0; // clear interrupt flag
}
void delay(unsigned int time)
{
·for(;time>0;time--);
}
#include <p30f6014a.h>
//==============================================================
//Function prototyte
//==============================================================
void send_data(unsigned char command);
void delay(unsigned int time);
//==============================================================
//·configuration bit
//==============================================================
_FOSC(CSW_FSCM_OFF & XT_PLL4);
_FWDT(WDT_OFF);
_FBORPOR(PBOR_OFF & MCLR_EN);
#define·LED·LATCbits.LATC13·//rc13 output
#define sw2 PORTCbits.RC1······ //input
#define sw3 PORTCbits.RC2······ //input
int main (void)
{
·//io
·TRISCbits.TRISC13=0;·//RC13 output
·TRISCbits.TRISC1=1;··//RC1 input
·TRISCbits.TRISC2=1;···· //set RC2 input
·TRISCbits.TRISC3=1;···· //set RC3 input
·PORTC = 0xffff;
·//UART
·U1MODE=0x8001;···//enable uart,no parity, 8 bit data, 2 stop bit
·U1STA=0x8400;···//tx enable, interrupt when a char is received
·U1BRG=389;····//set baud rate as 2400kbs;
·IFS0bits.U1TXIF=0;··//clear tx interrupt flag
·IEC0bits.U1TXIE=0;··//enable tx interrupt
·while(1)
{
·LED=1;
·if(!sw2)
·{
··LED=0;········· //LED on(active low)
·send_data('!');··//header
·send_data('S');
·send_data('C');
·send_data(0x01);······· //channel
······· send_data(0x3C);······· //ramp
·send_data(0xFA);······· //position
·send_data(0x00);
·send_data(0x0D);······· //terminator
·delay(500);
·}
}
return 0;
}
void send_data(unsigned char command)
{
·U1TXREG=command;···· //move to transmitt buffer
·while(IFS0bits.U1TXIF==0);· //wait interrupt set to 1
·IFS0bits.U1TXIF=0; // clear interrupt flag
}
void delay(unsigned int time)
{
·for(;time>0;time--);
}
Comments
1) First see if you can get the version number back from the PSC before you try to control a servo.
2) You didn't explain how you connected the PSC. You do need a pullup resistor to +5V. A value like 4.7K will work fine. The serial connection needs to have "true" logic. In other words, the idle logic level needs to be high (+5V) with the start bit going to low (ground).
3) If you still have problems, try controlling the PSC from your PC. You'll need either a USB to TTL converter or an RS-232 to TTL converter depending on your serial port on the PC. Usually these put out "true" logic levels.
Please do not post the same message on two different forums. It's against forum rules and it makes a mess if people start replying to both messages.
Go back and delete the other message using the X box in the upper right corner of the message box.
2. My uart start bit is from Hight(5V) to low, is no transmittion, the tx will be at +5V.
3. i use the software PSCI from parallax and connect my laptop to(using USB to RS232 converter) my PSC via the schematic provided in the forum,but i cannot get the version number back from the PSC. The message display is "PSC not found", then what is the possible causes?
connection:
GND
Black
+5V
Red
dsPIC tx
serial in PSC
2) That's correct. The idle state of the line is high (+5V).
3) You cannot use a USB to RS232 converter and expect to receive information back from the PSC.
The transmit line from the converter won't turn off and will prevent the PSC from returning information
and theoretically could damage both devices. You can use external circuitry to allow this (a pair of
transistors, one PNP and the other NPN along with a couple of resistors to make an inverter and open-
collector driver.· You can just send data one way to the PSC.· You just can't send any command that
will cause a response to be sent back.
2) so i think i will add a pull up resistor and try again.
is it the connection is like this?
Ground
Black
+5V
RED
+5v
|
4.7k pull up resistor
|
Tx
|
signal for PSC
Thank you very much!
Mike, do you think noise and such was affecting jeffewong more than is usual?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST