View previous topic :: View next topic |
Author |
Message |
cap110874 Guest
|
Trouble sending RS232 commands to a projector |
Posted: Thu Sep 03, 2009 7:57 am |
|
|
Hi
I am trying to send rs232 commands to turn a projector on and off.
If i test in a hyperterminal or similar I type
"~0000 1" and then hit returm on the keyboard.
This turns on the projector.
"~0000 2" and then hit returm on the keyboard.
This turns off the projector.
All ok from hyperterminal
but when i use me pic 18f2525 too generate nothing happens. Testing with hyperterminal i am getting the commands but the dont do anyrthing to the projector. Looks like the carriage return is not working but cant work out why.
Code being used is:
if (last == turnOn)
return;
fputc(0x0D, STREAM_UART); //c return
if (turnOn)
fprintf(STREAM_UART, "~0000 1");
else
fprintf(STREAM_UART, "~0000 2");
fputc(0x0D, STREAM_UART); //c return
last = turnOn;
}
break; |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Thu Sep 03, 2009 8:25 am |
|
|
U may get an answer if you post your
compiler version
and a short example of your code ( WITH FUSES FOR SURE )
that JUST shows your communication setup
and no other stuff.
PS make sure it compiles w/o err before posting ok ?
BTW- what HARDWARE are you using to interface the PIC to said projector?
can you connect the pic via a nullmodem to HYPER term and SEE what you are sending ?
can u post a PDF or JPG of the schematic ? |
|
|
cap 110874 Guest
|
output text issue |
Posted: Thu Sep 03, 2009 8:36 am |
|
|
Quote: | U may get an answer if you post your
compiler version |
Version 4.079
Quote: | and a short example of your code ( WITH FUSES FOR SURE )
that JUST shows your communication setup |
I only posted this bit as this is the only part with the issue.
The code compiles and works properly, and using a hyperterminal sends the commands as I expect. But when the projector (Optoma hd82) receives the commands nothing happens.
I know this is almost certainly to do with the carriage return because if I use a serial program for windows like hyperterminal I can type the command to turn on ie ~0000 1 and then hit enter and the projector turns on. If I send the string from the hyper terminal ~0000 1 <CR> nothing happens, seems to only work when I hit return on the keyboard.
I as wanting to know if there were any other ways of sending the carriage return key via the code to simulate hitting the Return key. I'm currently sending putc 0x0D.
Thanks |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Thu Sep 03, 2009 8:41 am |
|
|
Format strings
|
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Thu Sep 03, 2009 11:18 am |
|
|
hello,
You should find out if your projector uses flow control...
(pins 1,4,6,7,8) on the DB9 Cable).
You can figure this out by making your own cable, using only pins
2,3, and 5..... null modem cable... as mentioned before.
I had a similar problem with a cellphone.
Also, check if hyperterminal is sending extra characters.
Use Siow instead of hyperterminal. (siow comes with the CCS compiler)
This is a basic solution... so simple, it gets overlooked often.
Hope this helps.
gabriel _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Thu Sep 03, 2009 3:25 pm |
|
|
Try sending commands from the PC using a macro vs. typing character by character. Maybe the projector needs spacing between characters to work or its UART buffer overflows. If you have a scope or simple logic analyzer you can see character spacing.
Also try changing your baud rate by +/- 2%. Maybe the PIC or projector baud rate clock is a little off. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
|