Author Topic: cmu interface with microcontroller 16f877a  (Read 3791 times)

0 Members and 1 Guest are viewing this topic.

Offline NEROTopic starter

  • Jr. Member
  • **
  • Posts: 20
  • Helpful? 0
cmu interface with microcontroller 16f877a
« on: December 11, 2007, 10:03:15 AM »
hi...
i have bought cmu camera version 1....
i have a problem to interface with my microcontroller....
i have read the manual.....and use the ttl communication types....
but nothing happen.... i am trying to give command "L1 1" to make the tracking led on.
should i need any converter?

paulstreats

  • Guest
Re: cmu interface with microcontroller 16f877a
« Reply #1 on: December 11, 2007, 10:29:03 AM »
can you paste the code you are using on the PIC

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: cmu interface with microcontroller 16f877a
« Reply #2 on: December 11, 2007, 02:24:43 PM »
tell us more about your hardware setup, too

Offline Fredrik Andersson

  • Robot Overlord
  • ****
  • Posts: 216
  • Helpful? 0
Re: cmu interface with microcontroller 16f877a
« Reply #3 on: December 11, 2007, 03:57:13 PM »
Did you send the newline character?
Current project: Pirrh - Portable Intelligent Round Rolling Hexapod

Offline NEROTopic starter

  • Jr. Member
  • **
  • Posts: 20
  • Helpful? 0
Re: cmu interface with microcontroller 16f877a
« Reply #4 on: December 12, 2007, 09:40:51 AM »

This is my code.... i use TTL channel from CMU cam board...
My connection Rx Cmu -->Tx PIC(RC6)  and Tx Cmu -->Rx PIC(RC7)


Quote
#include <system.h>

//Target PIC16F877 configuration word
#pragma DATA _CONFIG, _PWRTE_OFF & _BODEN_OFF & _WDT_OFF & _LVP_ON & _CPD_OFF & _DEBUG_OFF & _HS_OSC & _CP_OFF

//Set clock frequency
#pragma CLOCK_FREQ   20000000





   
   
   void serial_init(void)
{
   
    trisc = 10000000b;
   
    set_bit( rcsta, SPEN );    // Enable Serial port
   
    spbrg = 129;                //set baudrate 9600bps

    set_bit( txsta, BRGH );    // RRGH = 1   ( High speed mode )
   
    set_bit( txsta, TXEN );    // Enable Transmitter

    set_bit( pie1, RCIE );     // Enable Receive Interrupt
   set_bit( pie1, TXIE );
 

    set_bit( rcsta, CREN );    // Enable continuous receive
   
    set_bit( intcon, PEIE );   // Enable all Peripheral Interrupts
    set_bit( intcon, GIE );    // Enable Global Interrupts

   

   


}


   
void serialSendChar(char value)
{
    while((txsta & 1 << TRMT) == 0);                                 // TRMT is better then TXIF
    txreg = value;
    clear_bit(pie1,TXIE);
}

char serialReceiveChar()
{
    while((pir1 & 1 << RCIF) == 0);
    return rcreg;
}

void serialSendString(const char* text)
{
    char i = 0;
    while(text != 0)
         serialSendChar(text[i++]);
}



void interrupt( void )
{
   //Handle port change interrupt
   if( intcon & (1<<RBIF) )
   {
      clear_bit( intcon, RBIF );
   }

   //Handle external interrupt
   if( intcon & (1<<INTF) )
   {
      clear_bit( intcon, INTF );
   }

   //Handle timer0 interrupt
   if( intcon & (1<<T0IF) )
   {
      
      clear_bit( intcon, T0IF ); //clear timer 0 interrupt bit
   }

   

}

void main( void )
{
   serial_init();
   delay_s(2);
   serialSendString("RS\r");
   delay_s(5);
   
   
   //Endless loop
   do{
   
   serialSendString("L1 1\r");
   
   delay_s(2);
   serialSendString("L1 0\r");
   delay_s(2);}
   
   while( 1 );
   
}

paulstreats

  • Guest
Re: cmu interface with microcontroller 16f877a
« Reply #5 on: December 12, 2007, 10:45:13 AM »
the datasheet for the cmu cam 1 says that the baud rate should be 115,200 baud. You currently have it set at 9,600 on the PIC.

There is no SPBRG value available on the PICs datasheet for that fast baud rate, though you could try using 10 as the SPBRG value and you might get somewhere, otherwise youll need to get a different mcu.
If 10 doesnt work try setting at 0 and working up to 10, you might get lucky and hit on a magic number.


paulstreats

  • Guest
Re: cmu interface with microcontroller 16f877a
« Reply #6 on: December 12, 2007, 11:37:34 AM »
apparently theres a jumper on the cmu board to reduce the baud down to 38,400 but you would need to fiddle with the spbrg value since there doesnt appear to be one in the pic datasheet

Offline NEROTopic starter

  • Jr. Member
  • **
  • Posts: 20
  • Helpful? 0
Re: cmu interface with microcontroller 16f877a
« Reply #7 on: December 12, 2007, 11:52:02 AM »
hi...
but i have tested with baudrate 115200....
it still give the same condition.....
so i decided to try 9600bps coz ttl has a limit speed...
am i right?

 


data_list