cancel
Showing results for 
Search instead for 
Did you mean: 

non-inverted UART output

juerg
Associate II
Posted on February 27, 2013 at 09:28

Hi

I am trying to command a Pololu Maestro device from my STM32 device. The Pololu requires a non-inverted TTL signal for commands.

I can send out the command through an attached UART board to a hyperterminal session on my PC but as I understand the PL 2303 on that addon board inverts the signal. I actually wanted to use the SW-attached UART-Pin as Tx signal. I tried to find a setting for the UART or Pin to be non-inverting but could not see anything like that.

Can I define a Pin to be always in the inverted state of another Pin?

Juerg

#uart
20 REPLIES 20
trevor23
Associate III
Posted on February 27, 2013 at 10:45

The

PL 2303

you mention is RS232 serial I believe. The STM32 (like all processors) is TTL. So you need to convert from TTL to RS232. This is NOT just a matter of inverting the signal, the signal levels also need to be shifted (e.g. to plus and minus 12V). Google ttl to rs232 to see what you might need. If your goal is to get from STM32 serial to USB consider a TTL to USB converter cable instead of RS232 to USB -- you then skip conversion from TTL to RS232 and back again.

In answer to you direct question, no you can not invert the UART signals in software config (they are the way they are supposed to be). You could implement a ''bit bashed'' UART in software, with inverted pins, but this is for the experienced (and brave) only and can have performance issues for the whole of the system.

juerg
Associate II
Posted on February 27, 2013 at 11:21

Thanks Trevor

Just to have me get the things right - assuming my Pololu device allows for TTL inverted commands - would a STM32 Tx Pin connected to the Pololu Rx Pin be a working solution (both run with 5V and I have a ground connection in place for the 2 controllers) or should I better forget about such a connection?

Juerg

trevor23
Associate III
Posted on February 27, 2013 at 20:04

The STM32 UART is TTL, not ''TTL inverted''. If the device you refer to is also TTL serial then yes they may well work if connected together (if the device you mention is RS232 then no it won't work). If you wire them direct check that the STM32 UART rx pin is 5 volt tolerent (most are) if the deveice toy mention is 5 volt TTL. Make sure you wire output to input and input to output. Use some series resistance to prevent damage also.  Do you have more info or a link to the exact device in question?

emalund
Associate III
Posted on February 27, 2013 at 23:00

I'll bet you dollars to doughnuts that if your thingy requires ''inverted'' it also requires RS232 voltage Levels.

ALL units (I know of, and it's many) have the same polarity as  STM32 at TTL level and the inverse at RS232

Erik
Posted on February 27, 2013 at 23:18

What voltage control signal do servos require anyway? The STM32 should be able to drive 3V PWM signals into half a dozen servos.

Could we perhaps be specific about what board you're trying to drive, and cite a datasheet for peer review?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
juerg
Associate II
Posted on March 01, 2013 at 12:59

so what I have is a waveshare open107V board

    

http://www.wvshare.com/product/Open107V-Standard.htm

and a board for handling many servos, the Pololu Maestro 24 channels controller

    

http://www.pololu.com/catalog/product/1356

for the STM32 board I have a USART addon board with a USB connector and if I connect that to my PC I can see my commands on the hyperterminal.

The Pololu board has a USB connector but in addition also Rx and Tx for TTL level connection to other controller boards. So I think what Eric said does not apply in this combination but I also might be wrong there.

Here is the statement of the Pololu-supporter:

As far as I know, all the microcontrollers I am aware of, including the STM32s, can generate non-inverted serial signals. There are a lot of microcontroller boards on the market that give you raw access to the pins of the microcontroller without inverting or shifting their voltages. That is why the Maestro uses non-inverted serial; it makes it easy to control it from a microcontroller.

You haven't given me any details or schematics about the board you are using, but from your descriptions it sounds like there probably are inverters/level shifters on the board; you should figure out how to bypass those and just get raw access to the STM32's TX line.

Your plan to connect the two USB ports of the devices will probably not work. USB is an asymmetric protocol and USB devices need to be connected to a USB host, not another device. (However it could work if your STM32 board has USB OTG and you have the appropriate drivers for the Maestro.)

I am awaiting a USB adapter to be able to have a mini USB b to mini USB b cable so I can go on both controllers through the USB port. But as of the above statement this looks like being another full stop.

juerg
Associate II
Posted on March 01, 2013 at 20:50

Sorry for double posting, can't figure out how to get the copy deleted.

Now the Pololu guy states I need a 3.3 or 5V signal, idle high, start bit low, coming out of my STM32. USB-USB did not work (as I expected).

So I assume the HW guys will tell me to add a transistor or inverter chip to get the signal right but it looks like I won't be capable of coming up with such a setup (I am a softie and the possibility of getting + an - right is somewhere like zero and I don'tt know where to go for such items).

Hope to hear back from anybody anyway ...

trevor23
Associate III
Posted on March 02, 2013 at 11:25

As I keep saying,  the STM32 output (like all processors) is TTL (or somtimes called CMOS) serial at 3V3 (assuming your processor voltage is 3V3). It is already idle high. Thre is no inverted TTL anywhere --  so please stop saying ''inverted TTL'', it does not exist here and almost does not exist  any where else :). To tallk to another TTL serial port you just wire direct, as long as the voltages are ''similar''. Ensure output (Tx) goes to input (Rx) on the other side and visa versa -- you do not want to connect an output to an output or bad things will happen. TTL levels will be less forgiving if you make a mistake compared with RS232 as RS232 drivers have some fault tolerence built in. Good luck!

Just for your interest, to turn this TTL into RS232 you invert and shift the voltages -- this is usually done by a dedicated chip e.g. MAX232.

Posted on March 02, 2013 at 12:31

I'm with Trevor on the ''inverted'' situation, someone would have to go to quite some effort to make connectivity that difficult, and there don't appear to be many chips on the board.

The docs as I skimmed them seemed to talk about the serial port being usable in a USB-to-serial type fashion.

I would also be interested in knowing what voltage level is actually required for the servo control signals. The STM32 should be quite capable of generating 4 servo controls per TIM PWM unit. The envelope would be fine. If 5V was absolutely required I suppose it could be buffered, or you could use an FT pin driven in OD mode and pulled to 5V.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..