Jump to content
Electronics-Lab.com Community

encoder output to rs232 conversion

Recommended Posts

The operation will involve an encoder, a multiplexar which is selected with a counter that is clocked at the baud rate, and a level translator. You must select no parity and 8 data bits as the format. This is all you need. The input to the multiplexar must have the ready format for rs232 which includes the start bit, the stop bit, and the data bits you are sending. Now, with eight data bits possible, that makes for 0 through 255 inputs. The multiplexar would then have 8 inputs plus 2 inputs for the start and stop bits which is just pulled high. Or you could go with a BCD decoder with a 10 input multiplexar and pull the the inputs up or down as dummy data. The key to this is that the format that is input to the multiplexar is rs232. So with a BCD you will have four data lines, four dummy bits, and 2 bits pulled high. Next you have to generate the RTS and the CTS. To do that, pullup the RTS of the PC high. Then connect the CTS of the PC to the enable line of the counter only if you wish because the PC should always be ready. Now in order to make it work properly, reset the counter and make sure that the next transistion of the clock transmits the correct data bit as a 000 to 001 will select the second position as your transmitted bit. If you have a preset then you don't have to worry about it. But it is your option. Also, the clock that is applied to the counter should be half the time of the transmission.

The data will be freeflowing. If you want to send a byte as a result of an occurance of the input, like a switch from low to high, you will need a couple more items. All the inputs go to a multiple input OR gate. The Or gate is connected to the enable of the counter with an inductor to ground. This will give you an enable pulse that goes high when you throw the switch and then goes low after the inductor voltage falls.

Link to comment
Share on other sites

In my oppinion solution given by Kevin is not the right way to go..

I would employ any microcontroller (8051, PIC) with built-in UART, so you don't need to warry about bits, bytes and timing. All is done for you within this microcontroller. If it is for example 8051, use 11059200Hz cristal quarz and you will find a lot of application nots how to set up the UART to operate at, say, 9600bps or any other rate.
You will also need TTL - to - RS232 level converter and there are hundreds of ICs to performe this task. (Most common are MAX232 or 202 - doesn'i need to be MAX, any with the number 202 or 232 will do).
So you connect encoder output (assuming you have 0-5V level) to INT0 of the CPU (if you have encoder with 2 waves you will connect the other wave to any available input pins and with 2-waves shifted by 90deg you will be able to read not only distance but direction too).
And that is your hardware!!!
Now comes the software.
Ask yourself in what format you would like to send data to PC:
- raw indication that a pulse just occured ( a byte in HEX or ASCII)
- calculated distance in from of a string 000.0 ..?

But from this point you will not manipulate with hardare any more..
If you are intereste I can post you some diagrams of working circuits..

Link to comment
Share on other sites

From the info I've received from the replies I know what the hardware requirements are. Appreciate the input guys.

If anyone could help me on the software side where I want to display a 'box' on the screen with the value of the 'count' being displayed, with possibly an ability to scale the count to convert it to a linear movement, rather than a pulse count. Also I would be using the A & B signals from the encoder to discriminate direction of count.




Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...