Code not working

This is my code to drive a servo and its not working

[code]#include <stdio.h> /* Standard input/output definitions /
#include <string.h> /
String function definitions */
#include <stdlib.h>
#include <math.h>
#include <windows.h>
#define pi 3.1415927
#define SERVOPORT “0x3F8”

void write_data_comport(void)
{

printf("Transmitting data\n");
FILE *filetrans;
filetrans = fopen("SERVOPORT", "w"  ); //Opens for communication
fprintf(filetrans,"#1 P2000 T1000\r");

Sleep(10000);
fclose(filetrans);
printf("Finished transmitting data\n");

}

int main ()
{
int f;
write_data_comport();

return 0;

}[/code]

Can you provide a bit more information? It seems like you are trying to use C to control the SSC-32 with servo connected to pin 1. Did you first try one of the free programs to control a servo via SSC-32 to ensure the hardware is setup properly?
lynxmotion.com/c-15-software.aspx

I have tried RIOS and FlowArm and LabView. Later i Tried to control it with C, Led on the board dint even blink, and dint make my servo on the robot work.

Need more information to be able help.

Things like: How is the SSC-32 powered? Do you have power going to the VL terminal, one or both? What jumpers do you have installed on the SSC-32?
This includes the jumpers associated with power VS1=VS2 and VL=VS1… Also Baud rate jumpers.

When you first power up the SSC-32, does the LED come on?

How is the SSC-32 connected up to your PC? By a hardware RS232 port or by some form of USB to RS232 converter? If converter which one? When you plug the converter in, does a Comm port show up on your PC? What type of PC? What OS? Assuming a windows machine, if you open up the Device Manager, does the Comm port show up? If so does it say something like the device is operational?

Have you tried Lynxterm, which you can download from the software section up on Lynxmotion.com? Have you configured it to the proper Comm port as well as to the baud rate your jumpers on the SSC-32 is set to? Does this work?

Pictures of setup often help.

Kurt

I suggest you try the simple lynxterm application for inital testing. Are you using a USB to serial adapter? Assuming you are connecting a pc to an ssc-32 via a serial connection, have you set the baud rates correctly?

Hardware set up was working for all the software Lynxterm, Flowarm and even Labview but it was not working for the program which was just to run a servo at the first pin. while i was debugging my program the LED did not blink. I am using RS-232, hence the program was written for that port. I have been using windows 7 and Microsoft Visual Studios 2010 for the programming. i can’t send u the pic of the setup. but i assure that the setup works for the software’s as mentioned above. and the arm works at the COM1 so the address was for the COM1 port.

Perhaps your problem is with your Microsoft Visual Studios 2010 program. A Microsoft Visual Studios 2010 forum might be able to evaluate your code

I am not sure if fopen will open up the comm port that way or not… I have not tried. But assuming that works, then my gut is telling me that the combination of "s is wrong for:

#define SERVOPORT "0x3F8" ... filetrans = fopen("SERVOPORT", "w" ); //Opens for communication
That is I am not sure that the precompiler will substitute for something contained in quotes…
That is maybe it should be:

filetrans = fopen(SERVOPORT, "w"  ); //Opens for communication

I have not played with Visual C in a long time, but with Visual Basic I would instead use system objects to open up a comm port. Example:

Using com1 As IO.Ports.SerialPort = _ My.Computer.Ports.OpenSerialPort(XBeeCommport, 38400, IO.Ports.Parity.None)
This does additional things like make sure the baud rate and handshaking are set appropriately…

Good Luck
Kurt