Leonardo + G15 shield + G15

Talk about Arduino board, sheilds. Sharing Arduino projects, program, problems, solutions, suggestions..... many more, all are welcome.

Leonardo + G15 shield + G15

Postby JohnW » Tue Mar 25, 2014 9:30 pm

Hi Guys,

I've received the Leo, G15 shield and G15 servo today, along with the 12V 2Amp wall power supply.

I've connected everything and and I get some level of success - i've programmed the address successfully (I choose 8) using the SetID example, I then moved onto the positioning example - again this uploads correctly to the board and the red light flashes as I think it should I amended the code such that I have the following

CODE: SELECT_ALL_CODE
#include <G15.h>    // include the library
#define LED_BOARD 13


/*Return Error definitions & Mask
=====Higher 8 bits of Word=========
packet length error :       0x0100
packet header error:        0x0200
ID mismatch error:          0x0400
packet checksum mismatch :  0x0800
====Lower 8 bits of word==========
Error status return by G15:
INST         0x0040      
OVERLOAD      0x0020
CHECKSUM      0x0010
RANGE         0x0008
OVERHEAT      0x0004
ANGLELIMIT            0x0002
VOLTAGE              0x0001
*/


//declaration of variables & object
word ERROR=0;
byte DATA[10];
word STATUS;

//declare G15 Class Object
//servo1 ID=1
G15 servo1(0x08); //Set the right motor ID
//servo2 ID=2
//G15 servo2(2);


void setup(){
 
//initialize the arduino main board's serial/UART and Control Pins
  G15ShieldInit(19200,3,8);
 
//call the init function to init servo obj
  servo1.init();           
  //servo2.init();

//init LED indicator as output
  pinMode(LED_BOARD,OUTPUT); 
  digitalWrite(LED_BOARD, LOW);
 
  delay(500);
  digitalWrite(LED_BOARD, HIGH);
 
}
void loop(){
   
    servo1.SetLED(ON,iWRITE_DATA);
   
    servo1.SetSpeed(500,iWRITE_DATA);
    servo1.SetPos(ConvertAngle2Pos(0),iWRITE_DATA);    //goto 0 degree pos
   
    delay(5000); //keep the light on for 5 seconds to test
     
    servo1.SetPos(ConvertAngle2Pos(90),iWRITE_DATA);   //goto 90 degree pos
    servo1.SetSpeed(250,iWRITE_DATA);
   
     servo1.SetLED(OFF,iWRITE_DATA);
   
    //delay(1000);
   
    //servo2.SetLED(ON,iWRITE_DATA);
   
    //servo2.SetSpeed(250,iWRITE_DATA);
    //servo2.SetPos(ConvertAngle2Pos(0),iWRITE_DATA);     //goto 0 degree pos
   
    //delay(1000);
   
    //servo2.SetSpeed(500,iWRITE_DATA);
    //servo2.SetPos(ConvertAngle2Pos(90),iWRITE_DATA);   //goto 90 degree pos
   
    //servo2.SetLED(OFF,iWRITE_DATA);
    delay(1000);
   

}


So now I talk to servo at 8, and the red servo LED stays on for 5 seconds and off for 1, so I'm assuming the communications part is all successful.

My issue is the motor never moves, so I think I have a motor power problem. I have the 12v line plugged in directly to Leo board and both LED's illuminate on the shield, and Leo is powered.

If I plug my USB lead in, with no power supply I get the same effect, both boards are powered, and there seems to be no power jumpers on the Leo board.

I haven't tried powering the shield using the JP1 connector directly yet as looking in the manual I need to change JP3 over from INT to EXT and I dont have a soldering iron handy until tomorrow.

Is there something obvious either with Leo board or the shield I am missing?

Thanks for any help!! :)

---------------------------------------------------------------------------------------------------

Whilst typing this up and testing things I've reached the conclusion there is something wrong with the example code included for download, as if I replace the 'loop' code with the following from the tutorial the servo does what it is supposed to, so no power problems :D


CODE: SELECT_ALL_CODE
    servo1.SetPos(0,iWRITE_DATA);
    delay(800);
    servo1.SetPos(1087,iWRITE_DATA);
    delay(1600);
    servo1.SetPos(544,iWRITE_DATA);
    delay(800);


I'll decipher the error in the included example tomorrow, for now I'm content with what I've done so far.
JohnW
Freshie
 
Posts: 7
Joined: Tue Mar 25, 2014 8:49 pm

Re: Leonardo + G15 shield + G15

Postby sich » Wed Mar 26, 2014 12:54 pm

Looks like the problem lies at ConvertAngle2Pos() function. We'll verify and let you know. Thanks for your info!
~> How to ask QUESTIONS the SMART way in FORUM? <~
User avatar
sich
Moderator
 
Posts: 603
Joined: Tue Apr 21, 2009 2:15 pm

Re: Leonardo + G15 shield + G15

Postby JohnW » Wed Mar 26, 2014 1:55 pm

Hi Sich, thats what I think I had figured earlier during my lunch break, the code in my header is

CODE: SELECT_ALL_CODE
#define ConvertAngle2Pos(Angle) word(word(Angle)*1088UL/360UL)


There seems to be an error - I think it should be

CODE: SELECT_ALL_CODE
#define ConvertAngle2Pos(Angle) word(float(Angle)*1088UL/360UL)


or maybe

CODE: SELECT_ALL_CODE
#define ConvertAngle2Pos(Angle) word(float(Angle)*1088.0/360.0)


Would also work - I think as it stands it will probably always return 0 hence the non-movement, I will test it later the servo and other gizmo's are at home and I'm at work!
JohnW
Freshie
 
Posts: 7
Joined: Tue Mar 25, 2014 8:49 pm

Re: Leonardo + G15 shield + G15

Postby JohnW » Wed Mar 26, 2014 6:30 pm

I can confirm that either of the revised lines I propose work in fact just copying the reverse function works fine

CODE: SELECT_ALL_CODE
#define ConvertAngle2Pos(Angle) float(Angle)*1088.0/360.0


J.
JohnW
Freshie
 
Posts: 7
Joined: Tue Mar 25, 2014 8:49 pm

Re: Leonardo + G15 shield + G15

Postby sich » Wed Mar 26, 2014 6:47 pm

Hm... I can run the sample code on Leonardo without any modification to the code. G15 can rotate to the desired position correctly.
~> How to ask QUESTIONS the SMART way in FORUM? <~
User avatar
sich
Moderator
 
Posts: 603
Joined: Tue Apr 21, 2009 2:15 pm


Return to Arduino Based

Who is online

Users browsing this forum: No registered users and 10 guests

cron