go away spammer

Author Topic: interface an axonII microcontroller with a sparkfun openservo problems  (Read 3541 times)

0 Members and 1 Guest are viewing this topic.

Offline v01dTopic starter

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
I am trying to interface an axonII microcontroller with a sparkfun openservo and cannot get the two communicating.  I pulled out the oscilloscope and checked the communications and found that I was sending 0x20 to the open servo, but getting no response.

 I currently do not have the pot or motor installed on the board as I want to get the basic coms up and running first.  I am powering it off of a 7.2v regulator and it is drawing about 70 miliamps.

Any thoughts?

Jeff

Offline v01dTopic starter

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
here is my code

#include "hardware.h"

// Initialise the hardware
void appInitHardware(void) {
   initHardware();
i2cBusSetBitRate(&i2cMaster,1);

}
// Initialise the software
TICK_COUNT appInitSoftware(TICK_COUNT loopStart){
   return 0;
}
// This is the main loop
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart) {

   // -------- Start Switch/Button-------
   // Switch/Button - see switch.h
   if(SWITCH_pressed(&button)){
i2cStart(&i2cDev.i2cInfo, false);
i2cStop(&i2cMaster);  // this line does not compile correctly
   }

   return 0;
}

//the i2c stop does not run properly and leaves the line tied low.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Quote
i2cStop(&i2cMaster);  // this line does not compile correctly

That line is incorrect. It should be something like i2cStop( myDevice.bus );


Try this:
i2cStop(i2cDev.i2cInfo);


(I'm just reading this from the WebbotLib datasheet)

Offline v01dTopic starter

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
i tried i2cStop(i2cDev.i2cInfo); and got a complier error

test.c:27: error: incompatible type for argument 1 of 'i2cStop'

to initilize in the hardware.h i use

   GENERIC_I2C_DEVICE i2cDev = MAKE_GENERIC_I2C_DEVICE(0x10);
   static I2C_DEVICE_LIST i2cMaster_list[] = {&i2cDev.i2cInfo};
   I2C_HARDWARE_BUS i2cMaster = MAKE_I2C_HARDWARE_BUS(i2cMaster_list);
   i2cBusInit(&i2cMaster);

Webbot refers to the i2cBusInit(I2C_ABSTRACT_BUS* bus); and i2cStop(const I2C_ABSTRACT_BUS* i2c) as taking the same arguments
http://webbot.org.uk/WebbotLibDocs/28316.html

however if i do i2cStop(&i2cMaster);

it compiles, with a warning ... so something is wierd here
test.c:27: warning: passing argument 1 of 'i2cStop' from incompatible pointer type

Offline v01dTopic starter

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
so a bit more info.  i reviewed the data with the scope
if i try to start coms with:
   address :0x10 ; data line = 000100001
   address :0x20 ; data line = 001000001
   address :0x32 ; data line = 001100101
so this appears to be correct.
without individually setting and compiling each address using:
   " GENERIC_I2C_DEVICE i2cDev = MAKE_GENERIC_I2C_DEVICE(0x10);"
 is there a way i can dynamically send a ping out using..?
      uint8_t buffer = 0x90;
      uint8_t device= 0x20;
       i2cMasterSend(&device, 1, &buffer);
I keep getting warning about incompatible pointers and nothing on the lines when i do this.

this way i can start to narrow down if the openservo is nuts or my programming stinks (or probably a combo of the two)

Offline v01dTopic starter

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
PROGRESS!!!
somehow one of my scope channels went nuts.. so after i switched channels, things started to look more normal (i noticed the bad channel was reading -5v instead of +5v)
the i2cstop command is functioning normal, but the i2cstart command is causing the last 2 bits of the 9 bit stream to be high.  ie 0x00 = 000000011.  this happens with or without the Openservo board attached, so it has to be either the code or Webbot's drivers. 

Could someone please take a look at this and let me know if it is my code causing the problem.  THANKS!!!!!

//test.c:---------------------------------------------------
#include "hardware.h"
// Initialise the hardware
void appInitHardware(void) {
   initHardware();
//i2cBusSetBitRate(&i2cMaster,1);

}
// Initialise the software
TICK_COUNT appInitSoftware(TICK_COUNT loopStart){
   return 0;
}
// This is the main loop
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart) {

   // -------- Start Switch/Button-------
   // Switch/Button - see switch.h
   if(SWITCH_pressed(&button)){
i2cStart(&i2cDev.i2cInfo, false);
i2cStop(&i2cMaster);  // this line does not compile correctly
   }

   return 2000;
}
//code:---------------------------------------------------

//hardware.h--------------------------


/*
      This file has been auto-generated by WebbotLib tools V1.1
            ** DO NOT MODIFY BY HAND **
*/
#ifndef _HARDWARE_H_
#define _HARDWARE_H_
#include "xhardware.h"

// ------------------- uart1 -------------------

// Create a routine to write bytes to uart1
// You can set rprintf to use it by calling rprintfInit(&uart1SendByte)
MAKE_WRITER(uart1SendByte){
   return uartSendByte(uart1,byte);
}

// Create a routine to read a byte from uart1
// Returns -1 if there was no data
MAKE_READER( uart1GetByte){
   return uartGetByte(uart1);
}

// Create hardware UART uart1
HW_UART _uart1 = MAKE_UART_BUFFERED(null,null,UCSR1A,UCSR1B,UBRR1L,UBRR1H,UDR1,null,BV(U2X1),D2,D3,&uart1GetByte,&uart1SendByte);

#ifndef USART1_TX_vect
# error Uart1 Tx complete vector undefined
#else
ISR(USART1_TX_vect){
   uartTransmitService(uart1);
}
#endif

#ifndef USART1_RX_vect
# error Uart1 Rx complete vector undefined
#else
ISR(USART1_RX_vect){
   uartReceiveService(uart1);
}
#endif

// ----------- Define the ADC channels ----------
const uint8_t NUM_ADC_CHANNELS = 16;
const uint16_t PROGMEM AVcc_MV = 5000;

// ----------- My devices -----------------------
SWITCH button = MAKE_SWITCH(D5);
SEGLED led_display = MAKE_SEGLED(C3,C2,C0,D6,D7,C4,C5,null,false);
static SEGLED_LIST marquee_list[] = {
   &led_display
};
static MAKE_WRITER(marquee_put_char); /* Fwd Def */
MARQUEE marquee = MAKE_MARQUEE(marquee_list,500000,2000000,&marquee_put_char);
// Create a Writer to write to marquee
// Do NOT call it directly instead, to write the char 'A' use:
//    marqueeGetWriter(&marquee)('A');
static MAKE_WRITER(marquee_put_char){ /* createWriter */
   return marqueeSendByte(&marquee,byte);
}
GENERIC_I2C_DEVICE i2cDev = MAKE_GENERIC_I2C_DEVICE(0x10);
static I2C_DEVICE_LIST i2cMaster_list[] = {
   &i2cDev.i2cInfo
};
I2C_HARDWARE_BUS i2cMaster = MAKE_I2C_HARDWARE_BUS(i2cMaster_list);

// ----------- Initialise built in devices ------
void sysInitHardware(void){
   SWITCH_init(&button);
   setErrorLog(&uart1SendByte);
   rprintfInit(&uart1SendByte);
   uartInit(uart1,115200);
   segled_init(&led_display);
}

// ----------- Initialise my added devices ------
void initHardware(void){
   i2cBusInit(&i2cMaster);
}
// ----------- Register the statusLED -----------
void registerLED(void){
   statusLEDregister(C1,false);
}

// ----------- Ports are configured on the fly --
void configure_ports(void){
}

#endif

//end--------------------------

Offline v01dTopic starter

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
more progress!!

it looks like bit 8 is the read write flag set by the true/false statement in the i2cstart command.

bit 9 looks like it is put out to be pulled down by an ack command from the openservo.

so it looks like i still need to make a buss scanner, is there any way to increment the addresses?

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Change:
Code: [Select]
i2cStop(&i2cMaster);  // this line does not compile correctlyto
Code: [Select]
i2cStop(i2cGetAbstractBus(&i2cMaster));
I doubt its the I2C support in the library giving you issues - as its already successfully used with various things: displays, servo controllers, etc etc.

Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline v01dTopic starter

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
yup that solved that problem.  ;D

i now wrote some ugly code to ping all the i2c adress's

is there a way to call i2cstart(&i2cMaster[index]) ?  i tried but kept running into errors..so i did it the hard way.

Code: [Select]
#include "hardware.h"

// Initialise the hardware
void appInitHardware(void) {
   initHardware();
//i2cBusSetBitRate(&i2cMaster,1);

}
// Initialise the software
TICK_COUNT appInitSoftware(TICK_COUNT loopStart){
   return 0;
}

uint8_t number = 0x00;
// This is the main loop
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart) {
// prevent overflow


int ch = uartGetByte(UART1);

if(ch != -1) //if character in ch
{ //ch = "boobs";
number = number + 0x02;
rprintf("%x channel", number);
rprintfCRLF();
}

if (number> 0xff){number = 0x00;}

   // -------- Start Switch/Button-------
   // Switch/Button - see switch.h
  // if(SWITCH_pressed(&button)){
// i2cStart(&i2c00.i2cInfo, true);
//i2cStart(&i2c00.i2cInfo, true);
switch (number){
case 0x00:
i2cStart(&i2c00.i2cInfo, true);
break;
case 0x01:
i2cStart(&i2c01.i2cInfo, true);
break;
case 0x02:
i2cStart(&i2c02.i2cInfo, true);
break;
case 0x03:
i2cStart(&i2c03.i2cInfo, true);
break;
case 0x04:
i2cStart(&i2c04.i2cInfo, true);
break;
case 0x05:
i2cStart(&i2c05.i2cInfo, true);
break;
case 0x06:
i2cStart(&i2c06.i2cInfo, true);
break;
case 0x07:
i2cStart(&i2c07.i2cInfo, true);
break;
case 0x08:
i2cStart(&i2c08.i2cInfo, true);
break;
case 0x09:
i2cStart(&i2c09.i2cInfo, true);
break;
case 0x0a:
i2cStart(&i2c0a.i2cInfo, true);
break;
case 0x0b:
i2cStart(&i2c0b.i2cInfo, true);
break;
case 0x0c:
i2cStart(&i2c0c.i2cInfo, true);
break;
case 0x0d:
i2cStart(&i2c0d.i2cInfo, true);
break;
case 0x0e:
i2cStart(&i2c0e.i2cInfo, true);
break;
case 0x0f:
i2cStart(&i2c0f.i2cInfo, true);
break;

case 0x10:
// i2cStart(&i2c10.i2cInfo, true);
// break;
case 0x11:
i2cStart(&i2c11.i2cInfo, true);
break;
case 0x12:
// i2cStart(&i2c12.i2cInfo, true);
// break;
case 0x13:
i2cStart(&i2c13.i2cInfo, true);
break;
case 0x14:
/// i2cStart(&i2c14.i2cInfo, true);
// break;
case 0x15:
i2cStart(&i2c15.i2cInfo, true);
break;
case 0x16:
// i2cStart(&i2c16.i2cInfo, true);
// break;
case 0x17:
i2cStart(&i2c17.i2cInfo, true);
break;
case 0x18:
// i2cStart(&i2c18.i2cInfo, true);
// break;
case 0x19:
i2cStart(&i2c19.i2cInfo, true);
break;
case 0x1a:
// i2cStart(&i2c1a.i2cInfo, true);
// break;
case 0x1b:
i2cStart(&i2c1b.i2cInfo, true);
break;
case 0x1c:
// i2cStart(&i2c1c.i2cInfo, true);
// break;
case 0x1d:
i2cStart(&i2c1d.i2cInfo, true);
break;
case 0x1e:
// i2cStart(&i2c1e.i2cInfo, true);
// break;
case 0x1f:
i2cStart(&i2c1f.i2cInfo, true);
break;

case 0x20:
// i2cStart(&i2c20.i2cInfo, true);
// break;
case 0x21:
i2cStart(&i2c21.i2cInfo, true);
break;
case 0x22:
// i2cStart(&i2c22.i2cInfo, true);
// break;
case 0x23:
i2cStart(&i2c23.i2cInfo, true);
break;
case 0x24:
// i2cStart(&i2c24.i2cInfo, true);
// break;
case 0x25:
i2cStart(&i2c25.i2cInfo, true);
break;
case 0x26:
// i2cStart(&i2c26.i2cInfo, true);
// break;
case 0x27:
i2cStart(&i2c27.i2cInfo, true);
break;
case 0x28:
// i2cStart(&i2c28.i2cInfo, true);
// break;
case 0x29:
i2cStart(&i2c29.i2cInfo, true);
break;
case 0x2a:
// i2cStart(&i2c2a.i2cInfo, true);
// break;
case 0x2b:
i2cStart(&i2c2b.i2cInfo, true);
break;
case 0x2c:
// i2cStart(&i2c2c.i2cInfo, true);
// break;
case 0x2d:
i2cStart(&i2c2d.i2cInfo, true);
break;
case 0x2e:
// i2cStart(&i2c2e.i2cInfo, true);
// break;
case 0x2f:
i2cStart(&i2c2f.i2cInfo, true);
break;

case 0x30:
// i2cStart(&i2c30.i2cInfo, true);
// break;
case 0x31:
i2cStart(&i2c31.i2cInfo, true);
break;
case 0x32:
// i2cStart(&i2c32.i2cInfo, true);
// break;
case 0x33:
i2cStart(&i2c33.i2cInfo, true);
break;
case 0x34:
// i2cStart(&i2c34.i2cInfo, true);
// break;
case 0x35:
i2cStart(&i2c35.i2cInfo, true);
break;
case 0x36:
// i2cStart(&i2c36.i2cInfo, true);
// break;
case 0x37:
i2cStart(&i2c37.i2cInfo, true);
break;
case 0x38:
// i2cStart(&i2c38.i2cInfo, true);
// break;
case 0x39:
i2cStart(&i2c39.i2cInfo, true);
break;
case 0x3a:
// i2cStart(&i2c3a.i2cInfo, true);
// break;
case 0x3b:
i2cStart(&i2c3b.i2cInfo, true);
break;
case 0x3c:
// i2cStart(&i2c3c.i2cInfo, true);
// break;
case 0x3d:
i2cStart(&i2c3d.i2cInfo, true);
break;
case 0x3e:
// i2cStart(&i2c3e.i2cInfo, true);
// break;
case 0x3f:
i2cStart(&i2c3f.i2cInfo, true);
break;


case 0x40:
// i2cStart(&i2c40.i2cInfo, true);
// break;
case 0x41:
i2cStart(&i2c41.i2cInfo, true);
break;
case 0x42:
// i2cStart(&i2c42.i2cInfo, true);
// break;
case 0x43:
i2cStart(&i2c43.i2cInfo, true);
break;
case 0x44:
// i2cStart(&i2c44.i2cInfo, true);
// break;
case 0x45:
i2cStart(&i2c45.i2cInfo, true);
break;
case 0x46:
// i2cStart(&i2c46.i2cInfo, true);
// break;
case 0x47:
i2cStart(&i2c47.i2cInfo, true);
break;
case 0x48:
// i2cStart(&i2c48.i2cInfo, true);
// break;
case 0x49:
i2cStart(&i2c49.i2cInfo, true);
break;
case 0x4a:
// i2cStart(&i2c4a.i2cInfo, true);
// break;
case 0x4b:
i2cStart(&i2c4b.i2cInfo, true);
break;
case 0x4c:
// i2cStart(&i2c4c.i2cInfo, true);
// break;
case 0x4d:
i2cStart(&i2c4d.i2cInfo, true);
break;
case 0x4e:
// i2cStart(&i2c4e.i2cInfo, true);
// break;
case 0x4f:
i2cStart(&i2c4f.i2cInfo, true);
break;

case 0x50:
// i2cStart(&i2c50.i2cInfo, true);
// break;
case 0x51:
i2cStart(&i2c51.i2cInfo, true);
break;
case 0x52:
// i2cStart(&i2c52.i2cInfo, true);
// break;
case 0x53:
i2cStart(&i2c53.i2cInfo, true);
break;
case 0x54:
// i2cStart(&i2c54.i2cInfo, true);
// break;
case 0x55:
i2cStart(&i2c55.i2cInfo, true);
break;
case 0x56:
// i2cStart(&i2c56.i2cInfo, true);
// break;
case 0x57:
i2cStart(&i2c57.i2cInfo, true);
break;
case 0x58:
// i2cStart(&i2c58.i2cInfo, true);
// break;
case 0x59:
i2cStart(&i2c59.i2cInfo, true);
break;
case 0x5a:
// i2cStart(&i2c5a.i2cInfo, true);
// break;
case 0x5b:
i2cStart(&i2c5b.i2cInfo, true);
break;
case 0x5c:
// i2cStart(&i2c5c.i2cInfo, true);
// break;
case 0x5d:
i2cStart(&i2c5d.i2cInfo, true);
break;
case 0x5e:
// i2cStart(&i2c5e.i2cInfo, true);
// break;
case 0x5f:
i2cStart(&i2c5f.i2cInfo, true);
break;


case 0x60:
// i2cStart(&i2c60.i2cInfo, true);
// break;
case 0x61:
i2cStart(&i2c61.i2cInfo, true);
break;
case 0x62:
// i2cStart(&i2c62.i2cInfo, true);
// break;
case 0x63:
i2cStart(&i2c63.i2cInfo, true);
break;
case 0x64:
// i2cStart(&i2c64.i2cInfo, true);
// break;
case 0x65:
i2cStart(&i2c65.i2cInfo, true);
break;
case 0x66:
// i2cStart(&i2c66.i2cInfo, true);
// break;
case 0x67:
i2cStart(&i2c67.i2cInfo, true);
break;
case 0x68:
// i2cStart(&i2c68.i2cInfo, true);
// break;
case 0x69:
i2cStart(&i2c69.i2cInfo, true);
break;
case 0x6a:
// i2cStart(&i2c6a.i2cInfo, true);
// break;
case 0x6b:
i2cStart(&i2c6b.i2cInfo, true);
break;
case 0x6c:
// i2cStart(&i2c6c.i2cInfo, true);
// break;
case 0x6d:
i2cStart(&i2c6d.i2cInfo, true);
break;
case 0x6e:
// i2cStart(&i2c6e.i2cInfo, true);
// break;
case 0x6f:
i2cStart(&i2c6f.i2cInfo, true);
break;

case 0x70:
// i2cStart(&i2c70.i2cInfo, true);
// break;
case 0x71:
i2cStart(&i2c71.i2cInfo, true);
break;
case 0x72:
// i2cStart(&i2c72.i2cInfo, true);
// break;
case 0x73:
i2cStart(&i2c73.i2cInfo, true);
break;
case 0x74:
// i2cStart(&i2c74.i2cInfo, true);
// break;
case 0x75:
i2cStart(&i2c75.i2cInfo, true);
break;
case 0x76:
/// i2cStart(&i2c76.i2cInfo, true);
// break;
case 0x77:
i2cStart(&i2c77.i2cInfo, true);
break;
case 0x78:
// i2cStart(&i2c78.i2cInfo, true);
// break;
case 0x79:
i2cStart(&i2c79.i2cInfo, true);
break;
case 0x7a:
// i2cStart(&i2c7a.i2cInfo, true);
// break;
case 0x7b:
i2cStart(&i2c7b.i2cInfo, true);
break;
case 0x7c:
// i2cStart(&i2c7c.i2cInfo, true);
// break;
case 0x7d:
i2cStart(&i2c7d.i2cInfo, true);
break;
case 0x7e:
// i2cStart(&i2c7e.i2cInfo, true);
// break;
case 0x7f:
i2cStart(&i2c7f.i2cInfo, true);
break;


case 0x80:
// i2cStart(&i2c80.i2cInfo, true);
// break;
case 0x81:
i2cStart(&i2c81.i2cInfo, true);
break;
case 0x82:
// i2cStart(&i2c82.i2cInfo, true);
// break;
case 0x83:
i2cStart(&i2c83.i2cInfo, true);
break;
case 0x84:
// i2cStart(&i2c84.i2cInfo, true);
// break;
case 0x85:
i2cStart(&i2c85.i2cInfo, true);
break;
case 0x86:
// i2cStart(&i2c86.i2cInfo, true);
// break;
case 0x87:
i2cStart(&i2c87.i2cInfo, true);
break;
case 0x88:
// i2cStart(&i2c88.i2cInfo, true);
// break;
case 0x89:
i2cStart(&i2c89.i2cInfo, true);
break;
case 0x8a:
// i2cStart(&i2c8a.i2cInfo, true);
// break;
case 0x8b:
i2cStart(&i2c8b.i2cInfo, true);
break;
case 0x8c:
// i2cStart(&i2c8c.i2cInfo, true);
// break;
case 0x8d:
i2cStart(&i2c8d.i2cInfo, true);
break;
case 0x8e:
// i2cStart(&i2c8e.i2cInfo, true);
// break;
case 0x8f:
i2cStart(&i2c8f.i2cInfo, true);
break;

case 0x90:
// i2cStart(&i2c90.i2cInfo, true);
// break;
case 0x91:
i2cStart(&i2c91.i2cInfo, true);
break;
case 0x92:
// i2cStart(&i2c92.i2cInfo, true);
// break;
case 0x93:
i2cStart(&i2c93.i2cInfo, true);
break;
case 0x94:
// i2cStart(&i2c94.i2cInfo, true);
// break;
case 0x95:
i2cStart(&i2c95.i2cInfo, true);
break;
case 0x96:
// i2cStart(&i2c96.i2cInfo, true);
// break;
case 0x97:
i2cStart(&i2c97.i2cInfo, true);
break;
case 0x98:
// i2cStart(&i2c98.i2cInfo, true);
// break;
case 0x99:
i2cStart(&i2c99.i2cInfo, true);
break;
case 0x9a:
// i2cStart(&i2c9a.i2cInfo, true);
// break;
case 0x9b:
i2cStart(&i2c9b.i2cInfo, true);
break;
case 0x9c:
// i2cStart(&i2c9c.i2cInfo, true);
// break;
case 0x9d:
i2cStart(&i2c9d.i2cInfo, true);
break;
case 0x9e:
// i2cStart(&i2c9e.i2cInfo, true);
// break;
case 0x9f:
i2cStart(&i2c9f.i2cInfo, true);
break;


case 0xa0:
// i2cStart(&i2ca0.i2cInfo, true);
// break;
case 0xa1:
i2cStart(&i2ca1.i2cInfo, true);
break;
case 0xa2:
// i2cStart(&i2ca2.i2cInfo, true);
// break;
case 0xa3:
i2cStart(&i2ca3.i2cInfo, true);
break;
case 0xa4:
// i2cStart(&i2ca4.i2cInfo, true);
// break;
case 0xa5:
i2cStart(&i2ca5.i2cInfo, true);
break;
case 0xa6:
// i2cStart(&i2ca6.i2cInfo, true);
// break;
case 0xa7:
i2cStart(&i2ca7.i2cInfo, true);
break;
case 0xa8:
// i2cStart(&i2ca8.i2cInfo, true);
// break;
case 0xa9:
i2cStart(&i2ca9.i2cInfo, true);
break;
case 0xaa:
// i2cStart(&i2caa.i2cInfo, true);
// break;
case 0xab:
i2cStart(&i2cab.i2cInfo, true);
break;
case 0xac:
// i2cStart(&i2cac.i2cInfo, true);
// break;
case 0xad:
i2cStart(&i2cad.i2cInfo, true);
break;
case 0xae:
// i2cStart(&i2cae.i2cInfo, true);
// break;
case 0xaf:
i2cStart(&i2caf.i2cInfo, true);
break;

case 0xb0:
// i2cStart(&i2cb0.i2cInfo, true);
// break;
case 0xb1:
i2cStart(&i2cb1.i2cInfo, true);
break;
case 0xb2:
// i2cStart(&i2cb2.i2cInfo, true);
// break;
case 0xb3:
i2cStart(&i2cb3.i2cInfo, true);
break;
case 0xb4:
// i2cStart(&i2cb4.i2cInfo, true);
// break;
case 0xb5:
i2cStart(&i2cb5.i2cInfo, true);
break;
case 0xb6:
// i2cStart(&i2cb6.i2cInfo, true);
// break;
case 0xb7:
i2cStart(&i2cb7.i2cInfo, true);
break;
case 0xb8:
// i2cStart(&i2cb8.i2cInfo, true);
// break;
case 0xb9:
i2cStart(&i2cb9.i2cInfo, true);
break;
case 0xba:
// i2cStart(&i2cba.i2cInfo, true);
// break;
case 0xbb:
i2cStart(&i2cbb.i2cInfo, true);
break;
case 0xbc:
// i2cStart(&i2cbc.i2cInfo, true);
// break;
case 0xbd:
i2cStart(&i2cbd.i2cInfo, true);
break;
case 0xbe:
// i2cStart(&i2cbe.i2cInfo, true);
// break;
case 0xbf:
i2cStart(&i2cbf.i2cInfo, true);
break;


case 0xc0:
// i2cStart(&i2cc0.i2cInfo, true);
// break;
case 0xc1:
i2cStart(&i2cc1.i2cInfo, true);
break;
case 0xc2:
// i2cStart(&i2cc2.i2cInfo, true);
// break;
case 0xc3:
i2cStart(&i2cc3.i2cInfo, true);
break;
case 0xc4:
// i2cStart(&i2cc4.i2cInfo, true);
// break;
case 0xc5:
i2cStart(&i2cc5.i2cInfo, true);
break;
case 0xc6:
// i2cStart(&i2cc6.i2cInfo, true);
// break;
case 0xc7:
i2cStart(&i2cc7.i2cInfo, true);
break;
case 0xc8:
// i2cStart(&i2cc8.i2cInfo, true);
// break;
case 0xc9:
i2cStart(&i2cc9.i2cInfo, true);
break;
case 0xca:
// i2cStart(&i2cca.i2cInfo, true);
// break;
case 0xcb:
i2cStart(&i2ccb.i2cInfo, true);
break;
case 0xcc:
// i2cStart(&i2ccc.i2cInfo, true);
/// break;
case 0xcd:
i2cStart(&i2ccd.i2cInfo, true);
break;
case 0xce:
// i2cStart(&i2cce.i2cInfo, true);
// break;
case 0xcf:
i2cStart(&i2ccf.i2cInfo, true);
break;

case 0xd0:
// i2cStart(&i2cd0.i2cInfo, true);
// break;
case 0xd1:
i2cStart(&i2cd1.i2cInfo, true);
break;
case 0xd2:
// i2cStart(&i2cd2.i2cInfo, true);
// break;
case 0xd3:
i2cStart(&i2cd3.i2cInfo, true);
break;
case 0xd4:
// i2cStart(&i2cd4.i2cInfo, true);
// break;
case 0xd5:
i2cStart(&i2cd5.i2cInfo, true);
break;
case 0xd6:
// i2cStart(&i2cd6.i2cInfo, true);
// break;
case 0xd7:
i2cStart(&i2cd7.i2cInfo, true);
break;
case 0xd8:
// i2cStart(&i2cd8.i2cInfo, true);
// break;
case 0xd9:
i2cStart(&i2cd9.i2cInfo, true);
break;
case 0xda:
// i2cStart(&i2cda.i2cInfo, true);
// break;
case 0xdb:
i2cStart(&i2cdb.i2cInfo, true);
break;
case 0xdc:
// i2cStart(&i2cdc.i2cInfo, true);
// break;
case 0xdd:
i2cStart(&i2cdd.i2cInfo, true);
break;
case 0xde:
// i2cStart(&i2cde.i2cInfo, true);
// break;
case 0xdf:
i2cStart(&i2cdf.i2cInfo, true);
break;


case 0xe0:
// i2cStart(&i2ce0.i2cInfo, true);
// break;
case 0xe1:
i2cStart(&i2ce1.i2cInfo, true);
break;
case 0xe2:
// i2cStart(&i2ce2.i2cInfo, true);
// break;
case 0xe3:
i2cStart(&i2ce3.i2cInfo, true);
break;
case 0xe4:
// i2cStart(&i2ce4.i2cInfo, true);
// break;
case 0xe5:
i2cStart(&i2ce5.i2cInfo, true);
break;
case 0xe6:
// i2cStart(&i2ce6.i2cInfo, true);
// break;
case 0xe7:
i2cStart(&i2ce7.i2cInfo, true);
break;
case 0xe8:
// i2cStart(&i2ce8.i2cInfo, true);
// break;
case 0xe9:
i2cStart(&i2ce9.i2cInfo, true);
break;
case 0xea:
// i2cStart(&i2cea.i2cInfo, true);
// break;
case 0xeb:
i2cStart(&i2ceb.i2cInfo, true);
break;
case 0xec:
// i2cStart(&i2cec.i2cInfo, true);
// break;
case 0xed:
i2cStart(&i2ced.i2cInfo, true);
break;
case 0xee:
// i2cStart(&i2cee.i2cInfo, true);
// break;
case 0xef:
i2cStart(&i2cef.i2cInfo, true);
break;

case 0xf0:
// i2cStart(&i2cf0.i2cInfo, true);
// break;
case 0xf1:
i2cStart(&i2cf1.i2cInfo, true);
break;
case 0xf2:
// i2cStart(&i2cf2.i2cInfo, true);
// break;
case 0xf3:
i2cStart(&i2cf3.i2cInfo, true);
break;
case 0xf4:
// i2cStart(&i2cf4.i2cInfo, true);
// break;
case 0xf5:
i2cStart(&i2cf5.i2cInfo, true);
break;
case 0xf6:
// i2cStart(&i2cf6.i2cInfo, true);
// break;
case 0xf7:
i2cStart(&i2cf7.i2cInfo, true);
break;
case 0xf8:
// i2cStart(&i2cf8.i2cInfo, true);
// break;
case 0xf9:
i2cStart(&i2cf9.i2cInfo, true);
break;
case 0xfa:
// i2cStart(&i2cfa.i2cInfo, true);
// break;
case 0xfb:
i2cStart(&i2cfb.i2cInfo, true);
break;
case 0xfc:
// i2cStart(&i2cfc.i2cInfo, true);
// break;
case 0xfd:
i2cStart(&i2cfd.i2cInfo, true);
break;
case 0xfe:
// i2cStart(&i2cfe.i2cInfo, true);
// break;
case 0xff:
i2cStart(&i2cff.i2cInfo, true);
break;

default:
break;
}

i2cStop(i2cGetAbstractBus(&i2cMaster)); 
   //}

   return 2000;
}


Offline v01dTopic starter

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
looks like it's the openservo that is the culprit (just sitting silent despite my requests to talk to it).  My compliments to webbot for getting me this far :) , I do appreciate the help.

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Your code just seems to be doing a start and a stop. This is like ringing a phone number and then hanging up the phone - ie no communications are actually happening.

From a quick look at the manual then the I2C address, by default, should be either 0x20 or 0x10.
Try using the WebbotLib functions to read some of the registers such as the various info stuff about the device type or version numbers - rather than the low level start/stop stuff.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline v01dTopic starter

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
My initial thoughts were to do the same, but your code first checks to see if there was an ACK before sending the next chunk of data.  I modified the i2cStart() lines to return the ACK and then output it via the uart.
   ack = i2cStart(device,TRUE);
after scanning all the lines I still got  0x00 for all ack's.  I also checked the lines with the scope and found the same thing. 
I spoke to sparkfun, and apparently the servo is supposed to a "demo move" where it tries spin around a bit on power up (which mine has never done).  They are sending me one they tested to confirm that mine are not working, and have offered to repair the ones I have in hand. 

I would like to compress my code a bit with arrays, and I get and incompatible pointer type warning. Any suggestions?
Code: [Select]
GENERIC_I2C_DEVICE i2c00= MAKE_GENERIC_I2C_DEVICE(0x00);
static I2C_DEVICE_LIST i2cMaster_list[] = {&i2c00.i2cInfo,}
I2C_HARDWARE_BUS i2cMaster = MAKE_I2C_HARDWARE_BUS(i2cMaster_list);
i2cBusInit(&i2cMaster);
ack = i2cStart(&i2cMaster[0],TRUE); // causes warnings and does not work

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
An update that should make your life simpler...

In previous versions of WebbotLib the i2cStart function expected a 'device' to be passed so that it could use its i2c address. Thats why you ended up creating a device with every possible i2cAddress.

As of Version 2.05 the i2cStart command has been changed so that you can pass it an address directly. So your code should now be MUCH simpler.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

 


Get Your Ad Here