TTL naman ang other end ana bro noh? Mas ok na kay no need na ug max232. Di madala ug 100 na? Hehe
TTL naman ang other end ana bro noh? Mas ok na kay no need na ug max232. Di madala ug 100 na? Hehe
YES!bag-o pagyud na kuha, salamat sa mga nitabang,
nakuha na nako para maka communicate sa C# program sa ako simulation sa proteus...
salamat i-actual nani nako! salamat mga Master!
mangutana lng ko balik dere mga Master kong mapoblema ko balik.. salamat sa tanan..
Ahak, bai @red_horse naa napud ko problem,
ahak dle man cya mo gana sa actual na gyud, sa simulation gana kaau.. ako ra gyud ni gisuon ang naa sa Proteus nga circuit deli man cya mo gana......
ako gi gamit kay Serial-to-rs232 kon ako gi direct sa LED ang pin3(transmit data Tx) inig click nako sa c# nga button mo sige cya so meaning ok ra ba ang USB-to-rs232? or sa ako ni PIC ang problema..?
Dili mi maka tag-an ana bro since wala man ka gapakita sa imo codes or circuit.
But there are ways to debug both your hardware and software.
Let us start sa hardware.
First do an echo test sa PC side.
I assume gagamit ka ug ug max232/max3232.
I-short ang pin11 and pin12 or pin9 and pin10 sa max232/max3232 depende ug asa nimo gi-connect ang USB-to-serial cable.
Open up USART terminal sa mikroC or sa windows (hyperterminal).
Make sure the same ang baud rate settings and tsakto sad ang comport.
Send a character sa terminal. If di nimo ma receive ang imo gi send sa terminal, that means may problem imo hardware.
Last edited by red_horse; 10-15-2012 at 10:57 PM. Reason: Typo..
Mao ni ako naa sa Proteus circuit Bro @red_horse
naa ko pangutana unsa nang COMPIM dba mao nang DB9 or USB-to-RS232?
Mao ni Code nako sa MikroC Pro.
Kini mao ni ako code sa Visual C#.....Code:char UART1_Data_Ready(); char uart_rd; void main() { TRISB=0; PORTB=0; UART1_Init(9600); // Initialize UART module at 9600 bps Delay_ms(100); // Wait for UART module to stabilize while(1) { if(UART1_Data_Ready()) { while(1) { uart_rd = UART1_Read(); if(uart_rd=='A') { PORTB=0X14; DELAY_ms(5000); PORTB=0X24; DELAY_ms(500); PORTB=0X41; DELAY_ms(5000); PORTB=0X42; DELAY_ms(500); } else if(uart_rd=='O') { PORTB=0x00; DELAY_ms(500); } else if(uart_rd=='m') { PORTB=0x41; DELAY_ms(500); } else if(uart_rd=='M') { PORTB=0x14; DELAY_ms(500); } } } } }
ahak ani oi deadline nabaya inig Friday..Code:using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO.Ports; namespace SerialPortsNew { public partial class Form1 : Form { SerialPort port = new SerialPort("COM3", 9600, Parity.None, 8, StopBits.One); bool CurrentState = true; bool PrevState; public Form1() { InitializeComponent(); } private void Automatic_Click(object sender, EventArgs e) { Manual.Enabled = false; off.Enabled = true; port.Open(); port.Write("A"); port.Close(); } private void Manual_Click(object sender, EventArgs e) { Manual.Visible = false; off.Enabled = true; Automatic.Enabled = false; pressManual.Visible = true; } private void off_Click(object sender, EventArgs e) { if (CurrentState) { Manual.Enabled = true; Automatic.Enabled = true; Manual.Visible = true; pressManual.Visible = false; port.Open(); port.Write("O"); port.Close(); PrevState = false; CurrentState = PrevState; } else if (PrevState == false && CurrentState == PrevState) { Manual.Visible = true; pressManual.Visible = false; Automatic.Enabled = true; port.Open(); port.Write("O"); port.Close(); CurrentState = true; } } private void pressManual_Click(object sender, EventArgs e) { if (CurrentState) { port.Open(); port.Write("M"); port.Close(); PrevState = false; CurrentState = PrevState; } else if (PrevState == false && CurrentState == PrevState) { port.Open(); port.Write("m"); port.Close(); CurrentState = true; } } } }![]()
Dili nako makita imo proteus file or image.
Kanang COMPIM mura ra na sya ug serial port with built in max232 inside so direct ra nimo i-connect sa imo mcu.
I-double click na sya makita nimo ang BaudRate ug ComPort settings.
Your codes seems ok. Maybe sa hardware lang jud imo problema.
Deadline na rong monday?
Actually dugay naman sad ni.
If kumpleto ka sa hardware mahuman lang ni one day.
Naa na ba kay max232?
If wa pa buy nalang sa egizmo ug USB-to-TTL module, which works with 3.3-5v PIC's.
e-Gizmo USB-UART Serial TTL converter
Or kana gibaligya ni carl_marx1234.
By the way taas ra kaau imo delay dri,
If ang imo PIC maka receive sa character "A", mo wait pa sya 11 seconds para mo detect na sad ug lain characters.Code:if(uart_rd=='A') { PORTB=0X14; DELAY_ms(5000); PORTB=0X24; DELAY_ms(500); PORTB=0X41; DELAY_ms(5000); PORTB=0X42; DELAY_ms(500); }
kini siya kay for Automatic nga button ra ni cya, kay ako gibuhat kay murag traffic light( naa Manual button, ug naa pud Automatic... mao ra..... wala lagi ko kapalit ug max232 mga tag-pila sad kaha ni? naa ni technica?,.. unsa maning USB-to-TTL converter ang ako man project gud kay dapat serial gamiton.....
Code:if(uart_rd=='A') { PORTB=0X14; DELAY_ms(5000); PORTB=0X24; DELAY_ms(500); PORTB=0X41; DELAY_ms(5000); PORTB=0X42; DELAY_ms(500); }
naay gamay sayup ang code nmo sa mikroC bro.
Nag endless loop ka ug kaduha. Sa 2nd loop nmo wako nkakita ug cndition nga mo terminate cya.
So never na cya mo read ug usab sa uart.
Remove d 2nd loop.
1thing: rs232 is dli ka level sa pic serial. U need to have a voltage leveler ic which is max232.
Mao ni cya mo convert from rs232 to TTL LEVEL. Kay ttl man pic.
2 options:
A. U buy max232 sa teknika ug buy sa cdrking usb to serial cable.
Construct d crkt naa sa help sa mikroC search lng USART
B. go to any cellshop and look for DCU11 data cable. Pra na cya sa sony ericson
Cut d other end. Wire color code
RED: 5V
Orange: gnd
Green: rx
Blue: tx
White: nc
This cable is usb to ttl233 na. So no need na max232 ic.
Similar Threads |
|