SmallBot
reconn's
reconn's
world
world
.com



Email Statistics | July 05, 2008

Serial Multiplexer Project

Design:

serial multiplexer design

The design is pretty simple really, connect the RX and TX lines of each sonar unit to the PIC. In code, the PIC reads the data off each TX line and then sends the read data through the voltage level converter (MAX232 chip) to the host PC.

Implementation:

I used MPLAB v7.0 to write the code, and I compiled it with the CCS PCH compiler. The sonar module's output is an inverted RS-232 signal -- so in order to read data from them you have to invert them. This can be done either with an inverter (with input: sonar TX; output: PIC RX), or you can automatically invert the signal in code. I tested the inverter method to make sure it worked -- it did, but in the end I did the inversion in code, so I wouldn't have to wire up another chip.

According to the datasheet, the sonar modules only output data when their RX pin is high (+5v). They output the sonar reading, in one inch increments every 49mS. I read the data from the sonar modules in round-robin style:
  1. command the sonar to take a measurement
  2. read the data
  3. command the sonar to stop measurements
  4. send the data to the host computer
  5. move on to the next module, repeat steps 1-5
In this board, I connected the two sonar modules as follows:
Sonar Pin
PIC Pin
Sonar 1: RXRA2
Sonar 1: TXRA3
Sonar 2: RXRA0
Sonar 2: TXRA1

Sample Output

Example output of a single sonar module:
R006
R006
R010
R012
R035
R035
R035

Example output of the Serial Multiplexer:
Sonar MUX v.1
Author: Andrew Wilson 5/2006
reconnsworld.com
sonar1: 025
sonar2: 006
sonar1: 025
sonar2: 006
sonar1: 025
sonar2: 006
sonar1: 025
sonar2: 006
sonar1: 025
sonar2: 006

Code and HEX File

To see the source code, follow this link
For the 18F1320 hex file, click here

Final Words

This project works pretty well. However it may be a good idea to implement time-outs in the program. Right now, if one sonar module is broken the program will be stuck waiting for data that never comes. This will keep the program from ever moving forward.

If you're interested in having me build one of these units for you, send me an email using the feedback form.

project added: 6/11/2006


Recent Project Log Entries
OscopeCapture: Reverse Engineering the USB Protocol?
Posted on 20 March 2008 | 5:05 pm
OscopeCapture : Installing Environment
Posted on 18 March 2008 | 8:57 pm
Oscilloscope Waveform Capture Program Intro
Posted on 18 March 2008 | 8:27 pm
PIC Code, Verified
Posted on 5 July 2006 | 7:08 pm
Speed Control Dial
Posted on 28 June 2006 | 4:37 pm
Beginning of Stepper Driver
Posted on 27 June 2006 | 8:12 pm
Aoyue 852 Hot Air Rework Station
Posted on 15 June 2006 | 7:36 pm
Instek GDS-820C Oscilloscope
Posted on 13 June 2006 | 4:58 pm
Site by Andrew Wilson. Copyright 1997-2006 All Rights Reserved unless otherwise noted.
Schematics in Schematics Depot were found on the internet and assumed to be in public domain. Contact webmaster if the copyright holder wants them pulled for any reason.