Shop OBEX P1 Docs P2 Docs Learn Events
H48C 3-Axis Accelerometer — Parallax Forums

H48C 3-Axis Accelerometer

RituRitu Posts: 39
edited 2006-07-07 13:49 in General Discussion
I am trying to program the Hitachi H48C_3-Axis with the Javelin, so I need to code in JAVA and the example given on the parallax website is in Basic, and I am having a hard time converting it to JAVA, is there anyone who would know how to have the accelerometer supply information to the Javelin in the programming language JAVA.
Thanks

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-06-30 08:51
    This should get you going.
    regards peter


    Post Edited (Peter Verkaik) : 6/30/2006 8:59:59 AM GMT
  • RituRitu Posts: 39
    edited 2006-06-30 19:20
    When I try to run this an error comes up, [noparse][[/noparse]Error JVM-0029} Method H84C_test::gForce contains out of range(Integer 55296) How could I fix this?
    Thanks
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-06-30 19:47
    Fixed version attached.

    regards peter
  • RituRitu Posts: 39
    edited 2006-06-30 20:04
    Thanks for all you help, sry but one more question. I seem to keep getting just 0 for the x, y, and z, even when I move it. What could be the problem there, bad wiring?
    Thanks again
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-06-30 20:18
    Try changing the CPU.POST_CLOCK_MSB into CPU.PRE_CLOCK_MSB and see
    what results that gives.
    regards peter
    ·
  • RituRitu Posts: 39
    edited 2006-06-30 20:40
    Hmm I am still getting just 0s, it might be my wiring but I am not sure.
    Thanks anyway
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-06-30 21:09
    Make sure both the H48C and the javelin share the same GND.
    regards peter
  • RituRitu Posts: 39
    edited 2006-07-05 14:29
    Hmmm, I have no idea why it still isnt working.
  • RituRitu Posts: 39
    edited 2006-07-06 17:29
    Anyone have any more suggestions, I dont think it is the wiring anymore, but something in the code.
    thanks
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-07-06 18:44
    Have you tried the basic code using a basic stamp?
    If not, it could be a bad chip. Do you have another chip?

    regards peter
  • RituRitu Posts: 39
    edited 2006-07-06 19:27
    I only have the javelin, and I have gotten other programs to work on it, so I am pretty sure the problem is in the code.
    Thanks
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-07-06 19:45
    Ritu,

    ·· Juts because the Javelin works fine doesn't mean something hasn't hapened to the Accelerometer, which is what Peter is suggesting.· By trying known code on a BASIC Stamp that would help narrow things down.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • RituRitu Posts: 39
    edited 2006-07-06 20:14
    K I tried it with the basic stamp and it works, so I am still confused about the java code.
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-07-06 20:20
    Ok, try the attached program.
    I added debug statements to print the refValue and adcValue for each reading.
    Let us know if these values are always -1 as they are preset,
    or if they have other values which indicates bits are read.
    Edit: and notice I used pins 13, 14 and 15.
    Change that to the pins you used in your wiring.

    regards peter

    Post Edited (Peter Verkaik) : 7/6/2006 8:24:25 PM GMT
  • RituRitu Posts: 39
    edited 2006-07-06 20:54
    Everything is zero, not -1
    thanks for all the help you have given me so far
  • RituRitu Posts: 39
    edited 2006-07-06 21:01
    Actually no, the refValue and the adcValue equal 1
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-07-06 21:18
    In the basic code there was no initialization for the clock and datapin.
    The documentation for the javelin shiftIn() and shiftOut() tells such
    initialization is required.
    Try the attached program. I added initialization code at the start of main().
    If results remain 0 or 1 for adc and ref, try other combinations for the
    clk and data init values.



    regards peter
  • RituRitu Posts: 39
    edited 2006-07-07 13:33
    Hmm still doesnt work, no matter what combination I did of true and falses.
    thanks
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-07-07 13:49
    And you are absolutely sure you didn't
    interchange the clock, data and cs pins?
    If the basic stamp worked, and you use the same
    socket for the javelin and the same pin definitions
    (so you know the wiring is correct), then it should work.

    Edit: unless one of the used javelin pins is defect.
    Have you tried pulsing a led on the clock, data and cs pin,
    and have tried to read a button on the data pin?
    Just to make sure your javelin pins·are ok.

    regards peter

    Post Edited (Peter Verkaik) : 7/7/2006 2:18:52 PM GMT
Sign In or Register to comment.