Serin general question


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Sep 2011
    Posts
    20

    Default Serin general question

    I am using 2 16F887a's to communicate data via RS485 in an ROV project. Sending data from the ROV to the surface works fine, but I can't get the ROV to recieve data for the light switch command (I know the comm's are working because I am using a Pololu servo controller to operate the thrusters). Can some one tell me what is wrong with the following code? The processor hangs striaght after the I2C command.
    Light_pos =0
    Main:
    i2cread SDA,SCL,$C0,2,[bearing.Highbyte,bearing.lowbyte] 'get data from the compass
    lcdout $fe, 1,"Heading ",DEC BEARING/10,223
    SEROUT PORTC.6,T9600,["H",bearing.Highbyte,bearing.lowbyte] 'transmit compass data to the surface
    Serin PORTC.7,T9600,200,read_adc,["L"],Light_val ' test for light status from the surface
    read_adc:
    ADCIN 0,AD0 ' read AD's for temp, gyro and pressure
    AD0 = (AD0*10)/quanta
    LCDOUT $fe, $C0
    LCDOUT DEC AD0
    AD0=0

  2. #2
    Join Date
    Jul 2009
    Location
    Ohio, USA
    Posts
    57

    Default Re: Serin general question

    Do you have Include "modedefs.bas" somewhere near the beginning of your code?

    Also check out the SERIN2 command.

  3. #3
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107

    Default Re: Serin general question

    Why in the world would you use SERIN/SEROUT when you have hardware serial ports available?
    Charles Linquist

  4. #4
    Join Date
    Sep 2011
    Posts
    20

    Default Re: Serin general question

    Yes the "modedefs.bas" has been included. Sorry I don't get the comment about hardware ports?
    The LCD stuff is in there jsut so that I can see what is going on. If the Serin is removed (commented out) the program runs fine???

  5. #5
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107

    Default Re: Serin general question

    The chip you are using has a EUSART = Hardware serial port.

    You can use HSERIN and HSEROUT for your communications. You can read PIR1.5 (at least that is what it is in 18F chips), you have serial port interrupts, you can transfer a byte and move on.....

    Things work so much better when you use the hardware that Microchip has provided.
    Charles Linquist

  6. #6
    Join Date
    Sep 2011
    Posts
    20

    Default Re: Serin general question

    Understood thanks ref the HSERIN....I will give it a try. The strange thing is it works fine on the surface control unit. The other thing is I am using RS485 chips directly.
    Will give it a try and report back....when normal work dosen't get in the way

  7. #7
    Join Date
    Sep 2011
    Posts
    20

    Default Re: Serin general question

    I could not get the HSERIN to work....probably timing and RCV stack overflowing. I can't see how I can use the interupt because I don't want to interupt the program.....the motor/thruster commands must take priority. However I did fianlly manage to get the SERIN/SEROUT working, it was a stupid mistake in my program - the jump to statement was pointing to the wrong place. Would like to use the HSERIN though at some point I think it would give better control and think it would also allow me to reduce one of the additinal PCB's.
    Thanks for your help

  8. #8
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869

    Default Re: Serin general question

    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts