go_away

Author Topic: $50 roboduino robot problem  (Read 2074 times)

0 Members and 1 Guest are viewing this topic.

Offline I Am BlashyrkhTopic starter

  • Jr. Member
  • **
  • Posts: 18
  • Helpful? 0
$50 roboduino robot problem
« on: April 23, 2009, 03:50:30 PM »
I am working on a $50 robot (the roboduino version) and I am following the directions in programing but I have a couple problems:

First, when I do the build it says build succeeded with 2 warnings. There are no errors but the warnings are:
"uart.c: 70: warning: pointer targets in passing argument 2 of 'bufferInit' differ in signedness"
"uart.c: 72: warning: pointer targets in passing argument 2 of 'bufferInit' differ in signedness"
Do these matter? Does anyone no what they mean?

Second, I wanted to program the roboduino through the bootloader and it says to be written soon. Can any one else please help me navigate my way through programing it using the USB bootloader? Please?!

Offline Tazdevil

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
Re: $50 roboduino robot problem
« Reply #1 on: May 26, 2009, 07:52:39 PM »
I am getting the same warnings did you ever figure out why?

I haven't realy tried digging into it yet just got the uart to talk to the PC serial port on my first try at making the hardware. Not too good with C yet as I just started to learn that also. Looks like I have a long road ahead but the tutorials are great for geting going.

Offline awally88

  • Robot Overlord
  • ****
  • Posts: 212
  • Helpful? 0
Re: $50 roboduino robot problem
« Reply #2 on: May 27, 2009, 12:05:35 AM »
Can you post the code segment?

Offline Tazdevil

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
Re: $50 roboduino robot problem
« Reply #3 on: May 27, 2009, 04:15:58 AM »
Here is the code I have been playing with. I think the error started when I added the serial port Uart support to this project which is the photovore.c with my changes. I looked around a little and see I was looking in uart.h not uart.c so the line numbers make a little more sense. I am very new to C only up to chapter 7 in the 24 hour book! so I may be overlooking something very simple.

what is signedness?

Thanks for the response!

uart.c: In function 'uartInitBuffers':
uart.c:70: warning: pointer targets in passing argument 2 of 'bufferInit' differ in signedness
uart.c:72: warning: pointer targets in passing argument 2 of 'bufferInit' differ in signedness


from uart.c

Comment is LN65

// create and initialize the uart transmit and receive buffers
void uartInitBuffers(void)
{
   #ifndef UART_BUFFERS_EXTERNAL_RAM
      // initialize the UART receive buffer
      bufferInit(&uartRxBuffer, uartRxData, UART_RX_BUFFER_SIZE);
      // initialize the UART transmit buffer
      bufferInit(&uartTxBuffer, uartTxData, UART_TX_BUFFER_SIZE);
   #else
      // initialize the UART receive buffer
      bufferInit(&uartRxBuffer, (u08*) UART_RX_BUFFER_ADDR, UART_RX_BUFFER_SIZE);
      // initialize the UART transmit buffer
      bufferInit(&uartTxBuffer, (u08*) UART_TX_BUFFER_ADDR, UART_TX_BUFFER_SIZE);
   #endif
}


/****************************************************************************
*
*   Copyright (c) 2007 www.societyofrobots.com
*   (please link back if you use this code!)
*
*   This program is free software; you can redistribute it and/or modify
*   it under the terms of the GNU General Public License version 2 as
*   published by the Free Software Foundation.
*
*   Alternatively, this software may be distributed under the terms of BSD
*   license.
*
*   Photovore v1, March 10th, 2007
*   Simple case-based method for a robot that chases light.
*
*
****************************************************************************/

//SoR Include
#include "SoR_Utils.h" //includes all the technical stuff


int main(void)
   {
   //declare variables here
   //int i=250;//a 'whatever' variable
   int sensor_left=0;//left photoresistor
   int sensor_right=0;//right photoresistor
   int threshold=8;//the larger this number, the more likely your robot will drive straight
   int ADC3test=0;

   /****************INITIALIZATIONS*******************/
   //other stuff Im experimenting with for SoR
   uartInit();  // initialize the UART (serial port)
   uartSetBaudRate(38400);// set the baud rate of the UART for our debug/reporting output
   rprintfInit(uartSendByte);// initialize rprintf system

   //timerInit(); // initialize the timer system
   
   configure_ports(); // configure which ports are analog, digital, etc.
   a2dInit(); // initialize analog to digital converter (ADC)
   a2dSetPrescaler(ADC_PRESCALE_DIV32); // configure ADC scaling
   a2dSetReference(ADC_REFERENCE_AVCC); // configure ADC reference voltage

   rprintf("Initialization Complete\r\n");
   /**************************************************/

   
   /*********ADD YOUR CODE BELOW THIS LINE **********/
   LED_off();//turn LED on


   while(1)
      {
      //store sensor data
      sensor_left=a2dConvert8bit(5);
      sensor_right=a2dConvert8bit(4);
      ADC3test=a2dConvert8bit(3);
rprintf("Pd3=: %d\r\n", ADC3test);
delay_cycles(500000);
rprintf("Sensor right: %d\r\n", sensor_right);
rprintf("sensor left: %d\r\n", sensor_left);

      //output message to serial (use HyperTerminal)

      //detects more light on left side of robot
      if(sensor_left > sensor_right && (sensor_left - sensor_right) > threshold)
         {//go left
         servo_left(468);
         servo_right(468);
         }

      //detects more light on right side of robot
      else if(sensor_right > sensor_left && (sensor_right - sensor_left) > threshold)
         {//go right
         servo_left(220);
         servo_right(220);
      
         }

      //light is about equal on both sides
      else
         {//go straight
            rprintf("Pd3=: %d\r\n", ADC3test);
delay_cycles(500);
rprintf("Sensor right: %d\r\n", sensor_right);
rprintf("sensor left: %d\r\n", sensor_left);
      //   servo_left(25);
      //servo_right(44);
         }


      /* Servo Test Code
      i=250;
      while(i>0)
         {
         servo_left(40);
         i--;
         }

      i=250;
      while(i>0)
         {
         servo_left(24);
         i--;
         }
      */

      //rprintf("Initialization Complete\r\n");
      
      //output message to serial (use hyperterminal)
      //print("Hello, World! Read My Analog: %u\r\n", sensor_0);

      delay_cycles(5000);//a small delay to prevent crazy oscillations
      }
   /*********ADD YOUR CODE ABOVE THIS LINE **********/

   return 0;
   }


/*********************COMMAND LIST*************************

delay_cycles(cycles);
Delays - you can make your robot wait for a certain amount of time with this function.
Put the number of computational cycles to delay in the ().
23 cycles is about .992 milliseconds
to calculate: 23/.992*(time in milliseconds to delay) = cycles
Check servo datasheet where it says: 'Direction: Clockwise/Pulse Traveling 1500 to 1900usec'


servo_left(speed); and servo_right(speed);
Commands your servos to rotate at a certain speed.
Vary speed (which represents a delay in cycles) from 20 to 50.
Left is for port D0 and right is for port D1.


LED_on(); and LED_off();
Turns on and off your LED. The LED is on port D4.
By bringing port D4 low, you are turning on the LED.


variable=a2dConvert8bit(pin);
Reads analog pin. For example, set 'pin' to 5 to read PC5.
'variable' will store the value.

***********************************************************/

Offline airman00

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: $50 roboduino robot problem
« Reply #4 on: May 27, 2009, 06:57:23 AM »
These aren't errors - only warnings. They don't matter.
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline billhowl

  • Supreme Robot
  • *****
  • Posts: 375
  • Helpful? 32
  • Your success is in your hands.
Re: $50 roboduino robot problem
« Reply #5 on: May 27, 2009, 07:14:30 AM »
The code should change to this

// create and initialize the uart transmit and receive buffers
void uartInitBuffers(void)
{
   #ifndef UART_BUFFERS_EXTERNAL_RAM
      // initialize the UART receive buffer
      bufferInit(&uartRxBuffer, (u08*) uartRxData, UART_RX_BUFFER_SIZE);
      // initialize the UART transmit buffer
      bufferInit(&uartTxBuffer, (u08*) uartTxData, UART_TX_BUFFER_SIZE);
   #else
      // initialize the UART receive buffer
      bufferInit(&uartRxBuffer, (u08*) UART_RX_BUFFER_ADDR, UART_RX_BUFFER_SIZE);
      // initialize the UART transmit buffer
      bufferInit(&uartTxBuffer, (u08*) UART_TX_BUFFER_ADDR, UART_TX_BUFFER_SIZE);
   #endif
}

« Last Edit: May 27, 2009, 07:15:45 AM by billhowl »

Offline chelmi

  • Supreme Robot
  • *****
  • Posts: 496
  • Helpful? 15
Re: $50 roboduino robot problem
« Reply #6 on: May 27, 2009, 01:26:11 PM »
These aren't errors - only warnings. They don't matter.

Warnings are often issued for a good reason. They shouldn't be ignored. I've worked on
several projects were warnings were made into errors. i.e. your code would not
compile if it produces a warning. This is a good practice IMO.

For this specific case, this is due to a argument which is a singed integer for o function that take a unsigned integer.

Chelmi.

Offline airman00

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: $50 roboduino robot problem
« Reply #7 on: May 27, 2009, 06:44:50 PM »
I should have been more specific - they do not matter in this situation. It worked so I didnt bother to fix it

This is a good practice IMO.
I guess... but if it works, why play with it?
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline Tazdevil

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
Re: $50 roboduino robot problem
« Reply #8 on: May 27, 2009, 07:58:56 PM »
Thanks for the replies.

so u08* defines uartTxData as a unsigned 8 bit variable? What was it before that? I have not been able to find this described in any help or book I have can someone point me to the correct liturature to understand this?

I know it worked even with the warnings but as people have said warnings tend to bite you later when you make another change.

Offline billhowl

  • Supreme Robot
  • *****
  • Posts: 375
  • Helpful? 32
  • Your success is in your hands.
Re: $50 roboduino robot problem
« Reply #9 on: May 28, 2009, 01:02:19 AM »
The (u08*) is cast operator that change the signed char to unsigned 8 bits variable,


In buffer.h bufferInit was define with as show

//! initialize a buffer to start at a given address and have given size
void bufferInit(cBuffer* buffer, unsigned char *start, unsigned short size);

In uart.c both uartRxData and uartTxData was defines as char which is signed

#ifndef UART_BUFFERS_EXTERNAL_RAM
   // using internal ram,
   // automatically allocate space in ram for each buffer
   static char uartRxData[UART_RX_BUFFER_SIZE];
   static char uartTxData[UART_TX_BUFFER_SIZE];
#endif

You can read about the cast operator here
http://www.crasseux.com/books/ctutorial/The-cast-operator.html


Offline Tazdevil

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
Re: $50 roboduino robot problem
« Reply #10 on: May 28, 2009, 05:47:24 AM »
Thanks
 Cast operator!

Taz

 


Get Your Ad Here