View previous topic :: View next topic |
Author |
Message |
gmelcer
Joined: 19 Dec 2005 Posts: 3
|
EX_ADMM |
Posted: Mon Dec 19, 2005 6:32 pm |
|
|
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? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Dec 19, 2005 6:55 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
gmelcer
Joined: 19 Dec 2005 Posts: 3
|
|
Posted: Tue Dec 20, 2005 12:39 pm |
|
|
thanks, i will give that a try. |
|
![](templates/subSilver/images/spacer.gif) |
gmelcer
Joined: 19 Dec 2005 Posts: 3
|
|
Posted: Thu Dec 22, 2005 1:52 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Thu Dec 22, 2005 6:11 pm |
|
|
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? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Dec 22, 2005 6:20 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Thu Dec 22, 2005 9:10 pm |
|
|
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!! |
|
![](templates/subSilver/images/spacer.gif) |
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Fri Dec 23, 2005 8:10 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
jbmiller Guest
|
pic to pc |
Posted: Fri Dec 23, 2005 9:47 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Sat Dec 24, 2005 12:05 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Sat Dec 24, 2005 8:11 pm |
|
|
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!! |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Mon Dec 26, 2005 9:43 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
![](templates/subSilver/images/spacer.gif) |
sonicdeejay
Joined: 20 Dec 2005 Posts: 112
|
|
Posted: Sat Jan 14, 2006 2:30 am |
|
|
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](images/smiles/icon_smile.gif) |
|
![](templates/subSilver/images/spacer.gif) |
|