Subject:
|
Re: Vector2x SPI interrupt driven code
|
Newsgroups:
|
lugnet.robotics.handyboard
|
Date:
|
Wed, 5 Mar 1997 04:53:52 GMT
|
Original-From:
|
Adam <adam@ring.zenoxSPAMCAKE.com>
|
Viewed:
|
2212 times
|
| |
| |
Not sure who you are? tomb?
Anyways, I noticed mention of a compass.... I once looked into the
idea of using a flux gate compass to obtain heading info. After finding
that the inexpensive (affordable) models would only obtain info at a
resolution of 45 degrees, I gave up on it. I read all of the mail on
the HB list, but I don't recall transmisions on the compass idea.
Maybe I should ask what the Vector2x is???
Please feed me info on this compass stuff. I'm extremely interested.
Thanks.
On Tue, 4 Mar 1997 tomb@netperceptions.com wrote:
>
> Well it works. A couple people have asked for it. Turns out the
> stupid V2X docs are wrong again! Like the product, but bad docs will
> kill it!
>
> Even if you don't have a V2X, I have seen enough traffic asking about
> using the SPI for things on the HB, and this proves it can be done.
>
> The EOC level is wrong, it is HI not LO like the timing diagrams
> show. I kinda saw it on the scope, but I ignored it, figuring I was
> doing something wrong (the docs are right aren't they :-P). Tonight,
> I decided not to ignore it, and I built an inverter using a NPN
> transistor, on the EOC output.
>
> I noticed also, that I changed the CPOL, and it works, I didn't fix
> this to match the docs, I may, if I notice any trouble. It could be
> that the docs are wrong there also (surprise surprise).
>
> It outputs the heading directly, I didn't actually write a cute C
> routine, I should have, but something like:
>
> main()
> {
> comp_init(1);
> for(;;)
> printf("heading %d\n", head_word);
> }
>
> should give you a really nice compass. Notice that the interrupt
> routine double buffers things, so this *SHOULD* provide accurate
> results most of the time.
>
> The heading does 0-359 and is pretty darn stable (I did a lot of !! on
> the command line of IC).
>
> I'll clean it up, I think I have to steal one of the motor control
> lines (like the poloroid thing did), but I think I'll steal motor 3 or
> 4 reverse, that will allow control of the compass P/C line. This will
> still motor 3 forward with compass, and only a minor problem with
> motor 3 reverse (maybe).
>
> To use this, you will have to run a jumper from ground (tab of
> regulator works great), to the P/C line of the compass *AFTER*
> powering things up. P/C has to be high at reset or powerup, float
> works, otherwise you get lockups.
>
> Fred, after I clean this up, and put some more stuff with it, you want
> to package it up?
>
> *
> * icb file: "compspi.asm"
> *
> * Tom Brusehaver 02/16/96 working 03/04/97
> *
> * Run the V2X in master mode, this keeps collecting the "current"
> * heading, resulting in having almost real-time, constant input from
> * the compass.
> *
> * Pin Connections
> * V2X HC11
> * pin desc pin desc Notes
> * 13 EOC invert! SS Sync bit counters between master and slave
> * 2 SDO MOSI Data coming in
> * 3 SDI MISO Data going out
> * 1 SCLK CLK Bit clock
> * 5 P/C gnd after startup
> *
> * NOTE: I had to invert the EOC pin. I used a NPN transistor, Base
> * connected to EOC pin, Collector connected to SS(HC11), and
> * pulled up with a 390 ohm resistor. Emitter connected to ground.
> * pretty simple really.
> *
>
>
> #include <6811regs.asm>
>
> ORG MAIN_START
>
> subroutine_initialize_module:
> #include <ldxibase.asm>
> * X now has base pointer to interrupt vectors
>
> * get current vector; poke such that when we finish we go there
> LDD SPIINT,X ; SPI Interrupt
> STD interrupt_code_exit+1 ; fix $0000 at end.
>
> * install ourself as a new vector
> LDD #interrupt_code_start
> STD SPIINT,X
> rts
>
> * variables
>
> variable_temp_word: FDB 0 ; read each byte and store here
> variable_head_word: FDB 0 ; after reading 2 bytes move them here
> variable_byte_count: FDB 0 ; read first or second byte?
> variable_debug_vec: FDB 0 ; --for now--
>
> subroutine_comp_init:
> * put SPI in slave mode
> LDAA #%00000100
> STAA DDRD
> LDAA SPDR ; read it
> * LDAA #$CC ; SPIE, SPE !DWOM, !MSTR, CPOL, CPHA, E/2
> LDAA #$C8 ; SPIE, SPE !DWOM, !MSTR, !CPOL, CPHA, E/2
> STAA SPCR
>
> LDAA SPSR ; clear SPIF
> LDAA SPDR ;
>
> ldaa #$0f
> sta variable_debug_vec ; --fornow--debug
>
> CLI
> RTS
>
> * interrupt program begins here
> interrupt_code_start:
> ldaa #$4f
> sta variable_debug_vec ; --fornow--debug
>
> LDAA SPDR ; get our byte
> LDAB variable_byte_count
> CMPB #0 ; wouldn't have to
> BNE byte2_output
> STAA variable_temp_word ; just save the current byte away
> INCB ; increment byte count
> STAB variable_byte_count
> BRA end_out
> byte2_output:
> STAA variable_temp_word+1 ; save the current byte, and move to
> STAA variable_head_word+1
> LDAA variable_temp_word ; valid data holding location
> STAA variable_head_word ;
> LDAB #$0
> STAB variable_byte_count
> end_out:
> LDAA SPSR ; clear SPIF (maybe?)
> LDAA SPDR ;
>
> CLI
>
> * end of interrupt program.
> interrupt_code_exit:
> JMP $0000 ; this gets fixed above
>
>
>
>
|
|
Message has 2 Replies: | | Re: Vector2x SPI interrupt driven code
|
| (...) Tom Brusehaver, formerly tgb@bnr.com. (...) 45degrees sounds more like a dinsmore device (compass mechanism, and 4 hall effect transistors). I have them, and they are useful for some things. (...) The vector2x is a compass made by Precision (...) (28 years ago, 5-Mar-97, to lugnet.robotics.handyboard)
| | | Re: Vector2x SPI interrupt driven code
|
| Hey Tom How close is too close? How far away do you have it? Any problems with just pieces of metal, like casters or maybe a gel cel holder. (hint hint) Sounds like a pretty nifty little device. Just wondering if my setup would allow me to use it (...) (28 years ago, 5-Mar-97, to lugnet.robotics.handyboard)
|
Message is in Reply To:
| | Vector2x SPI interrupt driven code
|
| Well it works. A couple people have asked for it. Turns out the stupid V2X docs are wrong again! Like the product, but bad docs will kill it! Even if you don't have a V2X, I have seen enough traffic asking about using the SPI for things on the HB, (...) (28 years ago, 5-Mar-97, to lugnet.robotics.handyboard)
|
6 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|