It appears that during a power cycle pin D2 goes low for about 3 seconds. This is pretty unfortunate for me because D2 currently is in control of a relay…and the piece is about 30 foot high in a museum right now (long story…maybe I’ll document what sort of fun I’m using the spark for.)
Is there any documentation of pin behavior over reboots? I did a quick search and couldn’t find any.
This is quite common with microcontroller design and the Spark Core should have this in the documentation for those who don’t want to or don’t know where to look in the processor documentation.
Pull-up or pull-down is needed on any design where you don’t know the state of the processor pins during power up where they are generally in the high-z or input state. Most microcontrollers default to the input state once power up is complete so you still need a pull-up or pull-down to put your output into a known state. The issue is compounded with the Spark Core because there is Spark code run before your code so we need to know what state each pin is in after power up and before our code runs?
It will work as long the D2 line is not in the driven state and is actually in the input state. If it is actually being driven LOW then a pull-up will not have any effect.
so interesting enough, the pull-up did NOT work. I connected various values from 1K to 8.4K of resistance from the pin that I’m sinking to ensure that it was pulled high through the reprogram/reboot. No dice.
I ended up using a NPN transistor and reversing the logic to HIGH = on.
Please be aware that reprogramming is a test case you must consider before deploying in remote locations.
It’s a good lesson indeed. I had a remote core which was still within reach and could perform a reset so it wasn’t so painful when it went offline after calling a function.
Ah maybe I can investigate further when I have access to an oscilloscope next monday.
Will note this down and test. it’s probably some characteristics difference in the pins and the restart behavior. How did you managed to figure this btw?
so I have two relays (in a module… This one ) connected to A2 and D2 on the Spark Core. I didn’t test well, and then as I’m sending firmware to the Spark Core, during the reboot D2 gets grounded, causing the relay to activate.
If A2 actuated the same way, it would lock the linear actuator and it wouldn’t move, but because D2 grounds and A2 does not, it causes the actuator to move. Which is a bit disconcerting the first time an 1100 pound sculpture moves without your input (actually more like every time it moves when you don’t want it to its disconcerting.).