Question about pointers to data addresses for Handheld Persistence of Vision in
![Zoot](https://forums.parallax.com/uploads/userpics/559/nW4UO23UEIWZ4.png)
I cranked out a handheld POV module in an Altoids tin Monday evening after seeing a photo at MakeZine.com. It works *really* well -- the kids *love* it and everybody wants to play with it.... initial test code and photos are at bottom. We're trying to figure out a way to take photos of it in "action".
In any case, the one thing that came up is using adddresses of data (DW instructions) as "computed" constants for other data statements. On my Stamp and Motorola projects I like to create a short table of data address pointers so that I can setup bitmaps, text strings, sound scores, whatever, of varying lengths and can change data at any time before compiling without rewriting pointers or having a lot of "if/thens" in my mainline code.
With that in mind, I couldn't figure out an "SX/Bish" way to do the following, and after screwing with it for a few minutes I decided to just to do in ASM -- but am still curious because wouldn't there be a way to do this in straight SX/B?
Quasi-related question because the power-on pushbutton for this project wound up on the wrong side (I built it so the label on the tin would be right side up , but then the button didn't fit with the lid, so you can't use your thumb) -- I don't think there is an analogue to REVERSE on the Stamp in SX/B? I'm thinking of emulating it with something like this...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
In any case, the one thing that came up is using adddresses of data (DW instructions) as "computed" constants for other data statements. On my Stamp and Motorola projects I like to create a short table of data address pointers so that I can setup bitmaps, text strings, sound scores, whatever, of varying lengths and can change data at any time before compiling without rewriting pointers or having a lot of "if/thens" in my mainline code.
With that in mind, I couldn't figure out an "SX/Bish" way to do the following, and after screwing with it for a few minutes I decided to just to do in ASM -- but am still curious because wouldn't there be a way to do this in straight SX/B?
Msg_00: DATA $01 DATA $02 DATA $FF Msg_01: DATA $01 DATA $02 DATA $FF ' etc ASM Msg_Pointers: DW @Msg_00&$FF DW @Msg_00>>8 DW @Msg_01&$FF DW @Msg_01>>8 DW @Msg_02&$FF DW @Msg_02>>8 DW @Msg_03&$FF DW @Msg_03>>8 ENDASM
Quasi-related question because the power-on pushbutton for this project wound up on the wrong side (I built it so the label on the tin would be right side up , but then the button didn't fit with the lid, so you can't use your thumb) -- I don't think there is an analogue to REVERSE on the Stamp in SX/B? I'm thinking of emulating it with something like this...
ASM BANK 0 ' ioByte is input... Reverse_Bits: CLR tmpW1_MSB ' will be output byte MOV tmpB1, #%0000_0001 ' input mask MOV tmpB2, #%1000_0000 ' output mask :loop MOV W, ioByte AND W, tmpB1 JZ :next OR tmpW1_MSB, tmpB2 :next CLC RL tmpB1 CLC RR tmpB2 TEST tmpB1 JNZ :loop :done MOV leds, tmpW1_MSB ENDASM
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
Comments
If you were wanting to pass a pin number, like PBASIC actually uses, this subroutine should do it. It's a bit verbose to keep things simple:
Post Edited (JonnyMac) : 1/10/2008 7:15:55 PM GMT
In PBASIC (and SX/B) REVERSE means to change a pin from an input to an output (or vis-versa). You are wanting a bit reversal. There isn't any command to do that in SX/B. You ASM is probably the way to go. If it was me I'd just do:
Out.0 = In.7
Out.1 = In.6
Out.2 = In.5
Great project, I've been wanting to do a POV project, but I've never gotten around to it.
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·
Bean -- I was going to try address labels as constants in the Beta, but I want to be able to post my code in completed projects
Jonny -- I realized I slightly mis-wrote -- I didn't mean the pin command REVERSE in Pbasic, I meant the operation REV, i.e.
x = REV x 8 ' reverse right-most 8 bits
(Writing in too many different languages these days -- sometimes I lapse into French, if you know what mean).
Regardless, I had written something like your routine, but as you prob. know, shifting a register by a variable amount generates a substantial number of clock cycles (it doesn't really matter for this app, but I've been trying to practice getting my code more compact). Your routine is cool though -- I will need to try something like that out possibly to make open-true serial TX/RX truly open true on the SX.
Generally, I wouldn't need to reverse 'em -- it's just a software hack to correct a technical error; would have been better to wire things properly
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
Your POV device looks neat. I would like to see it in action!
To photograph it you might try hot-wiring it to be on, then placing it on a phonograph (record player) turntable. If you can get it to stay put without flying off it might allow you to photograph it in motion. Set the camera focus when it is stationary. Then experiment with rotational speed settings and shutter delays. If your camera does not have adjustable shutter settings, choosing a low value ISO setting should keep the shutter open longer.
- Sparks
Nice project. Could you post a schematic?
Thanks,
MikeS
Schematic is almost trivial -- see the SX/B code for pin setups -- RC.0-RC.6 is 7 led anodes through 270ohm resistors. RA.0 goes to the RC circuit straight out of the Pbasic and SX/B manuals except I used a 100k pot and .01uf cap because that's what I had on hand.
Regulator is LM2940 with only a 22uf bypass cap on the output. .1uf cap on Vdd/Vss at the SX. 4-pin prog. header to OSC1/OSC2/Vdd/Vss. The button is SPST NO between the battery and the regulator, so push the button and it starts up. That's it.
I whipped up a .php web page today that builds SX/B or ASM data statements for bitmaps from a handy little series of "right-reading" check boxes. Makes it much faster to draw pictures and images.... visit it at the link below
1uffakind.com/robots/povBitMapBuilder.php
P.S. -- because I shouldn't claim inspiration for the nugget of the idea itself: blog.makezine.com/archive/altoids_and_tin_cases/. I put the LEDs on the short side rather than long because it fits better in your hand.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
Post Edited (Zoot) : 1/11/2008 12:03:01 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php