Page 1 of 1

Darken Ship - via ARMstamp

Posted: Tue Sep 10, 2019 1:38 am
by olzeke51
My man-cave has a 'submarine' motif. As a Navy Airdale that spent time on carriers,
you get used to setting different 'integrity conditions' - ie various 'General Quarters'.
One of them was to "Darken Ship" - meaning to go to RED lights for exterior openings.
I found the Proto-24 on sale from that fit the BasicStamp 24 pin layout.
The ARMstamp/LPC11U37 duplicated those pins as well as added another 2 rows of pins.
Below is a picture of my "Set Condition Zebra" - [as I remember it] RED night lights for
my man-cave. {the Internet says it was 'Dog Zebra'}.
The relay board has isolated inputs. Currently only 1 relay is used. I power it from a
USB power pak, but needed the 3.3v for the A/D inputs. I loaded up the power section
in case I wanted to go a different route - scrounged parts - not pretty.
FWIW - the relays pull 90ma each - so I wired the relay power to the external 5v line;
didn't want to run all that current through the ARMstamp.
I had to do a 14 hour test on the A/D readings - my computer screen / screensaver would
interfere with my initial 'trigger' levels !!!! It currently uses a software timing loop and
turns off at 0730. The 'toggle' forces it on and overides the trigger level until turn off time.
I modified the "MultiTask.bas" file to do the different functions - RTC / monitor toggle /
sensor input/ main control functions of the relay-time-trigger level...You gotta watch out
for the amount of time you assign to each function - it can appear to hang... I ended up
using the "jump out of loop via the force interrupt method" for each task!!!
"Done is better than ....." - there are a few more additions I want to do - time will tell
edit Oct 13, 2019 changed picture to final version
ZEBRA.jpg (148.37 KiB) Viewed 10169 times

Re: Darken Ship - via ARMstamp

Posted: Sun Oct 13, 2019 1:46 pm
by olzeke51
Okay folks,
First - I updated the above picture
I had a hard time trying to do a 'switch debounce' routine in the MultiTask method.
So I added (in parallel) a toggle switch, with a bonus beeper!!
will post program after a little clean up - my USART prints seem to be doubling up !!!!

Re: Darken Ship - via ARMstamp

Posted: Mon Oct 14, 2019 12:11 am
by basicchip
Buttons and switches bounce, and you have to take that into account. The easiest way is to look for a change in the button then ignore all other changes for a certain debounce time. That can vary a lot depending on the switch. I set up a simple test case on an ARMstamp with a push button between 2 pins. One pin driven low, the other pulled high by the internal resistor.

pb1.png (310.04 KiB) Viewed 10167 times

Then some scope pix show the push is pretty clean, but release is takes about 1/2 millisecond to settle

DS1Z_QuickPrint2.jpg (85.91 KiB) Viewed 10167 times
DS1Z_QuickPrint4.jpg (84.28 KiB) Viewed 10167 times
And here is a program to read the debounced state of the button and display that on the LED

Code: Select all

#define LED_PIN	1


IO(61)=0		' drive one side of the switch low

DEBOUNCED_PB = IN(45)		' set the default state

while 1
	nextIN = IN(45)
	if DEBOUNCED_PB <> nextIN then
		if MAYBE_BOUNCING = 0 then
			DEBOUNCED_PB = nextIN			' record the change
			DEBOUNCE_WAIT = TIMER + 1000	' wait 1 millisecond
			end if
		end if
	end if

Re: Darken Ship - via ARMstamp

Posted: Mon Oct 14, 2019 11:20 am
by olzeke51
Confession time - learning point
I tested Basicchip's routine in my MultiTask program - it worked like a charm
So what was wrong with my ideas ??? -- TIME - I was doing 20- 50 ms time loops!
Turns out that information from the Internet is for RELAY contact bounce !!!!
Have a good day, y'all