HERSOUT2 (Weird problem)


Closed Thread
Results 1 to 18 of 18

Hybrid View

  1. #1
    Join Date
    Nov 2009
    Location
    London
    Posts
    251

    Default HERSOUT2 (Weird problem)

    My baud settings are as follows:
    Code:
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    DEFINE HSER_BAUD 9600
    DEFINE HSER_SPBRG  51 ' 9600 Baud
    BAUDCON.3 = 1         ' Enable 16 bit baudrate generator
    DEFINE HSER2_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER2_TXSTA 20h ' Enable transmit, BRGH = 0
    DEFINE HSER2_CLROERR 1 ' Clear overflow automatically
    DEFINE HSER2_BAUD 14400
    my code is as follows:

    Code:
    com var byte[12]
    
    GETPIC:
    		PAUSE 3000
    		COM=0
    		GOSUB SYNC
    GOTO GETPIC
    ; UART2 IS CONNECTED TO THE CAMERA (www.4dsystems.com.au/downloads/micro-CAM/Docs/uCAM-DS-rev7.pdf)
    ; UART1 IS CONNECTED TO MY PC
    SYNC:
    		HSEROUT2 [$AA,$0D,$00,$00,$00,$00]
    		HSERIN2	1000,SYNC,[COM]
    		HSEROUT [$AA,$0D,$00,$00,$00,$00]' this statement and the ones below should not execute
    		HSEROUT	[COM,13,10]
    		HSEROUT2 [$AA,$0E,$0D,$00,$00,$00]
    	GOTO GETPIC
    RETURN
    I should not get any response on my PC as I have removed my MAX232 and there is no way the data can go to the camera. But I get the following:

    Code:
    AA 0D 00 00 00 AA 0D 0A
    why is com getting loaded with AA 0D 0A and then after a few loops of the same, it changes.

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,531


    Did you find this post helpful? Yes | No

    Default Re: HERSOUT2 (Weird problem)

    Hi,
    I guess a schematic of your setup would help, at least for me. But I guess that when you "remove" the MAX232 (provided it's located between the PIC and the camera (you DO have the RS232 version of the camera and not the TTL version, right?) the USART input on the PIC is floating, tricking the HSERIN2 statement into believing it's actually received something so the execution falls thru to the HSEROUT statement

    Another thing that sticks out is you have COM declared as an array of 12 bytes and the response from the camera response to a SYNC is, as far as I can see, 6+6 bytes but you're only grabbing the first one with your HSERIN2 statement. Then it all starts over and there may be a residual byte in the USART buffer.

    /Henrik.

  3. #3
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: HERSOUT2 (Weird problem)

    This looks like a loop to me...
    SYNC:
    HSEROUT2 [$AA,$0D,$00,$00,$00,$00]
    HSERIN2 1000,SYNC,[COM]
    Dave Purola,
    N8NTA
    EN82fn

  4. #4
    Join Date
    Nov 2009
    Location
    London
    Posts
    251


    Did you find this post helpful? Yes | No

    Default Re: HERSOUT2 (Weird problem)

    Quote Originally Posted by HenrikOlsson View Post
    Hi,
    I guess a schematic of your setup would help, at least for me. But I guess that when you "remove" the MAX232 (provided it's located between the PIC and the camera (you DO have the RS232 version of the camera and not the TTL version, right?) the USART input on the PIC is floating, tricking the HSERIN2 statement into believing it's actually received something so the execution falls thru to the HSEROUT statement

    Another thing that sticks out is you have COM declared as an array of 12 bytes and the response from the camera response to a SYNC is, as far as I can see, 6+6 bytes but you're only grabbing the first one with your HSERIN2 statement. Then it all starts over and there may be a residual byte in the USART buffer.

    /Henrik.
    Ok, lets start solving the puzzle.

    1) The camera is RS232 type
    2) USART was floating. I tied it high and no reply back now - this problem is solved (cheers for that)

    secondly can you suggest on how do I get these 12 bytes if HEX8 is the highest I can use

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,531


    Did you find this post helpful? Yes | No

    Default Re: HERSOUT2 (Weird problem)

    If you know the length of the response, 12 in this case:
    Code:
    HSERIN2 1000,SYNC,[COM\12]
    Since the normal response packet (except image data) seems to be 6 bytes and the camera response to a SYNC is an ACK (6 bytes) and a SYNC (6 bytes) I'd probably do it in two steps
    Code:
    COM1 VAR BYTE[6]
    COM2 VAR BYTE[6]
    HSERIN2 1000,SYNC,[COM1\6]
    HSERIN2 1000,SYNC,[COM2\6]

  6. #6
    Join Date
    Nov 2009
    Location
    London
    Posts
    251


    Did you find this post helpful? Yes | No

    Default Re: HERSOUT2 (Weird problem)

    Quote Originally Posted by HenrikOlsson View Post
    If you know the length of the response, 12 in this case:

    HSERIN2 1000,SYNC,[COM\12]
    [
    Not quiet sure about this. Doesn't seem to be valid.
    I have instead declared 12 different variables and trying to get the response in them...i.e. - HSERIN 500,SYNC,[COM,ID,P1,P2,P3.....]

    But it does not work, must be something with the baud, any idea what is the MAX baud we can do with 8MHz osc. I will appreciate if you can show as to how you can calculate it.

  7. #7
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    654


    Did you find this post helpful? Yes | No

    Default Re: HERSOUT2 (Weird problem)

    Quote Originally Posted by Megahertz View Post
    Not quiet sure about this. Doesn't seem to be valid.
    The following text is taken from the manual. You will probably need to include the STR modifier.

    STR ArrayVar\n{\c}
    Receive string of n characters optionally ended in character c

    Quote Originally Posted by Megahertz View Post
    must be something with the baud, any idea what is the MAX baud we can do with 8MHz osc.
    Since you are dealing with HSEROUT2 (Hardware), my guess is that the answer to your question will be in the PIC datasheet.
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

Similar Threads

  1. Pulsin weird problem
    By allenf in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th September 2013, 18:33
  2. Weird problem with Debugin
    By Tina10 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 4th June 2013, 06:18
  3. Weird code problem
    By Navaidstech in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 16th March 2009, 11:16
  4. Weird Problem
    By isaac in forum General
    Replies: 9
    Last Post: - 22nd September 2008, 19:30
  5. PIC18F got some weird problem?
    By NatureTech in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 19th February 2007, 16:18

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