G15 Driver NOT working

LINIX Brushless, VEXTA Brushless, RC Servo, DC Geared, Linear, Stepper, Tamiya.....

G15 Driver NOT working

Postby Mohd093 » Wed Mar 25, 2015 12:13 am

I'm using G15 servo motor with PIC16f887, i have tried the example code provided by cytron the build is successful and i uploaded to the micro controller using pickit2, but when i make all my connection to the G15 driver the both LED the green and the red is lighting but the motor is not rotating and dont make any movement i have changed the code to just let the motor rotate but its still not responding.

Also to check if the G15 is working or not i have connect it to my arduino with G15 shield and its working perfectly.

So could you please help me in this matter
Mohd093
Freshie
 
Posts: 7
Joined: Wed Mar 25, 2015 12:02 am

Re: G15 Driver NOT working

Postby ober » Wed Mar 25, 2015 7:55 am

Which particular example code that you use? Can you provide the link? Which G15 driver are you using? Did you push the slide switch (Mode switch) to correct position? Showing us a clear photo of the hardware setup would help.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1440
Joined: Wed Apr 15, 2009 1:03 pm

Re: G15 Driver NOT working

Postby Mohd093 » Wed Mar 25, 2015 12:09 pm

I'm using GD02 Rev1.0 it doesn't have switch , the example code that i have used is SK40C GD02 Sample Code V1.0 [MPLAB X] in the attachment of this link http://cytron.com.my/p-gd02 , and when i upload tthe hex file directly using pickit2 it give me a massage stated that the hex file dont have a configuration, the picture of my circuit is attached below and this the code after my modification, the heaad file is my configuration bit file which is as following
CODE: SELECT_ALL_CODE
#include <xc.h>

// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.

// CONFIG1
#pragma config FOSC = HS        // Oscillator Selection bits (HS oscillator: High-speed crystal/resonator on RA6/OSC2/CLKOUT and RA7/OSC1/CLKIN)
#pragma config WDTE = OFF       // Watchdog Timer Enable bit (WDT enabled)
#pragma config PWRTE = OFF      // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = OFF       // RE3/MCLR pin function select bit (RE3/MCLR pin function is MCLR)
#pragma config CP = OFF         // Code Protection bit (Program memory code protection is disabled)
#pragma config CPD = OFF        // Data Code Protection bit (Data memory code protection is disabled)
#pragma config BOREN = OFF       // Brown Out Reset Selection bits (BOR enabled)
#pragma config IESO = OFF        // Internal External Switchover bit (Internal/External Switchover mode is enabled)
#pragma config FCMEN = OFF       // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is enabled)
#pragma config LVP = ON         // Low Voltage Programming Enable bit (RB3/PGM pin has PGM function, low voltage programming enabled)

// CONFIG2
#pragma config BOR4V = BOR40V   // Brown-out Reset Selection bit (Brown-out Reset set to 4.0V)
#pragma config WRT = OFF        // Flash Program Memory Self Write Enable bits (Write protection off)



#define _XTAL_FREQ 20000000
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

/*
 * File:   Main.c
 * Author: inghui
 *
 */
#include "G15.h"
#include "heaad.h"
#define _XTAL_FREQ 20000000
#define BAUDRATE 500000
#define CTRL_G15 RC4



#define   SW1      RB0
#define   SW2      RB1

#define   LED1      RB6
#define   LED2      RB7

#include <htc.h>


void initIO(void);
unsigned char UART_REC(void);
void UART_SEND(unsigned char data);
void UART_INIT(void);
void lcdinit(void);
void delay(unsigned long data);
void send_config(unsigned char data);
void send_char(unsigned char data);
void lcd_goto(unsigned char data);
void lcd_clr(void);
void send_string(const char *s);
unsigned char lcd_num(unsigned short number, unsigned char digit);


// If PIC16F887 Configuration bits.


unsigned char ERR_FLAG=0;
unsigned long UARTWAIT=15000;

void main(void) {
    unsigned char DATA[10];
    unsigned short pos, angle;

    initIO();
    lcdinit();
    UART_INIT();
   
     __delay_ms(500);
    LED1 = 0;
     __delay_ms(100);

 SetWheelMode(1);
 SetSpeed(1, 0x03FF,iWRITE_DATA);
 __delay_ms(5000);
 ExitWheelMode(1);
 while (1);
   
}

//Functions:

void initIO(void)
{


    //setup digital IO
    PORTB = 0;
    PORTC = 0;
    PORTD = 0;
    PORTE = 0;

    // Initialize the I/O port direction.
    TRISA = 0b11111111;
    TRISB = 0b00000011;
    TRISC = 0b10000000;
    TRISD = 0;
    TRISE = 0b00000011;

    ANSEL=0x00;
    ANSELH=0x00;

    LED1=0; LED2=0;

}

//LCD functions----------------------------------------------------------------
#define   rs         RB4   //RS pin of the LCD display
#define   e         RB5   //E pin of the LCD display
#define   lcd_data   PORTD      //LCD 8-bit data PORT

void lcdinit(void){

    TRISD=0x00;
    TRISB4=0;
    TRISB5=0;
        //configure lcd
    send_config(0b00000001);         //clear display at lcd
    send_config(0b00000010);         //lcd return to home
    send_config(0b00000110);         //entry mode-cursor increase 1
    send_config(0b00001100);         //display on, cursor off and cursor blink off
    send_config(0b00111000);         //function set

    //display startup message
    lcd_clr();                     //clear lcd

}
void delay(unsigned long data)      //delay function, the delay time
{               //depend on the given value
   for( ;data>0;data--);
}

void send_config(unsigned char data)   //send lcd configuration
{
   rs=0;               //set lcd to configuration mode
   lcd_data=data;            //lcd data port = data
   e=1;               //pulse e to confirm the data
   delay(50);
   e=0;
   delay(50);
}

void send_char(unsigned char data)      //send lcd character
{
    rs=1;               //set lcd to display mode
   lcd_data=data;            //lcd data port = data
   e=1;               //pulse e to confirm the data
   delay(10);
   e=0;
   delay(10);
}

void lcd_goto(unsigned char data)      //set the location of the lcd cursor
{                  //if the given value is (0-15) the
    if(data<16)                             //cursor will be at the upper line
   {               //if the given value is (20-35) the
       send_config(0x80+data);      //cursor will be at the lower line
   }               //location of the lcd cursor(2X16):
   else               // -----------------------------------------------------
   {               // | |00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15| |
       data=data-20;         // | |20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35| |
      send_config(0xc0+data);         // -----------------------------------------------------
   }
}

void lcd_clr(void)            //clear the lcd
{
    send_config(0x01);
   delay(600);
}

void send_string(const char *s)         //send a string to display in the lcd
{
     while (s && *s)send_char (*s++);
}


unsigned char lcd_num(unsigned short number, unsigned char digit){
    unsigned char num[16];
    unsigned char k=digit-1;
    unsigned char i,j;

    num[digit]=0;

    for(i=0;i<digit;i++){
        num[k-i]=number%10+'0';
        number=number/10;
        if(number==0) break;
    }

    send_string(&num[k-i]);

    for(j=0;j<k-i;j++)
        send_char(' ');

    return(i);
}



/*uart function*/
void UART_INIT(void){

      //set port direction
    TRISCbits.TRISC7=1;     //RX
    TRISCbits.TRISC6=0;     //TX
    TRISCbits.TRISC4  =0;  //EN1 or AX12_CTRL
    TRISCbits.TRISC5 =0;   //EN2  or G15_CTRL


     // Initialize UART.
    TXSTAbits.BRGH = 1;     // Select high speed baud rate.
    BAUDCTLbits.BRG16=1;    // Baud 16bits

    /*BaudRate=FOSC/(4(n+1))*/

    SPBRG =0x03; SPBRGH=0x01; //19200
    RCSTAbits.SPEN = 1;                                    // Enable serial port.
    TXSTAbits.TXEN = 1;
    RCSTAbits.CREN = 1;

}

void UART_SEND(unsigned char data)
{
   while(!TRMT) ; //wait for previous transmit completion
   TXREG=data;
        while(!TRMT) ;
}

unsigned char UART_REC(void)         //receive uart value
{
    unsigned long waitcount=0;
    unsigned char rec_data;

    if(RCSTAbits.OERR){
        RCSTAbits.CREN=0;
        RCSTAbits.CREN=1;
        ERR_FLAG=1;
        return(255);
    }
    // Read the received data.
    while (RCIF == 0) //wait for data
    {
        waitcount++;
        if (waitcount > UARTWAIT){ //   break if wait too long, no incoming data
            ERR_FLAG=1;
            return (255); //no line
        }
    }

    rec_data = RCREG;

    if (FERR == 1) {
        while(RCIF) rec_data=RCREG;
        ERR_FLAG=1;
        return (255);
    }
    else{
        ERR_FLAG=0;
        return rec_data;               //return the data received
    }
}
Mohd093
Freshie
 
Posts: 7
Joined: Wed Mar 25, 2015 12:02 am

Re: G15 Driver NOT working

Postby Mohd093 » Wed Mar 25, 2015 12:26 pm

BTW im using mplab X with XC8 compiler , and this is the picture of my circuit

Image
Mohd093
Freshie
 
Posts: 7
Joined: Wed Mar 25, 2015 12:02 am

Re: G15 Driver NOT working

Postby KISH » Wed Mar 25, 2015 4:59 pm

I just tested the sample code from G15 page too. Just simply import and write the the hex code in the folder using PICkit2 into SK40C with PIC16F887. The picture shows the hardware setup. It is working fine. I did not open the MPLAB X or compile it. The code is working on PIC16F887.

Please make sure ,you use PIC16F887 and recheck the your circuit connectiom . Even one jumper loose can cause circuit to fail. If you use PIC16F887A , that Hex code file is not compatible. BTW, the control pin is RC4.

The G15 rotate 90 degree back and forth.
Attachments
ss.JPG
KISH
Greenhorn
 
Posts: 2
Joined: Wed Mar 25, 2015 4:20 pm

Re: G15 Driver NOT working

Postby Mohd093 » Wed Mar 25, 2015 8:04 pm

i dont have the SK40C i'm connecting it directly to the PIC16F887, so does that make any differences ?? i'm connecting the driver to 12v battery and i'm using voltage regulator of 5v from the same battery to feed the PIC16F887, also im using 20 MHZ oscillator when i want write the HEX file directly to the micro-controller this massage is out
Warning : Some configuration words not in hex file.
Ensure defualt values above right are acceptable

and above is written Configuration : 2CF2 0700

and its not working as well .... did this massage apear to you as well ??

and also i have checked all the wires and tried again and its not working as well

S
Mohd093
Freshie
 
Posts: 7
Joined: Wed Mar 25, 2015 12:02 am

Re: G15 Driver NOT working

Postby ober » Wed Mar 25, 2015 10:42 pm

No modification of code is needed, we test the sample code before we released it.

We use SK40C because it is easy and ready platform for us to develop the code right away.

With the code is working, correct PIC, and the code is running the LEDs as you highlighted in earlier post, G15 is working on Arduino shield, the possible problems left are connection to GD02, and GD02 itself.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1440
Joined: Wed Apr 15, 2009 1:03 pm

Re: G15 Driver NOT working

Postby Mohd093 » Wed Mar 25, 2015 10:57 pm

i meant by the LED is the LED of the GD02 not the LED that connected to R6 and R7 .... so how i can check if the GD02 isworking or not there is no any way to check that ??
Mohd093
Freshie
 
Posts: 7
Joined: Wed Mar 25, 2015 12:02 am

Re: G15 Driver NOT working

Postby Mohd093 » Thu Mar 26, 2015 12:56 am

i just tried again and even the LED of the project at pin R6 & R7 is working so as you said i think the problem is in the GD02 so how i can check whether the GD02 is working perfectly or not .. maybe there is something wrong with RX and TX ??
Mohd093
Freshie
 
Posts: 7
Joined: Wed Mar 25, 2015 12:02 am

Re: G15 Driver NOT working

Postby ober » Thu Mar 26, 2015 9:29 am

The LEDs will blink if SW1 is pressed according to the code, so do you have SW1? I don see any push button on board.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1440
Joined: Wed Apr 15, 2009 1:03 pm

Next

Return to DC Motor

Who is online

Users browsing this forum: No registered users and 1 guest