Power cycle pin(s) status? [SOLVED]

Hello,

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.

Thanks.

Oh dang… You should have placed a pull-up resistor :smiley:

Let me see if i can find some information about that…

It seems like they are in the high-Z input state during reset…

2 Likes

yeah, tell me about it.

When you have a week to make a 1100 pound sculpture move, things get forgotten.

I’m going to try to do a retrofit after museum hours this weekend.

The Spark Core has been a lifesaver though.

3 Likes

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?

1 Like

umm…so what’s a high-Z input state?

what does this mean for me. i.e. if I add a pull-up on my retrofit this weekend will I hopefully get rid of the relay actuating when I load new code?

will an internal pullup work for this? is it maintained through firmware reload? (I would guess not)

I guess not as well since the internal pull up will not be enabled during reset.

Having an external pull up will always ensure it’s HIGH during non operating conditions :smiley:

2 Likes

High-Z describes a state in which a point in a circuit allows a relatively small amount of current passing through.

As internal pull ups/downs are only effective as soon as they got set during runtime, you won’t get around your analog pull-up/down resistor.

Though, as soon as you installed them, the small current should get ‘eaten’ by them :smile_cat:

2 Likes

Thanks both for responses. Mark as solved if you’d like. I think I know what I need to do!

1 Like

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.

1 Like

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.

1 Like

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. :slight_smile:

1 Like

Kenneth,

It is interesting that D2 has the issue, and A2 does not. I wish I could understand why that is.

Ah maybe I can investigate further when I have access to an oscilloscope next monday.

Will note this down and test. :slight_smile: it’s probably some characteristics difference in the pins and the restart behavior. How did you managed to figure this btw?

That’s good information for me to dig further.

1 Like

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.).

1 Like