I2C serial communication

Ok I haven’t been on the board lately… I have been fighting with my microcontroller!!!

I have been researching the I2C specification and it is pretty good. I have a motor controller that can be controlled from a serial port. The motor controller is the sabertooth.

The motorcontroller only requires that the TX line be connected to its screw terminal and the signal ground to 0 V terminal.

Is it possible to do asynchronous data over I2C? eg open an I2C port at say 9600 baud?

I2C and the likes of Dallas 1 Wire are all synchronous protocols so I am a bit confused on how else I should go about controling thed motors. I have 24 general I/O on my micro so should I wire up an DAC instead and use general I/O to write my byte?

The reason I am looking at other options is because my micro has both a DTE and DCE port but is restricting me to use only the DTE port. ultimately I need 2 serial ports so hence the attempt to use I2C or 1-wire.

Neil

You cannot easily make an I2C or 1-wire port behave as a regular async serial port.

But there are a couple of options for getting another serial port:

  1. Use the one port that you have and multiplex it to go to more than one device. Use a digital I/O pin on your MPU to choose which device you are currently talking to.

  2. I believe Dallas/Maxim makes a chip that converts 1-wire to async serial. I don’t have any experience with it, though.

  3. Use any digital I/O pin on your micro, and implement the async serial protocol in software. One (or both?) of your serial devices are 1-direction only, right? Such as your motor controller? If you only need to output serial data, doing it in SW is pretty easy. Receiving is a little harder, but still do-able.

Pete

hmmm - yeah I have seen some devices that go serial to 1-wire/I2C but not the other way.

yes you are right the device I want to control requires only one way communication. I could use a general I/O port pin and switch it on and off? here I would be simulating the activity of the TX line right?

The larger question for me is timing the sequencing so that my switching of that I/O pin is understood in the paradigm of 9600 baud - 8N1 serial settings.

how do I simulate in SW the TX line? (I have set my motor controller for 9600 baud - 8N1 serial )

Neil

Just browse the web to find an explanation of the protocol. For 8N1, you’ll be doing a total of 10 bits for each byte. The protocol is the same regardless of baud rate - the baud only changes the length (time) of the bits.
When the line is idle, it should be in the high state coming out of the MPU. The beginning of the start bit will be low, but that’s all I know without looking it up.

Note that you may or may not need a TTL-to-RS232 level converter (such as the MAX232 chip). Be sure you know the answer to this question, otherwise you may fry something when you hook it up.
Anything that connects to a PC serial port will be RS232 levels. But you may be able to simplify things by connecting your MPU directly to your motor controller, if it supports “TTL serial”. I do this with the SSC-32, for example, but I don’t know anything about the “Sabertooth” you mentioned.

Pete

Thats what I figured, I should be able to find some examples of SW controlled serial transmission based on a TX only (no flow control)

As for the TTL issue thanks for eminding me - I just got home with a bunch of new parts to build a cable to my DTE port - I WAS going to hook it up to my pc - I am using a USB to serial adapter on the PC side.

I might have fried something! I know my microcontroller does TTL but the DCE port might suport true RS232 levels because the loader port hooks directly to the PC and works fine… either way … better to play it safe.

thanks for the info I am going to do some research now because controlling the serial via software and a single bit port would be the best use of my micro leaving my serial port open for other devices.

Neil

Success!! haha!

so it turns out that when DTR was pulled on my DCE port (from a microntroller forum) my controller resets… this DCE port behavior prevented me from attempting to interface with the motorz

I decided to use a DTE serial cable I made with only a TX and signal ground and connected it to my motor controller (no DTR line). I then ran a terminal program over TCP/IP to my micro and started typing - the bytes were transmitted and sweet music from my motors came at different speeds and directions for each letter!!!

Now I can finally move on! I’ll write a higher lever java driver for the Sabertooth and that part of the bot should be done - complete with TCP/IP motor control or autonomous by my micro!!

hmmm I think I’ll go have a beer now.

Neil