Bridgeville DE
Email: wayne@faircloth.org
Bridgeville DE
The original post for picture(s) done on 2013-02-08 by E.W. Faircloth can be found at
https://faircloth.org/blog1/?p=7337
Tags: I see it this way! Heritage Shores Bridgville De E.W. Faircloth photography photographer programming computer code computer programming Raspberry Pi electronics assembly language water droplet droplets operating system
After shooting the push button switch used in my Raspberry Pi milk droplet project, I decided it need something shown as a size reference. Why not a finger or thumb? Since you know how big the average thumb is, you get a feel for the size of the button. The problem with that decision was not that the idea was flawed, jut my thumb. I should have used a coin, hair curler, ruler, professional hand model, anything except my weather -beaten dry thumb. This man's thumb needs a cure. A "manicure" shall we say. My droplet operating system starts running as soon as the Pi has power. The program waits until this button is pressed before continuing on to pull up the camera mirror. It then waits for a drop to fall. Once it sees a drop passing it takes a picture and mirror returns to normal position. Programs starts sequence again waiting for a button press. What follows is the code if you like to get "geeky" every now and then:) -------------- --------------- ----------------- --------------- .section .init .globl _start _start: b main .section .text main: mov sp, #0x8000 @ GPIO #18 output infrared LED to illuminate passing object @ GPIO #23 input off switch to initiate sequence @ GPIO #25 output infrared LED used to trigger camera @ GPIO #27 input infrared LED which detects reflected infrared setGPIO18$: pinNum .req r0 pinFunc .req r1 mov pinNum, #18 mov pinFunc, #1 bl SetGpioFunction .unreq pinNum .unreq pinFunc setGPIO23$: pinNum .req r0 pinFunc .req r1 mov pinNum, #23 mov pinFunc, #0 bl SetGpioFunction .unreq pinNum .unreq pinFunc setGPIO27$: pinNum .req r0 pinFunc .req r1 mov pinNum, #27 mov pinFunc, #0 bl SetGpioFunction .unreq pinNum .unreq pinFunc bigPapa$: @ This small loop just effectively waits until pushbutton is pressed before continuing start$: mov r0, #23 bl GetGpio cmp r0, #0 bne next$ beq start$ next$: @ We raise the mirror on the Nikon D7000 bl triggerRemote @ Now we turn on LED on pin #18 and contantly read for a reflection detected @ with LED on pin # 27 inBit .req r5 sleep .req r4 mov r0, #18 mov r1, #1 bl SetGpio setup$: @ We will repeatedly check for input on the detector LED on pin #27 mov inBit, #0 mov sleep, #0x000010 loop$: mov r0, #27 bl GetGpio mov inBit, r0 cmp r0, #0 bne stop$ sub sleep, #1 cmp sleep, #0 bne loop$ @ turn off source LED to pulse trigger signal mov r0, #18 mov r1, #0 bl SetGpio mov r0, #0x000002 bl Pause @ now turn it back on mov r0, #18 mov r1, #1 bl SetGpio b setup$ @ We saw activity on ifrared detector or GPIO pin# 27, so turn of #18 and move on stop$: mov r0, #18 mov r1, #0 bl SetGpio .unreq inBit .unreq sleep @ Here, trip shutter on Nikon D7000 @ but first, a little pause as flash going off too soon ldr r0, =0x028C80 bl triggerRemote ldr r0, =0x00F000 bl Pause b bigPapa$ @ end of program. We never get to the following code, but just in case, we'll spin our wheels:) spin3$: b spin3$ @ Function and Subroutines needed in main section .globl Pause Pause: delay .req r2 mov delay, r0 push {lr} ldr r0,=0x20003000 ldrd r0, r1, [r0, #4] start .req r3 mov start, r0 loopIt$: ldr r0,=0x20003000 ldrd r0, r1, [r0, #4] elapsed .req r1 sub elapsed, r0, start cmp elapsed, delay .unreq elapsed bls loopIt$ .unreq delay .unreq start pop {pc} .globl GetGpioAddress GetGpioAddress: ldr r0, =0x20200000 mov pc, lr .globl SetGpioFunction SetGpioFunction: pinNum .req r0 pinFunc .req r1 cmp pinNum,#53 cmpls pinFunc,#7 movhi pc,lr push {lr} mov r2, pinNum .unreq pinNum pinNum .req r2 bl GetGpioAddress gpioAddr .req r0 functionLoops$: cmp pinNum, #9 subhi pinNum, #10 addhi gpioAddr, #4 bhi functionLoops$ add pinNum, pinNum, lsl #1 lsl pinFunc, pinNum mask .req r3 mov mask, #7 lsl mask, pinNum .unreq pinNum mvn mask, mask oldFunc .req r2 ldr oldFunc, [gpioAddr] and oldFunc, mask .unreq mask orr pinFunc, oldFunc .unreq oldFunc str pinFunc, [gpioAddr] .unreq pinFunc .unreq gpioAddr pop {pc} .globl SetGpio SetGpio: pinNum .req r0 pinVal .req r1 push {lr} push {r6} push {r7} mov r2, pinNum .unreq pinNum pinNum .req r2 ldr r0, =0x20200000 gpioAddr .req r0 pinBank .req r3 lsr pinBank, pinNum, #5 lsl pinBank, #2 add gpioAddr, pinBank .unreq pinBank and pinNum, #31 setBit .req r3 mov setBit, #1 lsl setBit, pinNum test$: mask2 .req r6 oldFunc .req r7 mov mask2, #1 lsl mask2, pinNum mvn mask2, mask2 teq pinVal,#0 ldreq oldFunc, [gpioAddr, #40] ldrne oldFunc, [gpioAddr, #28] and oldFunc, mask2 orr setBit, oldFunc endTest$: teq pinVal, #0 .unreq pinVal streq setBit, [gpioAddr, #40] strne setBit, [gpioAddr, #28] .unreq setBit .unreq gpioAddr .unreq pinNum pop {r7} pop {r6} pop {pc} .globl GetGpio GetGpio: pinNum .req r1 push {lr} mov pinNum, r0 ldr r0, =0x20200034 gpLev0 .req r0 data .req r2 mask .req r3 ldr data, [gpLev0] .unreq gpLev0 mov r0, #1 lsl r0, pinNum mov mask, r0 and data, mask mov r0, data .unreq pinNum .unreq data .unreq mask pop {pc} .globl OutInfra OutInfra: push {lr} mov r4, r0 pinNum .req r0 pinVal .req r1 mov pinNum, #25 mov pinVal, #1 bl SetGpio mov r0,r4 bl Pause mov pinNum, #25 mov pinVal, #0 bl SetGpio .unreq pinNum .unreq pinVal mov r0,r4 bl Pause pop {pc} .globl triggerRemote triggerRemote: push {lr} setGPIO25$: pinNum .req r0 pinFunc .req r1 mov pinNum, #25 mov pinFunc, #1 bl SetGpioFunction .unreq pinNum .unreq pinFunc ldr r6, =0x000002 tinyLoop$: pulse2000$: ldr r5, =0x00006C infra1$: mov r0, #0x000008 bl OutInfra sub r5, #1 cmp r5, #0 bne infra1$ pause27830$: ldr r0, =0x006CB6 bl Pause pulse390a$: ldr r5, =0x00000F infra2$: mov r0, #0x000008 bl OutInfra sub r5, #1 cmp r5, #0 bne infra2$ pause1580$: ldr r0, =0x00062C bl Pause pulse401b$: ldr r5, =0x000010 infra3$: mov r0, #0x000008 bl OutInfra sub r5, #1 cmp r5, #0 bne infra3$ pause3580$: ldr r0, =0x000DFC bl Pause pulse400c$: ldr r5, =0x00000F infra4$: mov r0, #0x000008 bl OutInfra sub r5, #1 cmp r5, #0 bne infra4$ pause63200$: ldr r0, =0x00F6E0 bl Pause sub r6, #1 cmp r6, #0 bne tinyLoop$ pop {pc}