SX/B and the H48C Tri-Axis Accelerometer

infoseeker34infoseeker34 Posts: 3
edited 2010-11-14 - 06:46:50 in Microcontrollers
Hello!

Question: I am attempting·to aquire data from·an H48C using the SX28AC/DP and coding in SX/B.· This is my first time using the controller/language and I'm having a bit of trouble.· I've been using the sample code given on the site using BS2, but have had to modify it some...

I call to subroutine "get_h48c" from my main statement.· Subroutine "get_h48c" looks like this:

Get_H48C:
···RB = 0
······················· CS = 0
······················· SHIFTOUT········ DIO, CLK, MSBFIRST, VRef\3
·· ···INPUT RB.1··
······················· SHIFTIN········· DIO, CLK, MSBPOST, rvCount\8
······················· SHIFTIN········· DIO, CLK, MSBPOST, rvCount2\5
······················· CS = 1
·······················
···PAUSE··········· 1
··
·· ···RB = 0
······················· CS = 0
······················· SHIFTOUT········ DIO, CLK, MSBFIRST, axis\3
· ···INPUT RB.1
······················· SHIFTIN········· DIO, CLK, MSBPOST, axCount\8
······················· SHIFTIN········· DIO, CLK, MSBPOST, axCount2\5
······················· CS = 1
RETURN

I've verified with my scope that there is data flying around everywhere on my DIO line, but variables rvCount, rvCount2, axCount, axCount2 all stay zero.· I'm using SEROUT to send the data to an XBee, and I've verified that that operation is working correctly.· It seems that I'm not accessing the information correctly.

So here's the question...

Does anyone see anything obviously wrong with what I'm doing here?

any help would be greatly appreciated.

Comments

  • BeanBean Posts: 8,042
    edited 2006-10-24 - 22:46:40
    Can you post your complete program ?
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com

    "People who are willing to trade their freedom for·security deserve neither and will lose both." Benjamin Franklin
    ·
  • infoseeker34infoseeker34 Posts: 3
    edited 2006-10-25 - 13:40:53
    DEVICE SX28, OSCHS3, TURBO, STACKX, OPTIONX
    FREQ 50000000
    PROGRAM START_POINT
    '==============================================================================================================
    'Constants
    '==============================================================================================================
    XAxis CON 0
    YAxis CON 1
    ZAxis CON 2
    VRef CON 3
    Cnt2Mv CON $CE4C
    Gfcnv CON $3852
    '==============================================================================================================
    'Variables
    '==============================================================================================================
    axis VAR BYTE
    rvCount VAR BYTE
    rvCount2 VAR BYTE
    axCount VAR BYTE
    axCount2 VAR BYTE
    CLK VAR RB.0
    DIO VAR RB.1
    CS VAR RB.2
    '=============================================================================================================
    'SUBROUTINES
    '============================================================================================================
    Get_H48C:
    RB = 0
    CS = 0
    SHIFTOUT DIO, CLK, MSBFIRST, VRef\3
    INPUT RB.1
    SHIFTIN DIO, CLK, MSBPOST, rvCount\8
    SHIFTIN DIO, CLK, MSBPOST, rvCount2\5
    CS = 1

    PAUSE 1

    RB = 0
    CS = 0
    SHIFTOUT DIO, CLK, MSBFIRST, axis\3
    INPUT RB.1
    SHIFTIN DIO, CLK, MSBPOST, axCount\8
    SHIFTIN DIO, CLK, MSBPOST, axCount2\5
    CS = 1
    RETURN
    '=============================================================================================================

    '=============================================================================================================
    'Main
    '=============================================================================================================
    START_POINT:
    FOR axis = XAxis TO Zaxis
    GOSUB Get_H48C
    OUTPUT RC.2
    SEROUT RC.2, T9600, rvCount

    NEXT
    GOTO START_POINT


    E.O.P....

    So all I'm trying to do is gather the info and send it. Actually at this point I'm just checking to see if I have successfully placed the info into a variable. I haven't even begun to try and format the data.
  • BeanBean Posts: 8,042
    edited 2006-10-25 - 13:48:50
    Looks like you are missing the %11\2 before the Vref\3 and the axis\3.

    SHIFTOUT DIO, CLK, MSBFIRST, %11\2
    SHIFTOUT DIO, CLK, MSBFIRST, VRef\3



    SHIFTOUT DIO, CLK, MSBFIRST, %11\2
    SHIFTOUT DIO, CLK, MSBFIRST, axis\3

    See if that works...

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com

    "People who are willing to trade their freedom for·security deserve neither and will lose both." Benjamin Franklin
    ·
  • infoseeker34infoseeker34 Posts: 3
    edited 2006-10-25 - 18:44:43
    Awsome! Thanks for the second pair of eyes! I can't believe I overlooked that.

    While I have you on the line... you wouldn't happen to know if there is any source code floating about for turning the input from this operation into ascii for the purpose of serial transmission?

    I'm fairly certain I can accomplish this on my own, but I never want to work harder than completely neccessary. Plus it's always nice to have a reference even if it doesn't suit my app.

    - N
  • 01442240144224 Posts: 2
    edited 2010-11-13 - 10:19:40
    Bean wrote: »
    Looks like you are missing the %11\2 before the Vref\3 and the axis\3.

    SHIFTOUT DIO, CLK, MSBFIRST, %11\2
    SHIFTOUT DIO, CLK, MSBFIRST, VRef\3



    SHIFTOUT DIO, CLK, MSBFIRST, %11\2
    SHIFTOUT DIO, CLK, MSBFIRST, axis\3

    See if that works...

    Bean.

    Trying to do this in C using the pic16f887 but can't get it to work anyone got any ideas?
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2010-11-14 - 06:46:50
    Absolutely wonderful. Coincidentally, I just built a little box to emulate a Wii device and was pondering what to do about code. It sends everything to a 433Mhz transmitter to interface with whatever the receiver is connected to via RS232 port.
    Hwang Xian Shen, Puddleby-on-the-Marsh.
    All things considered, I can live and thrive without Microsoft products. LINUX is just fine.
Sign In or Register to comment.