RC India
Welcome Guest, please login or register.
 
Pages: [1]   Go Down
0 Members and 1 Guest are viewing this topic. Topic Tools Topic Tools 
Read
« on: June 15, 2012, 07:29:10 AM »
pradeep_K_B
Plane Lover
Active Member

**

Reputation Power: 1 
pradeep_K_B has no influence.
Offline Offline

City: Malappuram,Kerala
State: Kerala
RC Skills: Beginner
Posts: 35
Join Date: May, 2012




hello...i need to program a PIC 16f690 for to drive my servo motor....i have the C programm with me,but i dont know how to convert it to hex...i already tried in different ways...but.....can u help me to take the hex code from my C programm...pls
Logged
 

Read
« Reply #1 on: June 15, 2012, 07:57:29 AM »
ralsonjemmy
Boat Lover
Active Member
**

Reputation Power: 1 
ralsonjemmy has no influence.
Offline Offline

City: Banglaore
State: Karnataka
RC Skills: Beginner
Posts: 6
Join Date: Jun, 2011



Hello,
that need to be 'compiled' to create a hex , do you have any info on which compiler was used to build ?

Regards
-RJ
Logged
 

Read
« Reply #2 on: June 15, 2012, 08:07:30 AM »
pradeep_K_B
Plane Lover
Active Member

**

Reputation Power: 1 
pradeep_K_B has no influence.
Offline Offline

City: Malappuram,Kerala
State: Kerala
RC Skills: Beginner
Posts: 35
Join Date: May, 2012



i have tried it with sourceboost,,but still i cant.....i dont have a standard PIC programmer with me like pickit2 or some thing,,,,i think thats the problem...but once i got the hex code i can programm my pic with my  pic programmer
Logged
 

Read
« Reply #3 on: June 15, 2012, 08:49:38 AM »
Swapnil
Plane Lover
Forum Hero

*****

Reputation Power: 20 
Swapnil barely matters.Swapnil barely matters.
Offline Offline

City: Pune
State: Maharashtra
RC Skills: Beginner
Posts: 1755
Join Date: May, 2010

Retreat, Hell!



Pradeep, send me the C file, I'll convert it to hex and send it back to you! Smiley
Logged
 

Read
« Reply #4 on: June 15, 2012, 08:50:14 AM »
Dharmik
Heli Lover
Forum Hero

*****

Reputation Power: 13 
Dharmik has no influence.
Offline Offline

City: Bharuch
State: Gujarat
RC Skills: Beginner
Posts: 1097
Join Date: Sep, 2011



I don't know much but try avr studio.
Logged
 

Read
« Reply #5 on: June 15, 2012, 08:55:38 AM »
Swapnil
Plane Lover
Forum Hero

*****

Reputation Power: 20 
Swapnil barely matters.Swapnil barely matters.
Offline Offline

City: Pune
State: Maharashtra
RC Skills: Beginner
Posts: 1755
Join Date: May, 2010

Retreat, Hell!



Dharmik, AVR studio is for ATMEL microcontrollers not PICs!
Logged
 

Read
« Reply #6 on: June 15, 2012, 09:03:26 AM »
pradeep_K_B
Plane Lover
Active Member

**

Reputation Power: 1 
pradeep_K_B has no influence.
Offline Offline

City: Malappuram,Kerala
State: Kerala
RC Skills: Beginner
Posts: 35
Join Date: May, 2012



ya...AVR is for atmel...Swapnil..can u help me?Huh???
Logged
 

Read
« Reply #7 on: June 15, 2012, 09:04:48 AM »
Swapnil
Plane Lover
Forum Hero

*****

Reputation Power: 20 
Swapnil barely matters.Swapnil barely matters.
Offline Offline

City: Pune
State: Maharashtra
RC Skills: Beginner
Posts: 1755
Join Date: May, 2010

Retreat, Hell!



Yes, like I said in reply #3, send me the C file... I'll convert it to hex and send it back to you!
Logged
 

Read
« Reply #8 on: June 15, 2012, 09:06:31 AM »
pradeep_K_B
Plane Lover
Active Member

**

Reputation Power: 1 
pradeep_K_B has no influence.
Offline Offline

City: Malappuram,Kerala
State: Kerala
RC Skills: Beginner
Posts: 35
Join Date: May, 2012



thank u....can i get your email id pls?Huh?
Logged
 

Read
« Reply #9 on: June 15, 2012, 09:09:27 AM »
pradeep_K_B
Plane Lover
Active Member

**

Reputation Power: 1 
pradeep_K_B has no influence.
Offline Offline

City: Malappuram,Kerala
State: Kerala
RC Skills: Beginner
Posts: 35
Join Date: May, 2012



// ***************************************************************************
//  File Name    : servo.c
//  Version      : 1.0
//  Description  : Servo Motor Controller
//                 Using TIMER0 for Generating Servo PWM
//  Target       : PICJazz 16F690 Board
//  Compiler     : HITECT PICC-Lite Version 9.60PL1
//  IDE          : Microchip MPLAB IDE v8.00
//  Programmer   : PICKit2
// ***************************************************************************
#include <pic.h>
/*   PIC Configuration Bit:
**   INTIO     - Using Internal RC No Clock
**   WDTDIS    - Wacthdog Timer Disable
**   PWRTEN    - Power Up Timer Enable
**   MCLREN    - Master Clear Enable
**   UNPROTECT - Code Un-Protect
**   UNPROTECT - Data EEPROM Read Un-Protect
**   BORDIS    - Borwn Out Detect Disable
**   IESODIS   - Internal External Switch Over Mode Disable
**   FCMDIS    - Monitor Clock Fail Safe Disable
*/
__CONFIG(INTIO & WDTDIS & PWRTEN & MCLREN & UNPROTECT \
  & UNPROTECT & BORDIS & IESODIS & FCMDIS);
// Using Internal Clock of 8 Mhz
#define FOSC 8000000L
// Servo definition and variables
#define MAX_VALUE 200
#define CCW_ROTATION MAX_VALUE - 20
#define CW_ROTATION MAX_VALUE - 10
#define STOP_ROTATION MAX_VALUE
#define THRESHOLD_VALUE 50
unsigned char pulse_max=0;
unsigned char pulse_top=0;
unsigned char top_value = 0;
static void interrupt isr(void)
{
  if(T0IF) {             // TIMER0 Interrupt Flag
    pulse_max++;            // Pulse Max Increment
    pulse_top++;            // Pulse Top Increment

    /* MAX_VALUE=200 turn off the pulse */
    if (pulse_max >= MAX_VALUE) {
      pulse_max=0;
      pulse_top=0;
      RC2=0;                // Turn off RC2
    }

    /* top_value = MAX_VALUE - n, n=10: 10 x 0.1ms = 1.0ms, n=20: 20 x 0.1ms = 2.0ms */
    /* 2ms -> CCW Rotation, 1ms -> CW Rotation */
    if (pulse_top == top_value) {
      RC2=1;                // Turn On RC2
    }
    TMR0 = 156;             // Initial Value for 0.1ms Interrupt
    T0IF = 0;     // Clear TIMER0 interrupt flag
  }
}
void main(void)
{
  unsigned char ldr_left;
  unsigned char ldr_right;
  int ldr_diff;
  OSCCON=0x70;         // Select 8 Mhz internal clock
  /* Initial Port Used */
  TRISC = 0x03;        // Set RC0 and RC1 as input others as Output
  ANSEL = 0x30;        // Set PORT AN4 and AN5 as analog input
  ANSELH = 0x00;       // Set PORT AN8 to AN11 as Digital I/O
  PORTC = 0x00;        // Turn Off all PORTC
  /* Init Servo Pulse */
  pulse_max=0;
  pulse_top=0;
  top_value = MAX_VALUE; // top_value = MAX_VALUE: Servo Motor Stop
  /* Initial ADC */
  ADCON1=0b00110000;   // Select the FRC for 8 Mhz
  /* Init TIMER0: Period: Fosc/4 x Prescaler x TMR0
     0.0005 ms x 2 * 100 = 0.1 ms */
  OPTION = 0b00000000; // 1:2 Prescaller
  TMR0=156;            // Interupt every 0.1 ms
  T0IE = 1;        // Enable interrupt on TMR0 overflow
  GIE = 1;        // Global interrupt enable

  for(;;) {
    /* Read the ADC here */
    ADCON0=0b00010001;       // select left justify result. ADC port channel AN4
    GODONE=1;              // initiate conversion on the channel 4
    while(GODONE) continue;  // Wait for ldr_left conversion done
    ldr_left=ADRESH;         // Read 8 bits MSB, Ignore 2 bits LSB in ADRESL
    ADCON0=0b00010101;       // select left justify result. ADC port channel AN5
    GODONE=1;              // initiate conversion on the channel 5
    while(GODONE) continue;  // Wait for ldr_right conversion done
    ldr_right=ADRESH;        // Read 8 bits MSB, Ignore 2 bits LSB in ADRESL

    /* Get the different */
    ldr_diff=ldr_left - ldr_right;   

    if ((ldr_diff >= -THRESHOLD_VALUE) && (ldr_diff <= THRESHOLD_VALUE)) {
      top_value = MAX_VALUE;     // Stop the Servo Motor
    } else {
      if (ldr_diff > THRESHOLD_VALUE) {
        top_value = CCW_ROTATION;  // Counterclockwise Rotation
      } else {
        top_value = CW_ROTATION;   // Clockwise Rotation
      }
    }
  }
}
/* EOF: servo.c */
Logged
 

Read
« Reply #10 on: June 15, 2012, 09:10:01 AM »
pradeep_K_B
Plane Lover
Active Member

**

Reputation Power: 1 
pradeep_K_B has no influence.
Offline Offline

City: Malappuram,Kerala
State: Kerala
RC Skills: Beginner
Posts: 35
Join Date: May, 2012



its the code.....pls
Logged
 

Read
« Reply #11 on: June 15, 2012, 09:15:18 AM »
Swapnil
Plane Lover
Forum Hero

*****

Reputation Power: 20 
Swapnil barely matters.Swapnil barely matters.
Offline Offline

City: Pune
State: Maharashtra
RC Skills: Beginner
Posts: 1755
Join Date: May, 2010

Retreat, Hell!



Hmm...Okay can you please wait till afternoon, I'm a bit busy right now. I'll install PICC-Lite and send the hex to you. I also have MicroC pro, will check a servo program there too. Hang tight!
Logged
 

Read
« Reply #12 on: June 15, 2012, 09:24:53 AM »
pradeep_K_B
Plane Lover
Active Member

**

Reputation Power: 1 
pradeep_K_B has no influence.
Offline Offline

City: Malappuram,Kerala
State: Kerala
RC Skills: Beginner
Posts: 35
Join Date: May, 2012



ok...thank you.....
Logged
 

Read
« Reply #13 on: June 15, 2012, 10:13:59 AM »
Swapnil
Plane Lover
Forum Hero

*****

Reputation Power: 20 
Swapnil barely matters.Swapnil barely matters.
Offline Offline

City: Pune
State: Maharashtra
RC Skills: Beginner
Posts: 1755
Join Date: May, 2010

Retreat, Hell!



Pradeep, why don't you try an Arduino? It's cheap, simple and hassle-free.
And it has a dedicated servo library! So you only need 3 lines of code!


#include <Servo.h>
Servo servo1;

-----main loop----

servo1.writeMicroseconds(1765);

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

That's it!

Logged
 

Read
« Reply #14 on: June 15, 2012, 10:27:28 AM »
pradeep_K_B
Plane Lover
Active Member

**

Reputation Power: 1 
pradeep_K_B has no influence.
Offline Offline

City: Malappuram,Kerala
State: Kerala
RC Skills: Beginner
Posts: 35
Join Date: May, 2012



but i dont have a Adruino programmer..i have only the PIC programmer with me...thats y Sad
Logged
 

Read
« Reply #15 on: June 15, 2012, 10:32:13 AM »
Swapnil
Plane Lover
Forum Hero

*****

Reputation Power: 20 
Swapnil barely matters.Swapnil barely matters.
Offline Offline

City: Pune
State: Maharashtra
RC Skills: Beginner
Posts: 1755
Join Date: May, 2010

Retreat, Hell!



Okay send me your e-mail id, I'll send you the hex file...
Logged
 

Read
« Reply #16 on: June 15, 2012, 10:35:00 AM »
pradeep_K_B
Plane Lover
Active Member

**

Reputation Power: 1 
pradeep_K_B has no influence.
Offline Offline

City: Malappuram,Kerala
State: Kerala
RC Skills: Beginner
Posts: 35
Join Date: May, 2012



pls check ur private message
Logged
 

Read
« Reply #17 on: June 15, 2012, 10:37:54 AM »
Swapnil
Plane Lover
Forum Hero

*****

Reputation Power: 20 
Swapnil barely matters.Swapnil barely matters.
Offline Offline

City: Pune
State: Maharashtra
RC Skills: Beginner
Posts: 1755
Join Date: May, 2010

Retreat, Hell!



Sent!  Smiley
Logged
 

Read
« Reply #18 on: June 15, 2012, 10:43:42 AM »
pradeep_K_B
Plane Lover
Active Member

**

Reputation Power: 1 
pradeep_K_B has no influence.
Offline Offline

City: Malappuram,Kerala
State: Kerala
RC Skills: Beginner
Posts: 35
Join Date: May, 2012



thank u ...thank u very much....
Logged
 

Read
« Reply #19 on: June 15, 2012, 10:45:33 AM »
pradeep_K_B
Plane Lover
Active Member

**

Reputation Power: 1 
pradeep_K_B has no influence.
Offline Offline

City: Malappuram,Kerala
State: Kerala
RC Skills: Beginner
Posts: 35
Join Date: May, 2012



if u dont mind ,can i ask you for one more help??plssss
Logged
 

Read
« Reply #20 on: June 15, 2012, 10:50:12 AM »
Swapnil
Plane Lover
Forum Hero

*****

Reputation Power: 20 
Swapnil barely matters.Swapnil barely matters.
Offline Offline

City: Pune
State: Maharashtra
RC Skills: Beginner
Posts: 1755
Join Date: May, 2010

Retreat, Hell!



Post it, I'll check it in evening...time for lunch now! Smiley
Logged
 

Read
« Reply #21 on: June 15, 2012, 10:51:25 AM »
pradeep_K_B
Plane Lover
Active Member

**

Reputation Power: 1 
pradeep_K_B has no influence.
Offline Offline

City: Malappuram,Kerala
State: Kerala
RC Skills: Beginner
Posts: 35
Join Date: May, 2012



ok..thank u..but its in .asm format..
Logged
 

Read
« Reply #22 on: June 15, 2012, 11:55:14 AM »
pradeep_K_B
Plane Lover
Active Member

**

Reputation Power: 1 
pradeep_K_B has no influence.
Offline Offline

City: Malappuram,Kerala
State: Kerala
RC Skills: Beginner
Posts: 35
Join Date: May, 2012



its the code

;**********************************************************************
;                                                                     *
;    Filename:     encoder.asm                                       *
;    Date:                                                            *
;    File Version:                                                    *
;                                                                     *
;**********************************************************************
;NOTES
;encoder v4.2
;
;**********************************************************************
;HISTORY
;
; 040-20050131 4/8-channel encoder for 16F630
; 041-20050213
; 042-20050217 modify transmission repetition algorithm
; 043-20050227 use IR medium with irmtxv4 library
; 044-20090531 adapt 042-20050227 to the pic16f628
;
;**********************************************************************
list p=16f628
__CONFIG   _CP_OFF & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT & _LVP_OFF & _MCLRE_OFF & _BODEN_OFF


; toggle or momentary mode, 8 channels
#define MODE_CH8

; ON/OFF latched mode, 4 channels
;#define MODE_CH4

#include <p16F628.inc>
#include <mtxv4.inc>

variables UDATA
; RAM registers
tcnt RES 1
rcnt RES 1
cod RES 1
prevcod RES 1
cod0 RES 1
rowstate RES 1

startup CODE 0
  goto main
nop
nop
nop
retfie

prog CODE

main ; program starts here
clrf PORTA
clrf PORTB
clrf TMR0

BANKSEL TRISA
movlw 0
movwf TRISA
movlw 0xf0
movwf TRISB

bcf OPTION_REG, PSA
clrwdt
clrf OPTION_REG
clrwdt

BANKSEL PORTA
movlw 7
movwf CMCON
movlw (1<<RBIE); RB4-7 int on change enable
movwf INTCON

call mtx_init
clrf mtx_buffer
clrf tcnt

loop0 clrf (mtx_buffer+1)
movlw 0xff
movwf prevcod ; no button was pressed in the previous scan
movlw 0xfc ;ca,cb=0,cj=1
movwf PORTB
movlw 0xf0
tris PORTB
movf PORTB, W
bcf INTCON, RBIF
sleep

loop clrf cod
movlw 0xfe
tris PORTB ; select colA (RB0)
clrf PORTB
#ifdef MODE_CH8
clrw
#endif
#ifdef MODE_CH4
movlw 0x20
#endif
call scan
movlw 0xfd
tris PORTB ; select colB (RB1)
#ifdef MODE_CH8
movlw 0x04
#endif
#ifdef MODE_CH4
movlw 0x30
#endif
call scan
movf cod, W
bz loop2 ; if no buton is pressed, skip

subwf prevcod, W ; if the same button is pressed, skip
bz loop2

movf cod, W
movwf prevcod ; a new button is pressed - rcnt=3
movwf (mtx_buffer+1)
movlw 3
movwf rcnt

movlw 0x40 ; new button - new transmission
addwf tcnt, F

loop2 movlw 0xf7
tris PORTB ; select ID (RB3)
call scanid
movf cod0, W
movwf (mtx_buffer)

loop3 movf (mtx_buffer+1), W
andlw 0x3f
iorwf tcnt, W
movwf (mtx_buffer+1)

call mtx_send

movf rcnt, W
bz loop_done
decfsz rcnt, F
goto loop

loop_done movf cod, W
btfsc STATUS, Z
goto loop0 ; no button was pressed, go sleep
; if the same button is being hold, repeat the transmission
goto loop

scan movwf cod0
;movlw 0xc0
scandelay ;addlw 1
;bnz scandelay
movlw 0xf0
andwf PORTB, W
movwf rowstate

incf cod0, F
btfss rowstate, 4
goto pressed

incf cod0, F
btfss rowstate, 5
goto pressed

incf cod0, F
btfss rowstate, 6
goto pressed

incf cod0, F
btfss rowstate, 7
goto pressed
retlw 0

pressed movf cod0, W
movwf cod
return

scanid clrf cod0
clrw
scandelay2 addlw 1
bnz scandelay2
movlw 0xf0
andwf PORTB, W
movwf rowstate

btfss rowstate, 7
bsf cod0, 3
btfss rowstate, 6
bsf cod0, 2
btfss rowstate, 5
bsf cod0, 1
btfss rowstate, 4
bsf cod0, 0
return

end
Logged
 

Pages: [1]   Go Up
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Is it Possible to convert a SIM to a TX with a Hack module?
Radios and Receivers
avijit17basu 6 4878 Last post October 27, 2009, 10:37:01 PM
by HamAero
Skyrider 24 inch Glider Convert to RC
Electric Planes
Ashta 7 4436 Last post July 22, 2010, 11:53:06 AM
by Ashta
GWS beaver convert to Ailerons
Electric Planes
hangingtough 5 5718 Last post June 19, 2011, 11:44:13 PM
by hangingtough
Need help with intel 8051 microcontroler.
Servos, Gyros and All Electronics
speedracer 7 5386 Last post April 19, 2013, 12:18:39 AM
by wings_of_fire
QR Code scanning
Beginners Zone
Anirwan Kumar 5 2561 Last post November 19, 2018, 05:47:57 PM
by Anirwan