Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

How to get Rid of DB9/MAX232 Interface


  • Please log in to reply
6 replies to this topic

#1 baxter

baxter

    Advanced Member

  • Members
  • PipPipPip
  • 415 posts

Posted 13 June 2013 - 08:18 PM

I picked up a new Mini from the recent Sparkfun $10 off $20+ sale. My old Mini is mounted on on a Parallax BOE which has the DB9 connector. I wanted to breadboard the new Mini, but breadboarding with a DB9 connecctor is unpleasant to say the least. The Picaxe line of chips use a RS232 programming interface, but it is possible to use a regular USB to serial adapter if TX/RX are inverted. TX from USB/serial is input to the inverter and the output from the inverter is input to RX; and conversely for RX. I decided to try this with the Mini using a 74LVC2G14 Schmitt trigger inverter and it worked. Probably any USB to serial adapter will work, but I used a Prolific PL-2302 at 9600 baud. I was able flash the new 4.2 firmware on the Mini RS232 connection with straight hardware inversion. No problems with SAM-BA, MFdeploy performed its job and happily pings, gives device capabilities and connects.
All of this worked transparently without the USB to RS232 adapter/DB9 connector. The 74LVC2G14 is a SOT23-6 2 gate part and perfect for this application. You can also use a 74HC14 in a dip or SOIC 14-lead arrangement.
 

The connections are:

USB/serial     74LVC2G14(In)     74LVC2G14(Out)      MiniTX    -->       1A (pin 1)        1Y (pin 6)  -->  RX (pin 2) USB/serial     74LVC2G14(Out)     74LVC2G14(In)      MiniRX    <--       2Y (pin 4)        2A (pin 3)  <--  TX (pin 1)                                                   DTR (pin 3, no connection)

Pin 2 of the inverter IC is ground and pin 5 is VCC (5V from the USB serial). I think it is important to use 5V and not 3.3V. Given that hardware inversion works, it can be completely eliminated by doing the inversion in firmware. The FTDI EEPROM programming utility has provision for inversion; download it here:

 

http://www.ftdichip....ies.htm#FT_Prog

 

To use it (assuming you have a FTDI USB/serial adapter), under the menu devices click scan and parse. Invert RS232 is under Hardware specific in the tree. I did a Google search on the Forum for this type of Mini interface, but did not find anything so due apologies if this is a re-post on this topic.

 

Attached Files



#2 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 14 June 2013 - 11:25 AM

I was unaware of the need for inversion, I always use a regular Prolific USB to RS232 cable (think it has the 2303 chip) for flashing tinybooter onto my minis without problems (have used two different ones over time).

 

Since I've never had to interface with any RS232 devices in my apps, I've only used the TTL UART (pins 11 and 12) for deployment and debugging using a classic FTDI USB to 3V3 TTL UART cable which also supplies 5V to pin 21.

 

Are you flashing the RS232 version of tinybooter in order to free up the TTL UART for application use?



#3 baxter

baxter

    Advanced Member

  • Members
  • PipPipPip
  • 415 posts

Posted 14 June 2013 - 08:24 PM

Well, you don't need inversion for COM1 and yes, I am flashing the RS232 version of tinybooter and using COM2 (pins 1,2) for deployment with COM1(pins 11,12) for applications. COM2 is expecting inverted RS232 signal levels. Mini is taking these and passing them through another MAX232 equivalent chip. The RS232 logic transition threshold is about +/- 3V. So, if you interface TX/RX (inverted, idle low) at 0-5V (maybe3.3V) with Mini it will be happy. Hence, no need for a USB/RS232 cable on COM2; just an inverter between TX/RX signals from a USB/serial and Mini TX/RX (pins 1,2). You can do the inversion with transistors (lost the attribution), but the Schmitt trigger inverter is superior.

 

With the inversion circuit in place, a single cable (USB/serial) with a switch between COM1 and COM2 can be used for either deployment or application.

Attached Files



#4 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 15 June 2013 - 07:38 AM

See what you mean now, it's nice to be able to use the same cable for both ports. Since COM1 expects TTL levels, I suppose the inverter does signal level conversion too? However, in my experience COM2 (pins 1 and 2) does does not expect an inverted signal, rather it seems your PICAXE does. From what I know, COM2 implements industry standard RS232 signal levels, i.e. positive voltage is a logical zero and negative voltage is a locical one and in the mini case these voltages are -12V and +12V respectively. On, the other hand TTL UART levels are usually active low (idle high) with GND for ones and Vdd for zeros and so these levels are kind of the inverse of RS232. Am I right?

#5 baxter

baxter

    Advanced Member

  • Members
  • PipPipPip
  • 415 posts

Posted 15 June 2013 - 08:17 PM

Hi hanzibal,

You are absolutely correct. My phraseology, "COM2 is expecting inverted RS232 signal levels" is imperfect. I should have said, "COM2 is expecting RS232 logic levels which are inverted relative to normal UART logic". COM1 idles high, COM2 idles low. From,

http://en.wikibooks....Driver_Receiver
 

     RS-232              TTL             Logic----------------------------------------------- -15V ...  -3V  <->  +2V ... +5V        <->  1  +3V ... +15V  <->   0V ... +0.8V      <->  0

I believe that 0V on RS232 is always interpreted as logic 1 because it is contained in the interval, (-3v < 0v< +3v). The voltage levels on RS232 are very loose (+/- 5V is perfectly ok). My USB/RS232 adapter has 0V on TX at idle. In any event, the inverter interface on COM2 works for me.
 

Here is another clever inversion circuit using common MOSFETs,

http://www.botkin.or...2_interface.htm

 

 

 



#6 NooM

NooM

    Advanced Member

  • Members
  • PipPipPip
  • 490 posts
  • LocationAustria

Posted 15 June 2013 - 09:48 PM

interesting. i just used a max232 for this, but your version is smaller in size wich is nice!



#7 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 16 June 2013 - 01:43 AM

@baxter: Thanks, I just wanted to make sure I got it straight. For me it's usually the other way around, I want two TTL UARTs and so that's why I didn't quite follow initially. Now it's perfectly clear.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.