Serial communication with Baby o& Pololu AVR programmer usb

Products that I have: https://www.pololu.com/catalog/product/1302, Arduino uno;
programming software/libaries: AVR Studios 6, Arduino 1.0.1, Pololu library installed.


#include <avr/io.h>
#include <pololu/orangutan.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <pololu/OrangutanSerial/OrangutanSerial.h>


char send_buffer[100];

unsigned int MilliVolt=OrangutanAnalog::toMillivolts(OrangutanAnalog::read(0));
int Volts[100];


int main()
{
    while(1)
    {
        for(int i=0;i<100;i++){
	Volts[i]=MilliVolt;
        }
        memset(send_buffer,MilliVolt,100);
        OrangutanSerial::sendBlocking(send_buffer, strlen("Calibrating position sensors..."));
    }
}

How do I display MilliVolt from the code above with either AVR studio or Arduino using my baby o and Pololu Avr Programmer usb?

Hello. It looks like you are trying to use the C++ interface to our libraries. Are you OK with using the C interface instead? That will make life easier for you because all of our example code and Atmel Studio templates use C.

The general instructions for getting started with Atmel Studio are in the Pololu AVR Programming Quick Start Guide, and they should get you most of the way there:
pololu.com/docs/0J51

There are a lot of problems with your code, but you should make sure that you can program a basic demo onto your Baby Orangutan with Atmel Studio 6 before trying to write your own code.

–David

Think you for answering me David.

I noticed that i forgotten setBaudRate in the program, but this just a symptom not the cause of my probelm.
This might be stupid question, but i just want to know if I’m correct. i connect PD1 tx to the Rx on the pololu Avr programmer usb
and i connect PD0 Rx to the Tx on the pololu Avr programmer usb.
i been looking one of the Serial example
https://www.pololu.com/docs/0J20/3.h
Should i install the Br@y Terminal to see the analog to digitial data.

Yes, your proposed wiring is correct. Also, don’t forget to connect the GND pins of both devices. Yes, you would have to install Br@y Terminal or some other terminal program to look at the data sent by the Baby Orangutan.

–David

I modified the example for this site: https://www.pololu.com/docs/0J20/3.h .
here the modified code.

void process_received_byte(char byte)
{
    switch(byte)
    {
        // If the character 'G' is received, set PC1 high
        case 'G':
            set_digital_output(IO_C1, HIGH);
            break;
 
        // If the character 'g' is received, set PC1 low
        case 'g':
            set_digital_output(IO_C1, LOW);
            break;
 
        // If the character 'c' is received, set PC2 high
        case 'c':
            set_digital_output(IO_C2, HIGH);
            break;
 
        // If the character 'd' is received, set PC2 low
        case 'd':
            set_digital_output(IO_C2, LOW);
            break;
 
        // If any other character is received, change its capitalization and
        // send it back.
        default:
            wait_for_sending_to_finish();
            send_buffer[0] = byte ^ 0x20;
            serial_send(send_buffer, 1);
            break;
    }
}
int main()
{
    // Set the baud rate to 9600 bits per second.  Each byte takes ten bit
    // times, so you can get at most 960 bytes per second at this speed.
    serial_set_baud_rate(9600);	
    // Start receiving bytes in the ring buffer.
    serial_receive_ring(receive_buffer, sizeof(receive_buffer));
	set_digital_input(IO_C1,HIGH_IMPEDANCE);
	set_digital_input(IO_C2, HIGH_IMPEDANCE);
	    while(1)
    {
        // Deal with any new bytes received.
        check_for_new_bytes_received();
 
        // If the user presses the middle button, send "Hi there!"
        // and wait until the user releases the button.
        //if (button_is_pressed(MIDDLE_BUTTON))
        //{
           wait_for_sending_to_finish();
            memcpy_P(send_buffer, PSTR("Hi there!\r\n"), 11);
            serial_send(send_buffer, 11);
            // Wait for the user to release the button.  While the processor is
            // waiting, the OrangutanSerial library will take care of receiving
            // bytes using the serial reception interrupt.  But if enough bytes
            // arrive during this period to fill up the receive_buffer, then the
            // older bytes will be lost and we won't know exactly how many bytes
            // have been received.
            //wait_for_button_release(MIDDLE_BUTTON);
       // }
    }
}

Can some please explain why PD1 is not changing, it’s a constant High and can someone help me with Br@y Terminal for serial purposes?

It looks like you have modified our code so it should just constantly be writing “Hi there!” to the serial port. That’s a little bit extreme; could you add a “delay_ms(1000);” somewhere in the main loop so it only does that every second?

I’m not sure why TX/PD1 would just stay high constantly. I would expect it to go low several times while transmitting serial bytes. How are you looking at the signal on PD1?

What kind of trouble are you having with Br@y terminal? Did you try choosing the right COM port, choose the baud rate (9600), and clicking “Connect”? If you told me more details about what are you doing, I might be able to tell what is going wrong.

–David

Thank you for help the David.