help with hserout and hserin cmucam4


+ Reply to Thread
Results 1 to 9 of 9

Thread: help with hserout and hserin cmucam42552 days old

  1. #1
    siyete
    Guest siyete's Avatar

    0 Not allowed!

    Default help with hserout and hserin cmucam4

    hi im having problems writing my hserout and hserin.. can anyone help?..
    this is the code im currently writing

    Code:
    '****************************************************************
    '*  Name    : SE7EN.BAS                                         *
    '*  Author  : Raymond Angelo D. Esguerra                        *
    '*  Notice  : Copyright (c) 2012                                *
    '*          : All Rights Reserved                               *
    '*  Date    : 12/13/2012                                        *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    Device 16F877A
    Declare Xtal = 4                'Crystal Oscillator
    ADCON1 = 7
    
    
    Declare LCD_Type 0
    Declare LCD_DTPin PORTC.0
    Declare LCD_ENPin PORTC.5
    Declare LCD_RSPin PORTC.4
    Declare LCD_Interface 4
    Declare LCD_Lines 4
    
    
    All_Digital = True              'ALL PORTS IN DIGITAL MODE
    PortB_Pullups = On
    
    
    TRISA  = 000
    TRISB  = 000000
    TRISC  = 000000
    TRISD  = 000000
    TRISE  = 0
    
    
    '----------Serial Port Initialization----------
    Declare Hserial_Baud = 19200    ' Set baud rate
    Declare Hserial_RCSTA = $90     ' Enable serial port and continuous receive
    Declare Hserial_TXSTA = $24     ' Enable transmit and asynchronous mode 
    Declare Hserial_Clear On        ' Clear Buffer Before Receiving
    
    
    Dim tc_mx As Byte
    Dim tc_my As Byte
    Dim tc_x1 As Byte
    Dim tc_y1 As Byte
    Dim tc_x2 As Byte
    Dim tc_y2 As Byte
    Dim tc_p0 As Byte
    Dim tc_c0 As Byte 
    Dim midX As Byte
    Dim pi As Byte
    
    
    tc_mx = 0
    tc_my = 0
    tc_x1 = 0
    tc_y1 = 0
    tc_x2 = 0
    tc_y2 = 0
    tc_p0 = 0
    tc_c0 = 0
    midX = 0
    pi = 0
    
    
    Clear PORTA
    Clear PORTB
    Clear PORTC
    Clear PORTD
    Clear PORTE
    
    
    '----------Initialize Camera----------
    Cls
    start:
    
    
    HSerOut ["ag 0",13]
    HSerIn [ACK]
        DelayMS 500
    HSerOut ["aw 0",13]
    HSerIn [ACK]
        DelayMS 500
    HSerOut ["nf 2",13]
    HSerIn [ACK]
        DelayMS 500
    HSerOut ["pm 1",13]
    HSerIn [ACK]
        DelayMS 500
        
    '----------Send Data Request----------
    main:
    HSerOut ["tc 100 130 170 200 50 80",13]
    '----------Receive Camera Data----------
    HSerIn [tc_mx,tc_my,tc_x1,tc_y1,tc_x2,tc_y2,tc_p0,tc_c0]
    'mx = midX
    'my = midY
    'x1,y1,x2,y2 = upper and lower coordinates (we're not going to use)
    'midX is all we need(robot only goes left and right)
    'p0 = size (low means object is far, high means object is near)
    'c0 = confidence level (tracking correct color) 
    'from test, confidence of 30 is already OK
    '----------Process Camera Data----------
    If tc_p0 < 1 And tc_c0 < 20
    Then GoTo main
    'No Ball Detected Light All LED
        DelayMS 5000
    Else
    midX = tc_mx / 10
    GoTo direction
    EndIf
    
    
    direction:
    If midX < 6 Then
        'Light Left LED
        DelayMS 5000
    ElseIf midX > 10 Then
        'Light Right LED
        DelayMS 5000
    Else
        'Light Middle LED
        DelayMS 5000
    EndIf
    
    
    GoTo main
    ''----------------------------------------------------------------------------------------------------------    
    ''-----------------------------------------------------------------------------------------------------------            
        End ' This is where the code will stop to execute.
        ' This program should not reach this point as the last subroutine above
        ' will return to the point after from where it was called.
        ' So this 'END' instruction is not really need. BUT it is a very good idea
        ' to have an END point  in case of errors in the code.
        ' This provides some safety against unpredictable operation and 
        ' makes debugging easier (sometimes).

    the problem is i dont know if im doing the hserout and hserin correctly..
    this is the sample tx and rx response from cmucam4..

    Code:
    :ag 0 (command sent to camera) i used HSerOut ["ag 0",13]
    ACK (response from camera) i used HSerIn [ACK]
    
    
    :tc 100 130 170 200 50 80 (command sent to camera) used code HSerOut ["tc 100 130 170 200 50 80",13]
    ACK (data received from camera)
    T 48 57 5 4 117 78 22 49 (data received from camera)
    i dont know how to do this because the camera sends 2 lines and with spaces..
    ACK
    T 48 57 5 4 117 78 22 49

    HSerIn[ACK]
    HSerIn [T,tc_mx,tc_my,tc_x1,tc_y1,tc_x2,tc_y2,tc_p0,tc_c0]

    dunno what im supposed to do, im still a beginner at programming..

Attention

This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

The advertisements we display are relevant to this web site and your browsing history

Please consider supporting us by disabling your ad blocker.


Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

If you can, please report issues in the forum area WebSite / Forum Issues


Thank you for your attention.

  • #2
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,676
    Thumbs Up
    Received: 47
    Given: 95
    Total Downloaded
    1.32 GB

    0 Not allowed!

    Default Re: help with hserout and hserin cmucam4

    Can you say what you are trying to achieve? I'm asking because what you have written does not seem to bad apart from not ensuring you start collecting the data on the start of the packet.
    Tim

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #3
    siyete
    Guest siyete's Avatar

    0 Not allowed!

    Default Re: help with hserout and hserin cmucam4

    what im trying to achieve is how to get the values sent back from cmucam4 to my pic..
    like when i send out "pm 1" the camera will send back "ack"
    im assuming it will look like this:
    HSerOut ["ag 0",13]
    HSerIn [ACK]

    im wondering if how can i achieve this when the camera sends back 2 lines and with spaces..
    like when i send out "tc 100 130 170 200 50 80" the camera will send back
    ACK
    T 48 57 5 4 117 78 22 49

    what will my hserin look like?.. and i would like to save the values sent back..
    like save 48=tc_mx, 57=tc_my, and so on..

    and also
    ACK\r how can i write that on hserin

    Last edited by siyete; 13th December 2012 at 21:48.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #4
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,676
    Thumbs Up
    Received: 47
    Given: 95
    Total Downloaded
    1.32 GB

    0 Not allowed!

    Default Re: help with hserout and hserin cmucam4

    I would receive the data as a string then parse it.

    Start by waiting for the start char

    Then make a loop collecting the data and place it in a string until you the end char is hit. You can then parse the string using the space as the separator.
    Tim

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #5
    siyete
    Guest siyete's Avatar

    0 Not allowed!

    Default Re: help with hserout and hserin cmucam4

    im just a beginner so how could i get the hserin data as string and how can i parse the data?..

    i saw this but have no idea how to change it to proton basic, i believe this is for arduino..
    int CMUcam4::getTypeTDataPacket(CMUcam4_tracking_data_ t * pointer){
    int errorValue;


    if(pointer == NULL)
    {
    return CMUCAM4_RETURN_FAILURE;
    }


    if(errorValue = _responceWrapper('T'))
    {
    return errorValue;
    }


    return (sscanf(_resBuffer,
    "T %d %d %d %d %d %d %d %d ",
    &(pointer->mx),
    &(pointer->my),
    &(pointer->x1),
    &(pointer->y1),
    &(pointer->x2),
    &(pointer->y2),
    &(pointer->pixels),
    &(pointer->confidence)) == 8)
    ? CMUCAM4_RETURN_SUCCESS : CMUCAM4_UNEXPECTED_RESPONCE;
    }
    can you help on how i can receive the data as a string then parse it?..

    Last edited by siyete; 14th December 2012 at 05:51.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #6
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,676
    Thumbs Up
    Received: 47
    Given: 95
    Total Downloaded
    1.32 GB

    0 Not allowed!

    Default Re: help with hserout and hserin cmucam4

    Hi

    A bit later when I get time I will put together some code.
    Tim

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #7
    siyete
    Guest siyete's Avatar

    0 Not allowed!

    Default Re: help with hserout and hserin cmucam4

    thanks it would really help a lot since im only starting to understand programming..
    ill try to visit this topic once in a while, hoping to hear from you soon.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #8
    siyete
    Guest siyete's Avatar

    0 Not allowed!

    Default Re: help with hserout and hserin cmucam4

    just to update.. there are 2 parts i dont know how to do and need help badly..

    1. if i enter like HSEROUT ["AG 0",13]
    it will return either ACK\r or NCK\r

    so i need the code to be like:
    Dim B1 as whatever
    test_ag:
    HSerOut ["ag 0",13]
    HSerIn [B1]
    If B1 == NCK\r Then GoTo test_ag
    'if the data received is NCK\r it will repeat the HSEROUT ["AG 0",13]
    'while if its ACK\r it will move to the next part of the code
    'if possible to detect ACK or NCK without the \r then it would be easier
    'like if B1 has NCK then goto test_ag

    2. if i enter HSEROUT ["TC",13]
    it will return NCK\r or ACK\r

    but if it is ACK\r it will have a 2nd line like
    ACK\r
    T mx my x1 y1 x2 y2 pixels confidence\r


    dont know how it would look like but
    Dim B1 as whatever
    Dim tc_mx As Byte
    Dim tc_my As Byte
    Dim tc_x1 As Byte
    Dim tc_y1 As Byte
    Dim tc_x2 As Byte
    Dim tc_y2 As Byte
    Dim tc_p0 As Byte
    Dim tc_c0 As Byte
    main:
    HSerOut ["TC",13]
    HSerIn [B1]
    If B1 == NCK\r Then GoTo main
    HSerIn [T,tc_mx,tc_my,tc_x1,tc_y1,tc_x2,tc_y2,tc_p0,tc_c0]
    'i need to save the data gathered to a variable like tc_mx etc.. etc..
    Last edited by siyete; 14th December 2012 at 18:03.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #9
    siyete
    Guest siyete's Avatar

    0 Not allowed!

    Default Re: help with hserout and hserin cmucam4

    i have been reading and would something like this work?..
    HSERIN 500, main,[WAIT("ACK\r"), SKIP 1, tc_mx, tc_my,SKIP 4, p0, c0, SKIP 2]

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

    Thread Information

    Users Browsing this Thread

    There are currently 1 users browsing this thread. (0 members and 1 guests)

       

    Similar Threads

    1. Hserout/ hserin issues
      By Mr Anderson in forum Proton Plus Compiler v3
      Replies: 17
      Last Post: 10th January 2017, 21:37
    2. Yet another HserIn, HserOut Question
      By jacobl in forum Labcenter Proteus VSM
      Replies: 2
      Last Post: 14th April 2008, 10:19
    3. HSERIN HSEROUT setting 2 stop bits
      By RemonDePemon in forum Proton Plus Compiler v3
      Replies: 4
      Last Post: 22nd August 2006, 16:32
    4. Hserin/Hserout
      By EnkiLondon in forum Proton Plus Compiler v3
      Replies: 5
      Last Post: 7th February 2005, 16:38
    5. HSerin/HSerout
      By EnkiLondon in forum Proton Plus Compiler v3
      Replies: 1
      Last Post: 5th February 2005, 14:24

    Members who have read this thread since 24th November 2019, 00:46 : 0

    Actions :  (Set Date)  (Clear Date)

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

    Tags for this Thread

    Posting Permissions

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