Now I know the gut reaction of all you good, community-minded CD users is to point me to a search of the forums for this information, but I have already done that. After spending an hour or two looking on several websites, I could not find a complete explanation of how the TTL (and program) port works and how to use it. I understand the topic might be too big for a single resource to cover it, but even an introduction is lacking. Some of the things I’d like to know are
what does the protocol specify (i understand it is very loose)
I think he’s talking about the TTL serial port on the EDU-RC. It should be functionally identical to a regular serial port, except with much lower voltage levels required for signalling.
He’s talking about the TTL (Transistor-Transistor Logic) port on the 2004 Robot Controller.
The TTL port is a direct link to the User Processor in the RC and is basically a non-level-shifted version of the program port (which is RS232). Both of them can be used (with or without level-shifting) to communicate with other serial devices like CMUcams, computers, other RCs, and so forth.
In short, it’s another serial port. How do you use it in the progrmaming? Don’t ask me.
Oh, and the pinout (as copied from the Innovation FIRST RC reference guide) is
From left to right, +5v, TX (transmit), RX (recieve), B (ground)
To my knowledge, TTL uses an almost identical format as RS-232, the difference is that it uses different voltages. The wave forms are identical, though.
RS-232 is 1 = -3v to -25v; 0 = 3v to 25v.
TTL is (generally) 1 = 5v; 0 = 0v.
In the RCs, the Prog port is USART1 in api, the TTL is USART2.
In the MCC18 Libraries Doc (C:\mcc18\doc\MPLAB-C18-Libraries.pdf), the API info can be found in section 2.10 (p. 58). There is probably more info on Microchip’s web site, but that’s down at the moment.
Astronouth7303,
Here is the code we used to talk to a second micro that was keeping track of our position. It uses the TTL port. The documentation supplied didn’t mention setting the port directio registers (See the first couple of lines in the SensorInitializePort() routine). The EDU Bot did it for you but the RC requires that you do it yourself. If you want the source files PM me and I’ll email you the files.
Gene F. Team 343 Metal in Motion
AAARRRGGG!!! The tabs all got removed when I posted the code! If anyone needs/wants the actual source code PM me.
PURPOSE: Opens the serial port 2 for communicating with the scensors at
19.2k baud, 8 bits, no parity, one stop bit, and no flow control.
CALLED FROM: user_routines.c
ARGUMENTS: none
RETURNS: void
*******************************************************************************/
void SensorInitializePort (void)
{
// Set up TX pin as an output and RX as an input.
TRISGbits.TRISG1 = 0;
TRISGbits.TRISG2 = 1;
/* Code to read Bills device. /
/******************************************************************************
FUNCTION NAME: ReadSensorPack
PURPOSE: Talks to the sensor pack to read the current data
CALLED FROM: user_routines.c
ARGUMENTS: none
RETURNS: void
*******************************************************************************/
void SensorPackRead (void)
{
int i, j;
RCSTA2bits.CREN = 1; // Re-enable the receiver
// Send an STX to the sensor pack to tell it to send the data
putc2USART(STX);
// Loop for the number of characters in the sensor pack data
for ( j = 0; j < 8/sizeof(SensorPackType)/; j++ )
{
// Wait a finite amount of time for the next character to arrive.
for ( i = 0; i < 2500; i++ )
if ( DataRdy2USART())
break;
// If a character arrived (we didn’t timeout)
if ( i != 2500 )
{
// Grab the next charcter from the USART and place it in our data structure
Sensors.chars[j] = getc2USART();
}
else
{
// If it failed then clear any possible errors
RCSTA2bits.CREN = 0; // Disable the receiver
RCSTA2bits.CREN = 1; // Re-enable the receiver
printf("Rx Fail DataRdy = %d
",(int)DataRdy2USART()); /* printf EXAMPLE */
}
}
RCSTA2bits.CREN = 0; // Disable the receiver
// printf("x=%6d,y=%6d,pe=%6d,dd=%4d,ae=%4d
", Sensors.LeftOdom, Sensors.RightOdom, Sensors.PosError, (int)(unsigned char)Sensors.DDCompass, (int)( char)Sensors.AngleError );
}