Serial communication

I was reading the examples and documentation but I haven’t found if is possible to use the orangutan to establish a serial communication with the 3pi robot.
I need to debug some filter and the easy way is to send to the serial interface the filtered values and then using gnuplot or octave to plot the response function.

Any suggestion?

You can use the serial functions of our AVR library on the 3pi, a Baby Orangutan B, or an Orangutan LV-168 to communicate with another of these boards or with a PC. But I’m not sure why you want to put an Orangutan between the 3pi and the PC - you can go directly from the 3pi to a PC with the appropriate level shifter, like this one.

O right!
I will order that with the next order.
I find difficult to browse the documentation online, is it possible to produce a pdf from the html with all the libraries?
:blush: so i can print it out as a reference manual.

cheers.

We’re planning to produce PDF manuals in the future. For now, you can click View entire document on a single page on the top-level page of the document, then Print directly from your web browser or click the Print icon at the bottom of the page. Our web pages are designed to print reasonably well; please let us know if something isn’t readable.

O right is fine now!
I think there’s an error in the documentation

This should be:

because in the libraries there’s no reference to a class called OrangutanDelay.

:wink:

Hello.

I’ve corrected the command reference; thanks for catching that!

- Ben

I’m trying to use the serial communication as you suggested (with the orangutan) and AVR libraries:

int main()
{
	lcd.clear();
    	lcd.print("Serial!");
	OrangutanSerial::setBaudRate(115200);
	float output=0.0;
	char test[3]={'P','A','O'};
	char length = strlen(test);
	
	OrangutanPushbuttons::waitForPress(TOP_BUTTON);
	lcd.print("Sending!");
	OrangutanSerial::sendBlocking(test,length);
	lcd.print("Sent!");
	OrangutanPushbuttons::waitForPress(TOP_BUTTON);

return 0;
}

Using the ArduinoTerminal or the CuteCome in Kubuntu Hardy, I don’t read any character from the USB port.
What I’m missing here? Maybe the settings of the terminal program?


What happens if you try turning off the hardware and software handshaking?

- Ben

Also, you definitely don’t want to use strlen() to get the length of that string! That is a run-time function that will read the string, looking for a null (0) character signifying the end of the string, which will cause it to read past the bounds of your array. Instead, you want to use sizeof(), since the size of the array is defined at compile time.

Yes true so I also tried:

int main()
{
	NeuronBP nrnbp;
	lcd.clear();
    	lcd.print("Serial!");
	OrangutanSerial::setBaudRate(115200);
	float output=0.0;
	char test[4]={'P','A','O','\0'};
	//char length = strlen(test);
	lcd.clear();
    	lcd.print("Len:");
	lcd.print(length);
	OrangutanPushbuttons::waitForPress(TOP_BUTTON);
	lcd.print("Sending!");
	OrangutanSerial::sendBlocking(test,3);
	lcd.clear();
	lcd.print("Sent!");
	OrangutanPushbuttons::waitForPress(TOP_BUTTON);


 

return 0;
}

I also tried handshake hardware and software all the combinations.
To make a test I opened it before doing programming (make programming) and I can read the instructions sent to the orangutan by the avrdude:

How are you connecting the serial port to your 3pi? The library uses the PD0/PD1 serial port, not the USB programmer; but you can reconfigure your USB programmer as a USB-serial adapter. Is that what you are doing?

Hmm I need to use the USB port because all the computers we have don’t have the serial port.
So maybe this would be better?
posting.php?mode=reply&f=29&t=1208

Is it easy to re-configure the orangutan for USB communication?

It should be pretty easy: Moving the jumper from the “P” position to the “U” position on the programmer will turn it into a TTL-level USB-to-serial converter. Take a look at the User’s Guides for more information - you’ll have to make connections from the serial I/O pins on the programmer to the PD0/PD1 pins on your 3pi expansion port.

And don’t forget to connect the ground pad (G) on the adapter/programmer to ground on your 3pi!

- Ben

oky so in brief I need to do in order:
[ul]
change the jumper mode
solder the PC TX from orangutan to PD0 (USART input pin (RXD))
solder the PC RX from orangutan to PD1 (USART output pin (TXD))
solder the GROUND from orangutan to GND
[/ul]

am I correct?
On monday I can use the lab to solder the wires, I’ll probably use the expansion board on the top to access the PD0 and PD1.

Yes, those connections sound right. But I would suggest that you solder header pins to both sides and use a removable cable like a servo cable to make the connection. It’s probably not a good idea to solder them together permanently!

Yes indeed! I’m finding the proper connectors!

Hello,

I have a similar problem as the one discussed in this thread, however my setup is different.
I have a 3pi robot and have attached a AD 595 thermocouple to it using the ADC6 port on the robot.
I am successfully taking analog readings on this port and displaying the calibrated readings on the LCD screen of the 3pi.
I am also attempting to use the PD0 and PD1 / TX and RX lines on the robot to send the values to my
computer through usb using the 3pi programmer’s TX and RX lines. I have successfully tested and
used the example code on https://www.pololu.com/docs/0J20/6.j , however
I cant seem to successfully recieve the values the 3pi is reading into my program.

I am using visual basic with mscomm to communicate with the TTL serial port and recieve data from the 3pi
here is my code:

#include <pololu/3pi.h>
int main()   
{   


serial_set_baud_rate(9600); 
set_analog_mode(MODE_10_BIT);
unsigned int temp;
print("     ");

while(1)
{
lcd_goto_xy(0,0);           				// LCD cursor to home position (upper-left)   
print_long(to_millivolts(analog_read(6)));                        // trimpot output in mV   
print(" mV  ");            			             // added spaces are to overwrite left over chars   

lcd_goto_xy(0, 1);                                                         // LCD cursor to start of the second line   
unsigned int temp = ( 5.0 * analog_read(6) * 100.0)*10 / 1024.0;  // get temp in tenths of a degree C
print_long(temp/10);                                                                   // get the whole number of degrees   
print_character('.');                                                                     // print the decimal point   
print_long(temp - (temp/10)*10);                                                // print the tenths digit   
print_character(223);                                                                  // print a degree symbol   
print("C  ");                                                                                // added spaces are to overwrite left over chars   
}

}

The problem I think I am having is converting the integer to char and then sending using the library functions,
but I can’t seem to get very far. Can you guys help?

Thanks,

Hello,
There is no “3pi programmer”, so it is hard to tell from your description how your setup is different. But if you post some code that you tried, then tell us what you expected it to do and how it failed, maybe we can help you. Otherwise, for converting integers to characters, you could start with something like

char c = '0' + i; // works for values of i from 0 to 9
and work up from there.

-Paul

Thanks for the prompt reply,

Please excuse my ignorance, I may be following an unorthodox programming method since I use visual basic for my communications programs and am still learning how to use the 3pi properly, so I appreciate your patience.

The following is the code I have used to program my 3pi using the usb avr programmer, and I also used a visual basic program to open a connection ( the program I made uses the mscomm32.ocx component) with the TTL serial port provided by the avr programmer to take input from the PD1 line of the 3pi robot to the rx input on the programmer.

#include <pololu/3pi.h>
int main()   
{   


serial_set_baud_rate(9600); 
set_analog_mode(MODE_10_BIT);
unsigned int temp;
print("     ");

while(1)
{
lcd_goto_xy(0,0);           
print_long(to_millivolts(analog_read(6)));             
print(" mV  ");      

lcd_goto_xy(0, 1);                 
unsigned int temp = ( 5.0 * analog_read(6) * 100.0)*10 / 1024.0;
print_long(temp/10);
print_character('.');
print_long(temp - (temp/10)*10);
print_character(223);
print("C  ");
serial_send_blocking(temp, 10);
delay_ms(100);
}

}

I am assuming I only need to get the dang program to send proper values to the rx line on the programmer for my program to pick up the values, however I am not sure exactly what the 3pi is sending back to the computer. Must this value (temp) I am acquiring be a character array for it to be properly picked up as a bitwise transmission to the comm port?

What would you recommend to be the best way to send these values to my computer?

Thanks