HERSOUT2 (Weird problem)


Closed Thread
Results 1 to 18 of 18

Hybrid View

  1. #1
    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.

  2. #2
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    704


    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

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


    Did you find this post helpful? Yes | No

    Default Re: HERSOUT2 (Weird problem)

    ok. I tried to get 512 bytes using string (STR command) and the following statements

    Code:
    MESS1 VAR BYTE[512]
    
    HSERIN2 [STR MESS1\512]
    The data seems to be getting corrupted as I believe some bytes arriving in HEX format don't add up in a sensible way in string format. Like $00 will be considered as null. Is there any idea as to how to get them in HEX format?

  4. #4
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    704


    Did you find this post helpful? Yes | No

    Default Re: HERSOUT2 (Weird problem)

    The maximum number of bytes in an array is 96 according to the manual.
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

  5. #5
    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 rsocor01 View Post
    The maximum number of bytes in an array is 96 according to the manual.
    It is irrelevant now as I need to find a way to get it in hex until there is a way to convert it back.
    I can create byte[90] and do it that way.

  6. #6
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

    Default Re: HERSOUT2 (Weird problem)

    When using STR, maximum number of bytes is 255. It is only one byte counter.
    Darrel already give simple workaround:
    HSERIN2 [STR MESS1\255, STR MESS1[256]\255]

  7. #7
    Join Date
    Jan 2013
    Location
    Texas USA
    Posts
    229


    Did you find this post helpful? Yes | No

    Default Re: HERSOUT2 (Weird problem)

    After reading your posts and having a look at the camera datasheet, I would look at a couple of things.

    First, if you are still trying to communicate to the camera at 14400 and your PIC OSC frequency is 8MHz, then I would set the following parameters.

    For the second EUSART port, set the following register bits manually:
    SYNC = 0
    BRGH = 1
    BRG16 = 1
    SPBRGH = 0
    SPBRG = 137

    This will setup 14400 with a resultant 0.64% error rate. This is as good as you can get at 8MHz.

    Secondly, looking at the camera datasheet, the communication between the PIC and camera is NOT sending "ascii" Hex characters, it is binary data.
    So that being said, you should not use Input/Output modifiers (I.e. HEX/BIN/DEC) with the HSERIN2/HSEROUT2 commands to/from the camera.

    I would try the following for testing purposes.
    This assumes that the PC is connected to the 1st HSER port of the PIC for debug purposes and the PC is running a terminal emulator program.

    Code:
    com var byte[12]
    i var byte
    
    
    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]  'TX SYNC
    		for i = 0 to 11
    		    HSERIN2	1000,SYNC,[COM(i)]      'Rx ACK & SYNC pattern (2 x 6 bytes)
    		next i
    		HSEROUT2 [$AA,$0E,$0D,$00,$00,$00]  'TX ACK
    		
    		for i = 0 to 11     'Tx 12 bytes to PC for display             
        		HSEROUT [hex2 COM(i)]   'hex2 sends the data as "ascii" codes representing HEX digits 
        		HSEROUT [13,10]
    		next i
    		
    	GOTO GETPIC
    RETURN
    This should:
    1. Send the 6byte SYNC pattern to the camera.
    2. Receive the 6byte ACK pattern response from the camera.
    3. Receive the 6byte SYNC pattern response from the camera.
    4. Send the 6byte ACK pattern to the camera.

    5. Transmit out "ascii" character representations of the binary data stored in the COM byte array to the PC to be displayed in a terminal emulation program.
    Regards,
    TABSoft

  8. #8
    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 pedja089 View Post
    When using STR, maximum number of bytes is 255. It is only one byte counter.
    Darrel already give simple workaround:
    HSERIN2 [STR MESS1\255, STR MESS1[256]\255]
    Thanks for the detail. What does this (bold highlighted) code do?

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 : 0

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