Serial communication and controlling

Hi, my project involves serial communication with atmega328p baby orangutan, but I’m a little confused by the use of controls serial_send serial_send_blocking, there is little information about them, even in Pololu AVR Library Command Reference, as is the syntax of these commands?
second question, how can I send commands to baby orangutan (eg as set_motors (30, 30)) using a terminal (Br @ y terminal or Windows HyperTerminal)? would be hex? ASCII? binary?

Hello,

It sounds like you have not read over the serial sections of the Command Reference and User’s Guide. The syntax is precisely specified in the command reference, and there are examples in the user’s guide - so can you ask a more specific question?

As for your second question, that is up to you. You could, for example, try modifying our “3pi-serial-slave” program, which uses binary commands. You would generally type binary commands in hex with something like Br@y terminal. But if you prefer ASCII and hyperterminal instead, nothing will prevent you from writing an ASCII command interface.

-Paul

Excuse my ignorance, I looked but did not see the real sitaxe. :blush:

to communicate using a program like br@y terminal, as will be the command or syntax for starting the BABY-O motors ,(ex set_motors (10,10))? ,will be something like a “AT + command in hex”? where can I get these commands?

Hello,

It sounds like you are pretty confused about the basic things that are going on here. For example, “set_motors” is the name of a C function, not a command that you can send over the serial port. You will have to set up any commands that you want yourself. This is a complicated project, so you should take it one tiny step at a time. My recommendation:

First, make sure you are comfortable programming your Baby Orangutan with simple code (e.g. blinking an LED, running motors) - without any serial communication.

Next, add the following code to the beginning of your program:

	char buffer[100];

	// start receiving data at 115.2 kbaud
	serial_set_baud_rate(115200);
	serial_set_mode(SERIAL_CHECK);
	serial_receive_ring(buffer, 100);

	// wait for a command
	char command = read_next_byte();

To test it, send a byte (any byte at all) to your Baby Orangutan at 115200 baud. It will not run the rest of your program until the byte is received, so this should verify that the serial connection is working.

If you get that far, then you can start working on specific commands.

-Paul

After having posted the question,i realized that there is no specific command, what you should do is create your own, and link to what it BABY-O should do thank´s for your hep!

Hello,

I just realized that the “read_next_byte” function that in the code I posted is actually not part of our library - it is defined in the 3pi-serial-slave example. So you might have to look at that example for help after all.

Good luck!

-Paul

thanks for your help, Paul.
this is a small contribution to that had the same idea (or problem) is a simple control, with the Br @ y terminal.
the code has some minor bugs, but works. :blush: :laughing:
set at 9600 bps and ASCII mode.

// simple 
// control with br@y terminal
//by sidnei0240

#include <pololu/orangutan.h>
#include <stdlib.h>

   char dadosin[8];
	int  dadosint;
    
   int main()
    {
             
       serial_set_baud_rate(9600);
       serial_send_blocking("BABY-O V1.0 online\r\n", 20);// my welcome msg !! 
     
      
  while (1)
   {
   serial_receive(dadosin,1);
   while (serial_get_received_bytes() < 1);

   dadosint = atoi (dadosin); // convert char to int 
 switch (dadosint)
 {
  case  0: // case press keyboard "0"
  serial_send_blocking("stop\r\n",6);
               	
                set_motors(0,0);
              break;

case  1:
  serial_send_blocking("go\r\n",4); //case press keyboard "1"
               	
                set_motors(30,30);
                break;

				case  2:
  serial_send_blocking("back\r\n",6);//case press keyboard "2"
               	
                set_motors(-30,-30);



	          	
                       
  
   
   }
}   
}