Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Electronic Circuit Question -

  • 21-03-2014 5:15pm
    #1
    Registered Users, Registered Users 2 Posts: 3,896 ✭✭✭


    Hi -

    I want connect an Arduino's 5V RS232 TX Pin to a device that is a sort of RS485.

    Its a four wire system (MasterDeviceTX ,MasterDeviceRX ,0V, and 12V) thats normally resting at 0V and when a device wants to transmit it uses pulses to +12v (using rs232 standard signaling).

    So what I want to do is make as simple a circuit as possible that when its the Arduinos turn to talk it will do basically this

    Arduino Tx Pin Low (0V) - voltage to go to +12V
    Arduino Tx Pin High (5V) - voltage output to be disconnected oc (important: Not go to 0v as another device will want to pulse to 12V after)


    Just like this - except of course don't want use a real mechanical relay - this is just to illustrate what I need. I did try a solid state relay but it wasn't fast enough. Was thinking Mosfet or similiar.....

    299633.png

    You can see the bus and arduino grounds are connected. And I want the arduino to output either +12V or be disconnected.

    I know there are Max chips and rs485 arduino boards - but the ones I looked at Im not certain they are 0..12v and they require a separate pin to disconnect from the bus rather than like above - which I wont know when to as it depends on when the rs232 message actually completes.

    “Roll it back”



Comments

  • Registered Users, Registered Users 2 Posts: 5,421 ✭✭✭DublinDilbert


    Pick up an RS485 shield, they are less than €5 on ebay. The will have the correct RS485 driver chip on them and you can just connect your A and B wires to it.

    If you want to do your own you'll need an RS485 driver chip. You can run a software USART to drive this, leaving the main USART available to talk to the PC for debug + programming etc...


  • Registered Users, Registered Users 2 Posts: 3,896 ✭✭✭ozmo


    Pick up an RS485 shield, they are less than €5 on ebay. The will have the correct RS485 driver chip on them and you can just connect your A and B wires to it.

    If you want to do your own you'll need an RS485 driver chip. You can run a software USART to drive this, leaving the main USART available to talk to the PC for debug + programming etc...

    thanks for that - I did look a little into that though - see last line of post - the max chips and arduino boards Ive looked at require a disconnect signal as well as the tx signal as far as I can see??

    I'm looking for one wire in and 12v and open circuit out

    “Roll it back”



  • Registered Users, Registered Users 2 Posts: 2,320 ✭✭✭Chet T16


    Diagram isn't working for me.

    Doesn't RS485 use differential signals?


  • Registered Users, Registered Users 2 Posts: 9,597 ✭✭✭gctest50


    422 maybe ?


  • Registered Users, Registered Users 2 Posts: 3,896 ✭✭✭ozmo


    Chet T16 wrote: »
    Diagram isn't working for me.

    Thanks for looking at it-

    Its an Aritech Alarm panel. And thats the bus it uses as far as I have figured it out. Its probably unique hardware setup to them.

    I have the protocol figured out - I can read the bus, understand the packets and know when its time to send - but I cannot work out how to generate the 12v signal pulses.


    I want to make an arduino behave like one of the alarms panels keypads - so I can use it remotely from a browser as if i was in the house - and it will also allow me to add new zones.


    Protocol is like this - two wire bus, normally at 0v - Panel sends packet on one wire (Marked D) via rs232 - first byte is the device number - rest is text to display etc- and whatever device is assigned that id gets to reply on the return rs232 wire (Marked C). (+12 ). So the return wire has many devices - but all disconnected unless its their turn to reply.



    My first version uses the printer port (I described it here http://www.boards.ie/vbulletin/showthread.php?p=88215184 ) - but I think Id get more functionality if I made an Ethernet KeyPad and might be of use to others as few Aritech panels have a printer port.

    “Roll it back”



  • Advertisement
  • Registered Users, Registered Users 2 Posts: 3,896 ✭✭✭ozmo


    heres the diagram - hopefully ok this time...
    Again - looking for a silicon equivalent of this

    299633.png

    “Roll it back”



  • Registered Users, Registered Users 2 Posts: 2,320 ✭✭✭Chet T16


    Looks like you need some sort of tri state level shifter attached to the arduino tx line. Something like a 74HCT125 (but check if it'll work with 12v, that was the first thing to come up on google) should work for you with an extra pin controlling the output into a high impedance state


  • Registered Users, Registered Users 2 Posts: 3,896 ✭✭✭ozmo


    Thanks guys - looked into it - and although it would be perfect - the 74 chips just wont switch 12V - maybe get 7V at most out of them.


    After more research - It appears It may be possible use a P-Channel Mosfet. I opened a few old pc power supplies and got lots of N-Channel fets from them (much easier to use - but not suitable for switching in the Positive rail like I need) but no P Channel - so off to Maplins tomorrow for one try it out.


    http://digital-diy.com/general-electronics/67-tip-logic-level-fets-p-channel.html



    As a test - I did manage to connect directly into the panel - past the 12v public interface part - to the 5V logic and managed to emulate the keypad successfully - so Im on the right track :)

    “Roll it back”



  • Registered Users, Registered Users 2 Posts: 2,320 ✭✭✭Chet T16


    Always nice to get another step in the right direction!

    Keep us updated


  • Registered Users, Registered Users 2 Posts: 3,896 ✭✭✭ozmo


    Ok - tried a few things - but here is what i came up with as the simplest. Its an optocoupler!

    Now.. it Works .. Yay! :D ... Buuut the signal is not what I expected :( and I would like get it cleaner.
    I replaced the Transistor with an N-Mosfet (similar output), and a darlington introduced more problems (not grounding fully).


    I know the problem is the capacitance of the line and device its connected to (to the right of the output tag) but I cannot change that.

    Would anyone electronics guy know how to correct the circuit make the output closer to a square wave?


    * The 3.5k Resistor and capacitor are measured off the actual device it needs drive(and so cannot be removed).
    * The Frequency in is an TX message (1KHz square wave is a good aproximation).
    * The line is normally 0v
    * a 0V on the Arduino is to pull this cleanly to 12V (or close)
    * a 5V on the Arduino is to let it drop to 0V (but not ground it firmly)
    * Trying keep under 10mA current


    302345.png
    The circuit and the simulated output - very similar to whats observed in real life - the o/p voltage is not 12V and not rising quick enough.
    Smaller values for R1 put the current too high. Smaller values for R4 cause the transistor to stay partially on.
    It looks 100% perfect square wave out when not connected to the device.

    thanks...

    “Roll it back”



  • Advertisement
  • Registered Users, Registered Users 2 Posts: 3,896 ✭✭✭ozmo


    And here is what it looks like in real life...

    Top Image is what I was hoping to get - below that is the actual output of the circuit.

    The bottom one is rounded and lower voltage due to the line impedance.

    302346.jpg
    (note two traces are not showing the same data)


    it works, but maybe not always - so would anyone have any ideas to make it better without adding lots more components? Cheers.

    “Roll it back”



  • Registered Users, Registered Users 2 Posts: 2,320 ✭✭✭Chet T16


    I was going to say that the output would be grand but it looks like its only hitting 7v, is that correct?


  • Registered Users, Registered Users 2 Posts: 3,896 ✭✭✭ozmo


    Chet T16 wrote: »
    I was going to say that the output would be grand but it looks like its only hitting 7v, is that correct?

    Yes - its a bit on the low side and not as sharp a signal as I was hoping.

    “Roll it back”



  • Registered Users, Registered Users 2 Posts: 2,320 ✭✭✭Chet T16


    I assume the low voltage is caused by the voltage divider you've created with the 4k7 resistor there.

    To be honest if it's working as it is then getting a slightly higher voltage out of it should push you well into your logic high territory. Some systems will see anything over V/2 as high. I wouldn't worry about the waveform shape. Whats the baud rate?

    Does the rest of the system work ok when this is in its off/idle state?


  • Registered Users, Registered Users 2 Posts: 2,320 ✭✭✭Chet T16


    As an aside i did have a problem like this before - i had a laser (keyring type) connected to the uart tx pointing toward an LED. The signal on the rx side was more like a sawtooth wave. To recontruct the signal it was passed though an opamp used as a differentiator and then another as a comparator. I should have oscilloscope screenshots somewhere


  • Registered Users, Registered Users 2 Posts: 3,896 ✭✭✭ozmo


    Chet T16 wrote: »
    As an aside i did have a problem like this before - i had a laser (keyring type) connected to the uart tx pointing toward an LED. The signal on the rx side was more like a sawtooth wave. To recontruct the signal it was passed though an opamp used as a differentiator and then another as a comparator. I should have oscilloscope screenshots somewhere

    Device uses 1951 baud rate - odd number - but was one of the set options built into its uP and matches nicely what I see - guess it works out a handy clock speed to get to from the main clock.

    Always thought of doing that with penlaser - but never got round to try it - good to hear it works - what speed could you transmit on?

    “Roll it back”



  • Registered Users, Registered Users 2 Posts: 2,320 ✭✭✭Chet T16


    Ah sure no wonder its working, i've seen morse code send packets quicker than that :p

    I had some trouble with the rx line idling low/high when it should have been the opposite but the reconstruction worked well

    Top is received signal, bottom is sent.

    a9b5ae9f.jpg

    Top is sent, bottom is reconstructed

    25020366.jpg

    Those were all at 2400bps. I got bored and moved onto something else to play with, the LED is not a great choice for rx as even at a few cm it needs careful aligning. For my test i had them mounted in an empty pen


Advertisement