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

Designing circuit for custom PCB for Mini - best practice on RS232 vs TTL?


  • Please log in to reply
14 replies to this topic

#1 Frode

Frode

    Advanced Member

  • Members
  • PipPipPip
  • 202 posts
  • LocationNorway

Posted 24 April 2014 - 01:18 PM

Hi all, 

I've got a small custom PCB where I use a Mini to control a motordriver and some sensors. The Mini itself interfaces just fine with the other components on the PCB, but when I want to change the code on the Mini I have to remove it from the PCB, plug it into a small breadboard and use USB/RS232/TTL cables to program it.

 

I'd like to extend my custom PCB to include a micro-USB plug, and whatever supporting components I need to allow for programming the Mini without removing it from the PCB.

 

I'm still figuring out how to use the two RS232 vs TTL interfaces of the Mini, and wondered if anyone has any experiences to share when creating a custom PCB that allows me to program the Mini in-place.

 

I'd like to be able to 1) flash the firmware, 2) deploy new versions of my application and 3) debug. The last two are the most important ones.



#2 baxter

baxter

    Advanced Member

  • Members
  • PipPipPip
  • 415 posts

Posted 24 April 2014 - 05:52 PM

I started an Eagle Mini breakout board for the TI CC3000 WiFi module, but abandoned it due the flakey behaviour of the CC3000. The Eagle files are here,

https://www.dropbox....0g3u/jNoaSKjLnI

The serial interface is TTL (USB to serial adapter). COM2 (RS232, deploy) and COM1 (TTL) are switch selectable. The RS232 TX/RX inputs to the Mini are inverted TTL using a 74LVC2G14. The inversion for COM2 has been been tested by breadboarding and works just fine for deploying to the Mini.

Attached Files



#3 Frode

Frode

    Advanced Member

  • Members
  • PipPipPip
  • 202 posts
  • LocationNorway

Posted 24 April 2014 - 06:55 PM

Thanks, baxter!

 

So, let me see if I understand the schematic correctly...

 

You use ONE cable (a USB->TTL cable) from the computer to the TTLPort. Then you have a switch which allows you to change between RS232 and TTL. When set to RS232 the signal goes through the 74LVC2G14, and then to pins 1 and 2 on the Netduino.

 

When set to TTL the signal goes directly to pins 11 and 12.

 

Probably a basic question, but when do you set the switch to RS232, and when do you set it to TTL? Is it set to DEPLOY when you deploy from VS, and then you switch it over to S2 and powercycle the Netduino so that you can do live debugging?

 

Another basic question. My USB->TTL cable, as seen in the attached picture, is a 3v3 FTDI cable from Sparkfun. Is it similar to the one you use?

Attached Files



#4 baxter

baxter

    Advanced Member

  • Members
  • PipPipPip
  • 415 posts

Posted 24 April 2014 - 08:43 PM

I use RS232 (COM2) for deployment and debugging (flash the RS232 firmware). This Mini port is now dedicated to this function with this firmware. COM1 is free to do whatever you want with it. When you are debugging/deploying, set the switch to Deploy. When interacting  (and not debugging) with the Mini from your PC  via serial (e.g. talking, sending commands, etc), set the switch to COM1. One cable serves a dual purpose from your single PC COM port via the switch.

 

You could leave the switch out of the circuit by using another USB to serial, a Bluetooth SPP adapter or some serial component hooked directly to COM1 if your application requires serial I/O while debugging. However, the inverter is still necessary to use a USB to TTL cable on COM2.

 

I just use cheap Chinese USB to TTL cables (5V). Your 3.3V cable should work since a voltage level of greater than 2.0-2.7V will register as a logic 1,

https://learn.sparkf...tl-logic-levels



#5 Frode

Frode

    Advanced Member

  • Members
  • PipPipPip
  • 202 posts
  • LocationNorway

Posted 24 April 2014 - 08:49 PM

Aha, I understand. 

 

In my case I'm building an autonomous robot which does not communicate while operating, so I will only need RS232 for deploying and debugging.

 

The two TTL pins (11/12) are thus free to be used for sensors etc.

 

Thank you very much for you input, greatly appreciated!



#6 cys

cys

    Advanced Member

  • Members
  • PipPipPip
  • 113 posts
  • LocationSoCal

Posted 01 May 2014 - 07:04 PM

I use a low tech solution. When I want to update the mini embedded in my project pcb, I temporarily solder wires to the RS232 pins.



#7 Frode

Frode

    Advanced Member

  • Members
  • PipPipPip
  • 202 posts
  • LocationNorway

Posted 12 May 2014 - 08:43 PM

https://www.sparkfun.com/products/718

Can someone confirm that the breakoutboard in this link will work for programming the Mini via the RS232 pins?

If it does I think I'll include a microUSB and the FT232RL chip on my PCB for easy programming access.

#8 baxter

baxter

    Advanced Member

  • Members
  • PipPipPip
  • 415 posts

Posted 13 May 2014 - 02:19 AM

As is, it will not. It is a TTL cable. You want a cable that looks like this to program the Mini on COM2,

https://www.sparkfun.../products/11304

or others,
http://www.amazon.co...sl_3cliyfcfpj_b

The way to identify a TTL vs. RS232 cable is to measure the TX line with your meter. If it is a plus voltage corresponding to logic 1, then it is TTL; otherwise it is RS232. TTL idles high and RS232 idles low.

 

The DB9 connector is a pain in the ass. It's almost a big as the Mini. You don't need the full complement of RS232 signals; only TX, RX and ground for the Mini.  If you want to use the cable that you linked, then you can use the FTDI FT_PROG 2.8.2.0 - EEPROM Programming Utility to invert the TX/RX signals in the firmware,

 http://www.ftdichip....t/Utilities.htm

Otherwise, look back earlier in this thread (#2) on how to invert RS232 TX/RX with a simple 2 gate inverter. This has the advantage that you can use your linked  FTDI cable for either programming (COM2) or communicating (COM1); one cable for both. Just use a switch or jumper for selection.



#9 Frode

Frode

    Advanced Member

  • Members
  • PipPipPip
  • 202 posts
  • LocationNorway

Posted 13 May 2014 - 07:47 AM

baxter, thanks for being patient with me!

 

I've got a USB->DB9 cable, and got it hooked up to the Mini on the first pins, and that works. So I've got one functional setup. But, as you so eloquently put it, the DB9 connector is a pain in the ass.

 

I'm determined to put a micro-USB B plug on my PCB, and whatever chips I need to program the Mini via pins 1-3.

 

I do not have a logic level analyzer, so I'm having some trouble verifying the levels in the cables I've got here. Is the TTL Port in your schematics the same levels as in a standard USB cable?

 

What if I combine the FT232RL chip (from the breakoutboard above) with a gate inverter? That would do it, right?

So I'd connect the PC->micro USB B->FT232RL->gate inverter->Mini pins 1-3.

 

I tried finding the 74LVC2G14 on Farnell, but didn't find a direct match. What about TI's SN74LVC2G04DBVR?



#10 baxter

baxter

    Advanced Member

  • Members
  • PipPipPip
  • 415 posts

Posted 13 May 2014 - 09:05 PM

Quote:
"I'm determined to put a micro-USB B plug on my PCB, and whatever chips I need to program the Mini via pins 1-3."

----

Why do you want to put a micro USB on your board? Your linked Sparkfun breakout brings out Tx, RX and GND. Solder a pin header to these connections and connect to your Mini board with breadboard style jumper wires (female to female) to another 3 pin header. At this point, you now have TX, RX, GND on your Mini board. TX and RX must now be inverted before connecting them to Mini pins 1 and 2. You now have two options:
(1) invert TX/RX in the FTDI firmware
(2) Use the SN74LVC2G14DBVR to invert with hardware

It sounds as if you simply want a dedicated programming port. In which case, option (1) will provide the simplest solution. If you invert in the firmware, you will have turned your TTL cable into a RS232 cable. Mini pins 1,2,3  can now be connected directly to the 3 pin header.

----

Quote:
"What if I combine the FT232RL chip (from the breakoutboard above) with a gate inverter? That would do it, right? So I'd connect the PC->micro USB B->FT232RL->gate inverter->Mini pins 1-3."

----

Yes, but why duplicate the functionality of a USB to serial adapter on your Mini PCB? All of the components you see on the Sparkfun breakout would now be moved to the Mini. The only advantage I see to this is a prettier hookup; e.g. no breakout at the end of your cable. If this is the case, get a FTDI cable with different terminations and use a keyed 3 pin JST connector on your Mini PCB,

http://www.ftdichip....SBTTLSerial.htm

I think Adafruit sells one cheaper.

 

----

Quote:
"I do not have a logic level analyzer, so I'm having some trouble verifying the levels in the cables I've got here. Is the TTL Port in your schematics the same levels as in a standard USB cable?"

----

You don't need a logic analyzer; just a multimeter/voltmeter. Plug in the USB to serial adapter to your PC and measure the voltage from TX to GND. You should get a reading of 3.3V or 5V if it is TTL (depending upon the adapter)  and 0V-2.4V, if RS232. My USB to serial adapter is 5V (TX/RX) and I use the 5V output for VCC of the inverter.

----

Quote:

"I tried finding the 74LVC2G14 on Farnell, but didn't find a direct match. What about TI's SN74LVC2G04DBVR?"

----

You want the SN74LVC2G14DBVR from TI. I think the designation is unique to their Little Logic line of parts. It's widely available (Mouser, Digikey ...) The part with extra gates is 74HC14 If you have a .com or .edu address and register with TI you can get free samples.

----



#11 Frode

Frode

    Advanced Member

  • Members
  • PipPipPip
  • 202 posts
  • LocationNorway

Posted 13 May 2014 - 09:53 PM

The board I'm creating is going to be put in a very tight spot inside a small chassis, and I'd like to avoid the three pin header, and rather have one nice small USB hole in the side of the box. This is also a setup I'll be travelling around with so I'd like to avoid to rely on special cables and breakoutboards while I'm on the road. Just my laptop, a standard micro USB cable and my device would be the dream scenario.

The sparkfun breakout board was just for reference, I haven't actually got it. I agree that I would have to put all the components on that board onto my pcb, but I'd be ok with that.

I'll look into how inverting the levels in the FTDI firmware works. If that turns out too complicated I'll put on the device you suggested.

#12 Frode

Frode

    Advanced Member

  • Members
  • PipPipPip
  • 202 posts
  • LocationNorway

Posted 13 May 2014 - 10:21 PM

There is one thing I don't understand about the level inverting chip... As I understand it going from TTL to RS232 isn't just a matter of changing all lows to highs, and all highs to lows, but also changing the voltage levels.

TTL uses 0 for low and 5V for high, but RS232 uses negative voltage (less than -3V) for high, and positive (more than 3V) for low. At least according to this article: https://www.sparkfun.com/tutorials/215

I'm looking at the datasheet for the SN74LVC2G14DBVR, but cannot see any indication that the voltage for the logic levels change, only that it will invert the signal. Does it do more than change 0V to 5V, and 5V to 0V?

#13 baxter

baxter

    Advanced Member

  • Members
  • PipPipPip
  • 415 posts

Posted 14 May 2014 - 04:29 AM

The Schmitt-trigger inverter is not emulating a true RS232 interface. It is simply fooling the Mini. The RS232 transistion region is contained in the interval, +/- 3V. 0V is in this interval. The RS232 idle state should have a negative voltage less than -3V. I measured my USB to RS232 adapter input to Mini TX at idle and it is -0.82V. The empirical evidence seems to suggest that a volltage level in the transition region is always interpreted as a logic 1. The Schmitt-trigger inverter is working like Fig. 1 of this reference,

http://www.seetron.c...erial_coms.html

Notice that 0V falls in the logic 1 region in Fig 1. All I can tell you is that it works. I have used it with several Mini projects.

 

The FTDI programmer is easy to use. As I recall, the only thing you need to do is enable a check box in the GUI for the inversion.



#14 Jack Chidley

Jack Chidley

    Advanced Member

  • Members
  • PipPipPip
  • 99 posts

Posted 18 May 2014 - 05:04 PM

I do not have a logic level analyzer


I resisted getting a logic analyser for a long time. Then I bought the logic from www.saleae.com and it changed everything. Be warned though, Saleae are introducing a new range this year.

I'm beginning to think that an oscilloscope is required to. Rigol probably.

Oh, and it nearly drove me insane trying to get TTL to work with the mini. So is gave in and bought a USB/RS232 converter, as recommended by Chris Walker.

Jack

#15 Frode

Frode

    Advanced Member

  • Members
  • PipPipPip
  • 202 posts
  • LocationNorway

Posted 18 May 2014 - 08:43 PM

I've pre-ordered the logic analyzer from Saleae a few weeks ago, hoping it'll be here in a couple of months.

I'm designing the board in a baxter-inspired way, with an FT232RL for USB-to-UART, and a SN74LVC2G14DBVR inverter. I'll post here when I've tested the circuit.




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.