Connect with us

Help with "Data switch"

Discussion in 'General Electronics Discussion' started by HellasTechn, Apr 14, 2013.

Scroll to continue with content
  1. HellasTechn

    HellasTechn

    1,556
    215
    Apr 14, 2013
    Dear friends. Here i am going to share with you the problem i have.

    I need an automatic switch.

    I have two GPS receivers which have NMEA output. The output connector is a DB9 Connector.

    Pin 2 NMEA data output
    Pin 3 NMEA data input
    Pin 5 Ground

    Now i need to hook both theese GPS receivers to one serial port of a PC in order for the PC to be getting data from GPS-1 and if it fails (Blackout) to automatically switch to GPS-2

    I have looked up on the internet to find automatic serial data switch but i only found manual switches.

    I thought mabe a 5V relay could do the job but then again how will i drive the relay since the GPS receivers have no "i am on signal" not even a LED indicator.

    Any ideas apreciated ! Thank you alot.
     
  2. galaxy

    galaxy

    28
    2
    Nov 3, 2012
    One question, if GPS 1 fails, does the serial stream cease altogether, or still pump out 000,000 sort of data.

    If the serial stream ceases altogether, you could simply have a flip flop that was constantly being reset by the stream in normal operation, so it never toggles over. If the stream stops, the timer does its thing and the flip flop "flops" to the backup state, drving a relay/IC switch etc..

    Geez, did that make sense ????

    If the unit continues to output data, then it would be a "decode to test" sort of scenario.

    The other choice would be a 2nd Serial port on the PC and do the changover programatically.
     
    Last edited: Apr 14, 2013
  3. HellasTechn

    HellasTechn

    1,556
    215
    Apr 14, 2013
    Could you draw a diagram of the circuit you are telling me about so that i may be able to understand it better ?
     
  4. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    You can use a relay to switch the serial data signals between two different GPS receivers, but you've already identified a problem with your whole idea: how do you detect when one of them has failed? The only way to reliably do this is in software on the PC, which is able to analyse the responses from the receiver and detect various problems that might occur. Complete loss of the data stream from the GPS receiver is only one possibility.

    When one GPS fails and you switch over to the other one, the software running in the PC will probably need to know about it, and ideally, make the decision itself, since there is a full duplex connection between the PC software and the GPS receiver where the PC software needs to have a continuous data path in both directions, and remembers various state information about the GPS receiver. The PC software will not be expecting its data connection to suddenly switch over to a new, uninitialised GPS receiver and will probably become very confused.

    So... do you have control of the software running on the PC? If not, look at the documentation for that software to see whether it's designed to be able to handle an automatic fail-over to a second GPS receiver or not. If necessary, email the person or company that wrote the software and ask them whether it's safe to do it, and how you would control the changeover relay.

    If you wrote the PC software, you might be able to use one of the flow control outputs on the PC serial port to activate the relay. You would need a buffer and an external power source to power the relay coil because the RS-232 output signals have very little drive capability; definitely not enough to drive an electromechanical relay.
     
    chopnhack likes this.
  5. HellasTechn

    HellasTechn

    1,556
    215
    Apr 14, 2013
    What you say is very true.

    I have already done all that.

    I have niglected to tell you that the whole system is a position logger into a ship i work at.
    (that would have given you a better picture about this project)
    The system is pretty old and neither i have any control over its software nor there is any way to interface with this system.
    That is why i am trying to figure out a way for that system to be able to automatically change from gps-1 to gps-2 so i will not need to be present 24/7 to ensure that gps are all good.
    And i do want to do that because in ships power failures are quite often.
     
    Last edited: Apr 16, 2013
  6. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    Well, if you're sure that the PC software will not mind having a new GPS suddenly appear, and you only care about complete loss of the data stream, you can do what galaxy suggested. A 555 in monostable mode, triggered from the data stream from the GPS to the PC, will keep the relay switched over to GPS #1.

    You'll need a manual override for this at startup, because there'll be a chicken-and-egg situation - the GPS receiver probably won't transmit until the PC has transmitted some setup information to it, and it won't be able to transmit anything to it unless the 555 has detected a response from it and has switched the relay over to it! You'll need to think about how to handle this reliably.

    Then all you need is a DPDT relay. I'd use a small Telecom relay.

    Google 555 monostable circuits or "missing pulse detector" circuits.
     
  7. HellasTechn

    HellasTechn

    1,556
    215
    Apr 14, 2013
    I still can not understand completely how a 555 monostable vibrator will drive the relay but i will google it to see what i can find.

    If you would care to explain a little more detailed that would be much appreciated.

    It has been many years since i have studied digital electronics and i can barely remember how flipflops work. I do remember that the IC555 is a timer LOL :p
     
  8. HellasTechn

    HellasTechn

    1,556
    215
    Apr 14, 2013
  9. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    Yes, that circuit should work. R2 isn't needed, and the transistor should be a BC557B or a 2N3906. (The BC157 suggested is an obsolete part.)

    You'll need to process the RS-232 signal. The idle state for RS-232 data is negative, so you need a circuit that detects when it goes positive (data present) and generates a negative signal on the input to that circuit. You can do this with an NPN (e.g. 2N3904 or BC547B) connected as follows.

    Emitter to 0V rail
    Base through 100k resistor to RS-232 data signal
    Collector through 10k resistor to positive supply rail
    Collector is the output that feeds the missing pulse detector
    Also add a diode (1N914/1N4148) across the base-emitter of the transistor with its cathode to the base. This is needed to protect the transistor from negative base voltage, which can damage it.

    Yes, R1 and the capacitor set the timer interval.
     
  10. HellasTechn

    HellasTechn

    1,556
    215
    Apr 14, 2013
    Really i dont know how to thank you.

    You have all been so helpful.

    I am a little concerned about the data process you are saying.

    I will have to test the output during idle state (if there is an idle state in the gps output)
    because i think that the serial connector of the GPS is customized (it is not a standard serial comm port like the one used for pc to pc comm.)

    In case it just spits out positive pulses (data) then i should skip that crcuit right ?

    One other question. i beleave that it doesn't matter if the output is in rs232 or rs422 format right ?

    Hmmm one last thing... any recomendations for C1 and R1 (time interval) ?

    Thank you again for all your answers !!!!

    I am so excited that you helped me find a solution finally. I should be ready to test the circuit within the next 2 days !!!
     
    Last edited: Apr 16, 2013
  11. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    I don't understand what you're asking regarding skipping the circuit. You will need some kind of timing circuit, because the data line will be changing state as the data is transferred. When the data stops, the line will go idle, which for RS-232 is negative, although if the GPS receiver loses power, its transmitted data will go to 0V. So you need a circuit that detects when that line is positive. When it's positive, the circuit needs to reset a timer. If data stops, and the line stops pulsing into the positive state, the capacitor will charge up, and this will trigger the changeover to the second GPS receiver.

    RS-232 and RS-422 are different; RS-422 uses a differential pair for each data signal. Ideally you should use an RS-422 receiver to monitor an RS-422 data signal. These are made by companies like Maxim, Texas Instruments, Sipex, and a few others. Look for RS-422 receivers or transceivers on Digikey, Mouser etc.

    I'm not confident that this solution will work reliably, for the reasons I explained in an earlier post. Even if you test it, and it seems to work, I think it's possible that the PC software may become confused after the fail-over, if it's not designed to handle that situation. So although the switching part may be fairly simple, it may not be the whole answer to your problem.

    There's still the issue of enabling the first GPS receiver at startup. The GPS receiver may not start up and immediately start transmitting data; this may require communication from the PC first. If the timer has timed out (because there wasn't any data coming from GPS receiver #1) and switched over to GPS receiver #2, then there's no way for the PC to tell GPS receiver #1 to start transmitting data. That is a chicken-and-egg situation.
     
  12. HellasTechn

    HellasTechn

    1,556
    215
    Apr 14, 2013

    What do you mean idle state ?
     
  13. HellasTechn

    HellasTechn

    1,556
    215
    Apr 14, 2013
    Why do you think that RS422 is better ?
    I know the logger input is RS422 format and it uses an RS232 to RS422 converter to be able to receive RS232 NMEA data. I know for sure though that the GPS receivers can also output RS422 data.

    A chicken and egg situation will not happen because the GPS receivers do not need communication with the pc to start transmitting. you just power them up and they start giveing output. (I have checked that with an Oscope) plus i have been useing the same receivers with a Bridgemaster radar that only had a 2 wire input for NMEA data.
     
  14. HellasTechn

    HellasTechn

    1,556
    215
    Apr 14, 2013
    That i understand. You are right. I will have to dig into that but i need something to start with. and that something is the circuit you gave me !!!

    Thank you
     
  15. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    Asynchronous serial data uses a single signal for each data path. (RS-422 and other differential systems use two wires per signal, but there is still only one signal.) That signal is digital, i.e. it is always in one of two states. One state is defined as "idle" or "mark", and the signal stays in this state when no data is being transmitted. While data is being transmitted, the signal alternates between the mark state and the opposite state, which is called the "space" state or the "break" state.

    See en.wikipedia.org/wiki/Asynchronous_serial_communication

    Therefore you can detect whether data is present by monitoring the state of the signal. If it remains in the mark idle state, there is no data present. Whenever it switches to the opposite state, data of some kind is present. Your monitoring circuit will have a capacitor that is discharged when the data signal is in the non-idle state. When the data stops completely, the capacitor is able to charge up, and after a certain amount of time, it will reach a threshold voltage which the circuit defines as indicating that the data flow has stopped. That's when your circuit will switch to the second GPS receiver.

    For NMEA data you may find that the GPS receiver only transmits one burst of data every second. In this case, your circuit will need a timeout that's safely longer than one second before it reports that data has stopped.

    I didn't say that RS-422 is better than RS-232. They each have their place.

    If your setup is partly RS-422 and partly RS-232 then you should switch and monitor the RS-232 signals, since these are single wires. Monitoring RS-422 requires a differential RS-422 receiver, and switching RS-422 requires twice as many contacts on the relay. So you should do your monitoring and switching in the RS-232 section of the data path.

    You say the GPS receivers start transmitting NMEA data as soon as they're switched on. OK, that's good. Do you know whether the PC transmits _any_ data to the GPS receiver? Or does it just just "listen"? If the PC never transmits anything to the GPS receiver, and GPS receivers #1 and #2 are set up the same, then the PC probably won't care, and won't get confused, when your circuit switches from #1 to #2. Also, you won't need to switch the data signal in the other direction (from PC to GPS receiver) if that signal isn't used.
     
  16. HellasTechn

    HellasTechn

    1,556
    215
    Apr 14, 2013
    I took the time to study the circuit and read your posts. Yes indeed all you say make sense.

    I have bought all the parts and i will build the circuit on a breadboard tomorrow.

    I will test it and post back the outcome...

    The only thing that will be tricky is to make the pulse intervals more than a sec long cause just as you correctly pointed out NMEA gives one burst of data every one second or so.

    THANK YOU !!!!!!
     
  17. HellasTechn

    HellasTechn

    1,556
    215
    Apr 14, 2013
    555 missing pulse.png I had some free time so i made the circuit.

    This is how i made it.

    In the output it gives nothing... To be honest i dont know why.


    PS.

    I have already located a few mistakes i made... working on it
     
    Last edited: Apr 17, 2013
  18. HellasTechn

    HellasTechn

    1,556
    215
    Apr 14, 2013
    This has worked in the simulation.

    What do you think ?
     

    Attached Files:

  19. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    I'm not sure. There's a simpler way to do this, though. Here's a circuit that may be suitable.


    [​IMG]

    Here's a circuit description.

    The two GPS receivers connect to CN1 and CN2. The top terminal of each connector is for the RS-232 data from the GPS receiver to the PC. The PC connects to CN3. The two changeover contacts of relay K1 switch the PC's transmit and receive data signals to either GPS receiver #1 (when K1 is not energised) or GPS receiver #2 (when K1 is energised).

    The circuit monitors the data coming from GPS receiver #1. The RS-232 data line is negative in the idle state; when any data is present, the data signal pulses to the positive state. Each time this happens, Q1 is biased ON and discharges CT.

    The voltage divider (R1 and R2) and C1 improve the circuit's immunity to noise on the RS-232 data line. C1's value is chosen to suit data rates up to 9600 bps. If the GPS receivers use a data rate higher than that, C1 must be reduced accordingly. D1 protects Q1 from possibly damaging negative base voltage.

    As the data is flowing, Q1 keeps CT discharged. When data is not present, CT charges up through RT. After a time slightly longer than the time constant of CT RT, the voltage on CT reaches the positive threshold of the 555 and its output goes low, energising the relay and performing the fail-over to GPS receiver #2.

    The time constant of CT and RT is the product of the two values. For the values given, 47k and 33 uF, this time is 47e3 x 33e-6 = 1.5 seconds approximately.

    The circuit can be powered from 6~12V DC. Choose a relay accordingly. Here are suggestions from Digikey:
    12V coil: http://www.digikey.com/product-detail/en/V23079A2003B301/PB1058-ND/1210004
    6V coil: http://www.digikey.com/product-detail/en/IM04TS/PB1095-ND/1633981

    If the PC does not transmit data to the GPS receiver, there is no need to switch that data path, and a SPDT relay can be used.

    This circuit does not latch into the fail-over state. If GPS receiver #1 fails and the circuit switches to GPS receiver #2, then GPS receiver #1 starts transmitting data again, the circuit will switch back to GPS receiver #1.
     

    Attached Files:

    Last edited: Apr 17, 2013
  20. HellasTechn

    HellasTechn

    1,556
    215
    Apr 14, 2013
    Picture missing !
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
There are no similar threads yet.
Loading...
Electronics Point Logo
Continue to site
Quote of the day

-