Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

[SOLVED] RS232 to TTL using max232

Status
Not open for further replies.

saesaria

Member level 1
Joined
Jun 13, 2011
Messages
34
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Location
Indonesia
Activity points
1,538
Hi!
I designed rs232 to TTL using max232, I got the schematic from the internet. Then I tried it but it doesn't work at all. The schematic I made is shown as below.

Screenshot.png

I tried to connect AVR with PC and check the communication in hyperterminal, but no responding. Is there anything I missed?

The following is the code I am using
Code:
char uart_rd;

void main() {

  UART1_Init(9600);               // Initialize UART module at 9600 bps
  Delay_ms(100);                  // Wait for UART module to stabilize

  while (1) {                     // Endless loop
   if (UART1_Data_Ready()) {      // If data is received,
     uart_rd = UART1_Read();      // read the received data,
     UART1_Write(uart_rd);        // and send data via UART
    }
  }
}
thanks
 

alexxx

Advanced Member level 4
Joined
Apr 17, 2011
Messages
1,013
Helped
273
Reputation
552
Reaction score
270
Trophy points
1,383
Location
Greece
Activity points
7,938
- Could we see your initialization code?
- T1IN and R1OUT: which AVR pins are connected to?
- Are you using an one by one or a cross cable?
 

saesaria

Member level 1
Joined
Jun 13, 2011
Messages
34
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Location
Indonesia
Activity points
1,538
@alexxx
thanks for the reply
Could we see your initialization code?
do you mean UART initialization code? the initializaition is shown below
Code:
UART1_Init(9600);               // Initialize UART module at 9600 bps
  Delay_ms(100);                  // Wait for UART module to stabilize
T1IN and R1OUT: which AVR pins are connected to?
I use ATMega16
T1in <--> TXD (PD1)
R1out <--> RXD (PD0)
Are you using an one by one or a cross cable?
I'm using cross cable

When I use AVR programmer which support serial communication, it works. So there's no problem both with my AVR and the program.
Now I want to use max232 board that I made but it doesn't work.
 

alexxx

Advanced Member level 4
Joined
Apr 17, 2011
Messages
1,013
Helped
273
Reputation
552
Reaction score
270
Trophy points
1,383
Location
Greece
Activity points
7,938
saesaria said:
When I use AVR programmer which support serial communication, it works. So there's no problem both with my AVR and the program.
Only some AVR models (ATmega128, ATmega1281 and a few more others) support serial programming via USART. All other AVRs including ATmega16 are using SPI for serial programming, unless you are talking about serial bootloader, which is actually accomplished by USART.


saesaria said:
UART1_Init(9600); // Initialize UART module at 9600 bps
What compiler are you using? Normally this is no initialization code but initialization routine call, unless your compiler has build up functions like this one which takes care of USART initialization.

In general I would suggest the following:
If you have other signals on your RXD pin, remove them and keep only RXD signal on it. See with the osciloscope your RXD pin on ATmega16. When PC sends, then you should see digital signal on that pin. If you see the signal and has a good voltage level too, then hardware is OK and you should deal with your program. If not, then going backwards (R1OUT->R1IN->DB9.pin3) you should spot the problem.

Hope that helped.
 

saesaria

Member level 1
Joined
Jun 13, 2011
Messages
34
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Location
Indonesia
Activity points
1,538
Only some AVR models (ATmega128, ATmega1281 and a few more others) support serial programming via USART. All other AVRs including ATmega16 are using SPI for serial programming, unless you are talking about serial bootloader, which is actually accomplished by USART.
I mean, I connected my ATMega16 board with my AVR programmer board (there're two ATTiny 2313 on that), besides the AVR programmer also provide serial communication trought USB. I tested the serial communication between my ATMega16 and my laptop through the AVR programmer and it works using the following code
Code:
char uart_rd;

void main() {

  UART1_Init(9600);               // Initialize UART module at 9600 bps
  Delay_ms(100);                  // Wait for UART module to stabilize

  while (1) {                     // Endless loop
   if (UART1_Data_Ready()) {      // If data is received,
     uart_rd = UART1_Read();      // read the received data,
     UART1_Write(uart_rd);        // and send data via UART
    }
  }
}
how it works?
every I press a character on the keyboard, the character shown on the hyperterminal screen. So it means, both my ATMega16 board and also the program has no problem, right?

What compiler are you using? Normally this is no initialization code but initialization routine call, unless your compiler has build up functions like this one which takes care of USART initialization.
I'm using mikroC for AVR

In general I would suggest the following:
If you have other signals on your RXD pin, remove them and keep only RXD signal on it. See with the osciloscope your RXD pin on ATmega16. When PC sends, then you should see digital signal on that pin. If you see the signal and has a good voltage level too, then hardware is OK and you should deal with your program. If not, then going backwards (R1OUT->R1IN->DB9.pin3) you should spot the problem.

Hope that helped.
the RXD pin is save, no other signals connected to it. I tested the pin and there's no voltage level come out (I use voltmeter to test it). I think the problem is on the hardware, but I don't know yet what is the problem.

UPDATE
I tested again, I checked the V+ pin, it gives me +8V and the V- gives me -8V
Then when I give +5V on T1in pin, then the T1out gives me -8V, and it gives me +8V for +5V in T1in.
it is the correct voltage level right?

but still, no responding when connected to PC
 
Last edited:

saesaria

Member level 1
Joined
Jun 13, 2011
Messages
34
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Location
Indonesia
Activity points
1,538
SOLVED!
I tried the circuit on protoboard and it works well, perhaps the cause is from the PCB board, I don't know exactly what the problem is, maybe it just the soldering that is not good.
btw thanks to you Mr. Alexxx, you lead me to solve this.
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top