Wish Disable pins

Beja

Expert
Licensed User
Longtime User
I have a wish that all inputs and outputs be in high impedance state (electronically disconnected) before a new program replaces an old one and properly starts and stable.
At this time I see a quick on-offs or short spikes at the pins.
 
Last edited:

Cableguy

Expert
Licensed User
Longtime User
It shouldn't be difficult to add such code to your program.

I think that it is better than adding it to all programs.
I thought of exactly that! not every circuit will need a "circuit safe" compile mode, and such a snippet shouldn't be to hard to code
 

Beja

Expert
Licensed User
Longtime User
I thought of exactly that! not every circuit will need a "circuit safe" compile mode, and such a snippet shouldn't be to hard to code

The snippet is not hard... something like you define an array with the number of pins then iterate through them turning all LEDs off.
But I thought this can be built into B4R core functions instead of we do it every time.. something like a new class called AllPins, then you
just call it with AllPins.TurnOff, or AllPins.TurnOn.. Lazy, huh!
 

JordiCP

Expert
Licensed User
Longtime User
Don't know which is the hardware/software sequence by which a new program is loaded in Arduinos, so perhaps this does not help

But most (if not all) microcontrollers boot with all of its configurable pins as inputs or disconnected, so resetting and booting the micro into bootloader mode before the program runs should be safe to upload a new code.

Hope it makes sense
 

Beja

Expert
Licensed User
Longtime User
since it's a hardware issue then there's no s/w solution.. a workaround could be to put all the pins to zero at start.. pseudo-code would be something like this:

If First Time then
Turn all pins off
end if

The is important because sometimes you want to set the controller in waiting state from the very beginning. means it only responds to sensor inputs, so if an output is on while you want it to be on only after the presence of a sensor signal, then either you don't use that pin or make sure it's off from the beginning.
 

Cableguy

Expert
Licensed User
Longtime User
that seems to be a "false" question because when the duino reboots or restarts, all pins are in an high-impedance mode (R3), except for pin 13 to which the on-board LED is connected... Its only upon program run that the referenced pins change their state...
The only concern I have at this point is that we dont have a real debug mode in B4R so we cannot stop the running program from the IDE..
And when we compile a new program, there is a brief run of the "older" program before the new one takes over
 

Beja

Expert
Licensed User
Longtime User
that seems to be a "false" question because when the duino reboots or restarts, all pins are in an high-impedance mode (R3), except for pin 13 to which the on-board LED is connected... Its only upon program run that the referenced pins change their state...
The only concern I have at this point is that we dont have a real debug mode in B4R so we cannot stop the running program from the IDE..
And when we compile a new program, there is a brief run of the "older" program before the new one takes over

That's exactly what I am talking about cableguy.. power failures happen often.. and when it comes back pin13 will not be in high impedance state, but will be briefly in high state until the program boots.. this brief high could cause a disaster in critical applications if the program used it in a specific way.. Anyways, if I am to design a system around Arduino then I will add RC circuit to short pin 13 to ground for a second or so until it's turned to the sate the program decides.
 
Top