Shop OBEX P1 Docs P2 Docs Learn Events
Help help!!!parallax servo controller no response!!! — Parallax Forums

Help help!!!parallax servo controller no response!!!

jeffewongjeffewong Posts: 7
edited 2007-11-07 14:57 in General Discussion
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--);
}

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-11-02 04:31
    Can't help you with the PIC program, but a couple of suggestions:

    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.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-11-02 04:33
    Another comment:

    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.
  • jeffewongjeffewong Posts: 7
    edited 2007-11-02 10:01
    thanks for ur suggestion... i will try your suggested solution.thank you very much!!
  • jeffewongjeffewong Posts: 7
    edited 2007-11-06 01:37
    1. how to connect the pull up resistor to my PSC?is it as pull up at the +5v at PSC?
    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
  • Mike GreenMike Green Posts: 23,101
    edited 2007-11-06 01:50
    1) The pullup goes from the PSC signal line to +5V (it pulls up the input line to +5V in the absence of a signal).

    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.
  • jeffewongjeffewong Posts: 7
    edited 2007-11-06 02:20
    1)ya,i also use an external circuitry (like what you have described here) to send the signal from my laptop to my PSC. I copied the schematic of this circuitry from the parallax forum. Then i use Parallax Servo Control Interface to control my PSC. However, Parallax Servo Control Interface cannot detect my PSC.

    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 GreenMike Green Posts: 23,101
    edited 2007-11-06 02:42
    Yes, that's how the pullup resistor is connected.
  • jeffewongjeffewong Posts: 7
    edited 2007-11-06 02:46
    Thanks for your help!
  • jeffewongjeffewong Posts: 7
    edited 2007-11-07 06:07
    thanks Mike,after adding a pull up resistor, my PSC works. The RS232 converter using transistor 3904 and 3906 cannot work well. The data sent was wrong. Then i use MAX232, the data sent is correct. And now i can control the servo using Parallax Servo Interface. Your help really appreciated.
  • ZootZoot Posts: 2,227
    edited 2007-11-07 14:57
    Just one comment for others who may read this -- the serial I/O pin on the PSC uses the on-board SX's internal pullup for "open true". This is why you generally don't see an external pullup specified in the Parallax documentation. That said, the internal pullup is weak. I ran this down with Chris Savage last year (the pullup and series resistors on open-true Parallax products like the Ping and PSC are not documented, per se, that I know of).

    Mike, do you think noise and such was affecting jeffewong more than is usual?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
Sign In or Register to comment.