Posts Topics Forums Images
Search videos from message boards Videos Search messages from microblogs Microblogs Search messages from imdb.com Imdb Search messages from yuku.com Yuku Search messages from lefora.com (free forums) Lefora
My account: Login | Sign Up
Loading... 

Thread: led to rs232 [modified]

Started 1 month, 2 weeks ago by merlinq12
I have a problem. BIG one. I have a LED connected to pin 3 and 5 at serial port (rs232). Here is the code I make, who blink that led at an interval from a timer. private SerialPort o_port = new SerialPort( " COM3" , 9600 , Parity.Odd, 8 , StopBits.One); private void button1_Click( object sender, EventArgs e) { timer1.Enabled = true ; } ...
Site: CodeProject: Discussion Boards. Free source code and programming help  CodeProject: Discussion Boards. Free source code and programming help - site profile
Forum: C#  C# - forum profile
Total authors: 4 authors
Total thread posts: 12 posts
Thread activity: no new posts during last week
Domain info for: codeproject.com

Other posts in this thread:

Christian Graus replied 1 month, 2 weeks ago
You could write a timer, then write a loop that sends the data over and over, and turn it off when the timer fires, if you send the data on another thread. That's assuming that the data gets sent once, that it's not a switch you turn on or off. That's how it worked when I worked with the serial port, you'd turn the pin on, set a timer, then turn it off again.

merlinq12 replied 1 month, 2 weeks ago
well, when I integrate a while loop, my pc crash. I really dont know how to do it...I dont have any clue. Please write me a code to have a inspiration on how to do it. Im a bit new to this . thanks.

Christian Graus replied 1 month, 2 weeks ago
merlinq12 wrote: well, when I integrate a while loop, my pc crash. How does it crash ? What happens ? What's the code ? merlinq12 wrote: Please write me a code to have a inspiration on how to do it. Im a bit new to this Smile. It's years since I did it, but have you tried just setting it once ? Does that turn the LED on, or make it flash on and off ?

merlinq12 replied 1 month, 2 weeks ago
private void timer1_Tick( object sender, EventArgs e) { // this code crash my pc int number = 1 ; while (number == 1 ) { o_port.WriteLine( " xxx" ); } } The original code make the led flash/ ON and OFF. I dont know how to turn the pin ON !!!!

Alan N replied 1 month, 2 weeks ago
Hi, You have connected the LED between transmit data (TD) and ground (SG). Is is your intention to show when data is being transmitted or do you just want to turn an LED on and off? If it's the latter then it would be better to connect the LED to one of the control lines, e.g. data terminal ready (DTR) or request to send (RTS), and ground. These lines can be toggled or or off via the ...

Luc Pattyn replied 1 month, 2 weeks ago
Hi, you're taking a bad approach here. The data lines (TD and RD) carry a serial data stream, which consists of start bits, data bits, parity bit, and stop bits; and by definition are not constant. What you want can be achieved by using one of the control lines (that would be DTR or RTS, and it requires a hardware change to your current LED connection). You can use SerialPort class, open the ...

Christian Graus replied 1 month, 2 weeks ago
I'd think you'd want to set a timer with a small interval, not run your processor to 100%.

merlinq12 replied 1 month, 2 weeks ago
ohooohooo... Its Christmas time Thank you very much for this very good advice, guys. Oau. I use a usb to serial converter, and a bright LED , so I don't mind about the U/Led. I wonder ... hmmm..I can run a stepper motor with this? Actually at this is serve the experiment with the led. Of course I will use a demultiplexor, a uln2004, and some bunch of wires. If you know a better way (...

Luc Pattyn replied 1 month, 2 weeks ago
merlinq12 wrote: I don't mind about the U/Led. I don't know what you mean here, if you want to forgo the resistor chances are you will ruin your serial port, which will cost you more than thousands of resistors. merlinq12 wrote: .I can run a stepper motor with this? with the proper H bridge in place you can control motor steps, yes. However: - there is bound to be some unpredictable ...

merlinq12 replied 1 month, 2 weeks ago
Luc Pattyn thanks for your prompt response ... very nice and clean explanations (not very detailed but enough & strait forward). Thanks man. And I Dont abuse anything, I was beginning the discussion from SerialPort class, and one thing to another I was jumping to other interesting stuff. I see that I am away a bit from my original post, so I will no longer continue . I understand. hmmm...

 

Top contributing authors

Name
Posts
merlinq12
6
user's latest post:
led to rs232 [modified]
Published (2009-11-01 22:18:00)
though ... I must put for others the !Finished! customized code : // if you are to set different time intervals? // say 100ms to ON state and 400ms to OFF state? // Here is the answer! ...and the final finished code! // all other usings + using System.IO.Ports; private SerialPort port = new SerialPort( " COM3" , 9600 , Parity.Odd, 8 , StopBits.One); public Form1() { InitializeComponent(); port.Open(); } private void...
Christian Graus
3
user's latest post:
led to rs232 [modified]
Published (2009-11-01 19:33:00)
I'd think you'd want to set a timer with a small interval, not run your processor to 100%.
Luc Pattyn
2
user's latest post:
led to rs232 [modified]
Published (2009-11-01 20:15:00)
merlinq12 wrote: I don't mind about the U/Led. I don't know what you mean here, if you want to forgo the resistor chances are you will ruin your serial port, which will cost you more than thousands of resistors. merlinq12 wrote: .I can run a stepper motor with this? with the proper H bridge in place you can control motor steps, yes. However: - there is bound to be some unpredictable delay between setting a control line in software,...
Alan N
1
user's latest post:
led to rs232 [modified]
Published (2009-11-01 19:25:00)
Hi, You have connected the LED between transmit data (TD) and ground (SG). Is is your intention to show when data is being transmitted or do you just want to turn an LED on and off? If it's the latter then it would be better to connect the LED to one of the control lines, e.g. data terminal ready (DTR) or request to send (RTS), and ground. These lines can be toggled or or off via the SerialPort class. The timer tick code would be e.g....

Related threads on "CodeProject: Discussion Boards. Free source code and programming help":

Related threads on other sites:

Thread profile page for "led to rs232 [modified]" on http://www.codeproject.com. This report page is a snippet summary view from a single thread "led to rs232 [modified]", located on the Message Board at http://www.codeproject.com. This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity