CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

EX_ADMM

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
gmelcer



Joined: 19 Dec 2005
Posts: 3

View user's profile Send private message

EX_ADMM
PostPosted: Mon Dec 19, 2005 6:32 pm     Reply with quote

Hi, I am looking for something to use to graph the values of a changing voltage. I plan to use a modified version of EX_ADMM.C to do this. However, I am still a beginner in using microcontrollers. I have hooked up (+5v) to VDD, (+5v) to MCLR, wires connecting pins 8 and 11, wires connecting 7 and 12, a 20mhz crystal oscillator to OSC1 and OSC2 with 22pf ceramic capacitors which are grounded, and GND to VSS. I am using pins 5, 3, and 2 of a 9 pin RS-232 port on a laptop computer in an attempt to communicate with the picmicro. Those pins are connected to TX, RX, and GND of the Picmicro. To generate an analog signal I am just using a small dc motor which I turn by my hand. The DC motor is connected to pin2 (A0) of picmicro. The settings I used with HyperTerminal with no success were baud= 9600, Data bits = 0, parity = None, Stop bits =1, and flow control = none. Why is this not working? Any suggestions?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Dec 19, 2005 6:55 pm     Reply with quote

Code:
I am using pins 5, 3, and 2 of a 9 pin RS-232 port on a laptop computer in an attempt to communicate with the picmicro. Those pins are connected to TX, RX, and GND of the Picmicro. 

This is not going to work. You might have damaged your PIC.
The laptop likely uses RS232 levels, which means the idle state for
the Tx line from the laptop will be approximately -10v.

If you're going to do a direct connection, you need to use a 22K series
resistor on the Tx line coming from the laptop (this is pin 3 on the
DB-9 connector on the rear of the laptop). This will limit the current
sufficiently so that the protection diode of the PIC can do it's job without
being destroyed. You also need to use the INVERT directive with
your #use rs232() statement. This will create a software UART.

If want to use the hardware UART, you need to get a MAX232-type chip
to use on your PIC board, to convert the TTL levels coming out of the
PIC into RS232 levels.
gmelcer



Joined: 19 Dec 2005
Posts: 3

View user's profile Send private message

PostPosted: Tue Dec 20, 2005 12:39 pm     Reply with quote

thanks, i will give that a try.
gmelcer



Joined: 19 Dec 2005
Posts: 3

View user's profile Send private message

PostPosted: Thu Dec 22, 2005 1:52 pm     Reply with quote

Hi, I tried adding a 22k resistor in series with the TX line but I am stilling not seeing any results on the computer. When i looked at the line with a oscilliscope I do see some sort of signal so i do believe it is trying to output some sort of data. I am not sure if this is useful for you but I included a copy of the code that I am using. If anyone could help me I would highly appreciate it.

#include <18F452.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) // Jumpers: 8 to 11, 7 to 12



void main() {

int i, value, min, max;

printf("Sampling:");

setup_port_a( ALL_ANALOG );
setup_adc( ADC_CLOCK_INTERNAL );
set_adc_channel( 0 );

do {
min=255;
max=0;
for(i=0; i<=30; ++i) {
delay_ms(100);
value = Read_ADC();
if(value<min)
min=value;
if(value>max)
max=value;
}
printf("\n\rMin: %2X Max: %2X\n\r",min,max);

} while (TRUE);
}

thanks george
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Dec 22, 2005 2:03 pm     Reply with quote

From my previous post:
Quote:
You also need to use the INVERT directive with
your #use rs232() statement. This will create a software UART.


Read this thread for more information:
http://www.ccsinfo.com/forum/viewtopic.php?t=19062&highlight=22k
Guest








PostPosted: Thu Dec 22, 2005 6:11 pm     Reply with quote

I included the "INVERT" directive and reprogrammed the PIC. I still do not get anything on the computer? I unplugged the RX wire from the picmicro controller as well since it is not being used. After putting in the "INVERT" directive the TX Pin is at -5V. Is that good? any other ideas?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Dec 22, 2005 6:20 pm     Reply with quote

Quote:
After putting in the "INVERT" directive the TX Pin is at -5V. Is that good? any other ideas?

This means you have it connected to the wrong pin on the DB9.

1. Pin C6 on the PIC must go to pin 2 on the DB9 connector on the PC.

2. You must also have a wire between Ground on your board and pin 5
on the PC's DB9 connector.
asmallri



Joined: 12 Aug 2004
Posts: 1635
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Thu Dec 22, 2005 9:10 pm     Reply with quote

Anonymous wrote:
I included the "INVERT" directive and reprogrammed the PIC. I still do not get anything on the computer? I unplugged the RX wire from the picmicro controller as well since it is not being used. After putting in the "INVERT" directive the TX Pin is at -5V. Is that good? any other ideas?


It is never a good idea to use this low cost (until you blow the PIC) method of interfacing to a PC. I recommend using a real level converter like a MAX232 or similar.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Fri Dec 23, 2005 8:10 am     Reply with quote

For debug, I've never used a "real" level converter. 3 years, working every weekday, I've yet to blow a pic to my knowledge.
Just my 2cents. Don't want to fight, or suggest that this is what you should do. Just giving you my statistics.
btw. for me, PICs are very easy to replace.
I have many floating around here.
jbmiller
Guest







pic to pc
PostPosted: Fri Dec 23, 2005 9:47 am     Reply with quote

First thing I'd do is tie pins 2 and 3 of your serial cable together and verify that Hyperterminal is working OK. Typing on the PC keyboard should be echoed onto the screen.
I know a small, 'baby' step, but sometimes it's best to verify that the 'little' things that should work, really are !
been there-done that as the saying goes..

Isn't pin 2 of a de-9 RCv and not Xmt( as in a DB-25 ) ? That can be a 'gottcha' too.....

Jay
Guest








PostPosted: Sat Dec 24, 2005 12:05 pm     Reply with quote

Hi, I have made sure all the pins and everything are hooked up correctly. I have tried just about everything so I decided to change the code around to just print a value to the rs232 line everything 1/10 of a second. I disabled all the ADC stuff. I am just trying to get the PIC to talk to the computer. When I looked at pin C6 though nothing is coming out of it no matter what I do. It shouldn't matter whether or not the serial line is connected properly for something to at least come out of the pin? When I search this stuff on google it seems like everyone is using the MAX232 chip? Should I be using that? Any suggestions? Thanks for your help. GEORGE
asmallri



Joined: 12 Aug 2004
Posts: 1635
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Sat Dec 24, 2005 8:11 pm     Reply with quote

treitmey wrote:
For debug, I've never used a "real" level converter. 3 years, working every weekday, I've yet to blow a pic to my knowledge.


That's interesting. I have a few questions..

Is your interface just a resistor?

Have you ever observed latchup in this configuration?

Have you observed any erratic behaviour when the PIC's power source is disconnected but the cable to the PC is still connected and the PC is powered up?

Conversly, ave you seen any strange behaviour when the PIC is powered up and connected to the PC but the PC is powered down?

Quote:
btw. for me, PICs are very easy to replace.
I have many floating around here.


I use SMD devices almost exclusively these days - so replacing a PIC is a problem.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Guest








PostPosted: Mon Dec 26, 2005 9:43 am     Reply with quote

my interface for the TX line is just a 22k resistor in series. The RX line is connected directly to the PIC. I don't believe I have ever observered "latchups" (I am just an ameture hobbiest right now so i am not that expirenced but I am currently a freshman majoring in electrical and computer engineering). I do not recall seeing any odd behavior on the PC's part or the PIC part. I think I need to update the version of Hyperlink on the laptop which I a using because it doesn't let you input data. thanks
Guest








PostPosted: Mon Dec 26, 2005 10:07 am     Reply with quote

could this be the problem?
http://www.airborn.com.au/rs232.html
sonicdeejay



Joined: 20 Dec 2005
Posts: 112

View user's profile Send private message

PostPosted: Sat Jan 14, 2006 2:30 am     Reply with quote




Will it works....if i connect..that way...I am using 18f2331/2431

PIN 17(TX) --------> RX of RS232
PIN 18(RX) --------> TX of RS232


thanx

sonic
Smile
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group