Interesting thought....

Not that I actually intend to try this, if it is possible, except perhaps for educational purposes, but would it be theoretically possible to generate your own serial communation/TTL port, through a Digital IO. Setup a timer and interrupt to get the right baud rate, and just set a digital output to either 0 or 1 at each interrupt, so it would operate like a TX signal. TTL uses the 0V to 5V logic, correct? If the signal pin doesn’t provide enough voltage, maybe just let it trigger a transistor, which is connected to 5V.

Mostly, I’m asking this to confirm my understanding of how serial communication actually works, and I’m guessing I’m still a little bit off. It seems a tad too simple, the way I explained it. And if I am understanding things correctly, my next guess is that the interrupts will be triggering too often, slowing down the rest of the code. Am I on track at all?

You are 100% correct that it would be possible, and I am sure some of the serious codeheads will expand upon the most efficient way of doing it… although it sounds like you are heading in the correct direction.

In fact I have done something very similar using the PIC 16F627 and 16F84 series of chips using the “SEROUT” and “SERIN” commands of PIC Basic Pro from MELABS.

While it is convenient to use the commands in PIC Basic Pro, all they do is… as you suggest… turn digital I/O pins on and off.

More advanced PICs, such as the 18Fwhatevers in the RC actually have serial ports built in to them that handle a lot of the timing and I/O at a chip level, rather than having to run your own code… but those work only on certain pins. It doesn’t mean that you couldn’t program your own serial port onto any other series of pins. In fact USB and ethernet connections have both been programmed into PIC microcontrollers as well… they are just another rapid series of one’s and zeros… albeit with a somewhat more sophisticated logic and timing than RS232.

Don’t feel obliged to work only with the RC… take a look at some of the different PICs available either as free samples from Microchip, or through Digikey/other on-line vendors. It is amazing how much computing power you can get for just a couple of bucks!

Jason

It’s a good thought. Any regular RC digital pins and one of the internal timers are all you need.
I found it to be an insightful exercise and did an example using an LCD as an output device.

It’s a good excuse to expand to other chips and external processors too as Jason suggests.

P.S.
Just remembered Kevin Watson mentioned he had an example of serial communication such as this as well. I found it on his website with the 2005 code examples.

Well, if it really is that easy, maybe I will try it. After all, there aren’t many other uses for a Digital Output. In fact, I can’t really think of one at all, unless you count LED feedback, which can’t be done directly.

While FIRST limits the uses to which a digital output can be put simply to ensure that motors and relays are all hooked up and running in a safe, controlled and easily inspected manner, there is no reason that a digital output can’t be used to drive a speed controller, or any number of other uses. We use the digital outputs on a PIC 16f627a to drive an H-bridge chip that runs the mini-sumo robots we build in our engineering class.

In FRC robots, however, the main uses for these pins are as digital inputs, particularly as interupts, limit switches, etc. When you examine the data sheet of the PIC chip that drives the RC in more detail you will appreciate just how many different things the different pins on the PICs can be used for, and how elegantly Microchip has structured their design.

While I agree with you that under FIRST rules there are restrictions on the use of digital outputs (and with all the PWMs and Relay outputs available, it’s usually not a big deal) but in other applications the digital outputs are quite useful.

Jason

Excellent point. Our team really has never ventured too far beyond FIRST, thus I’ve never been given much reason to think that way. I’ve been trying to lately though, and hopefully I can spread this mindset to the rest of the team.

It would be neat to see some code written and published that would provide a port3 serial port based on one or two digital IO pins.
Maybe that could be my project for the summer.

I’m sure that if you look around many hobbyist robotics sites for programming you can probably find some sort of code that will handle serial communication to learn from then its just a matter of take that and write your own.