Digital I/Os during power up
#1
Posted 29 May 2011 - 08:37 PM
#2
Posted 30 May 2011 - 05:42 AM
Hi,
My problem is that when I power the Netduino board, the relays get triggered immediately.
It seems that as soon as the Netduino board is powered, the connected Digital I/Os signal a true.
I'm running into this now with a motor controller controlled via PWM. As soon as I turn the Netduino on, the motors start spinning full-speed. It takes a few seconds for them to stop. Not great for a robot
Chris, is there a firmware config option or something to handle this? It happens before our code gets to run.
Pete
I work for Microsoft. Opinions expressed here are my own and do not necessarily reflect those of my employer,our partners or customers.
#3
Posted 30 May 2011 - 05:55 AM
You'd need to connect so called 'pull-down' resistor between the Netduino pin and ground, which holds the signal at logic zero during the startup. 10 kΩ works fine.My problem is that when I power the Netduino board, the relays get triggered immediately.
#4
Posted 30 May 2011 - 06:26 AM
You'd need to connect so called 'pull-down' resistor between the Netduino pin and ground, which holds the signal at logic zero during the startup. 10 kΩ works fine.
Thanks Chris. Looks like I'm going to have to put a small board on this guy no matter what
Pete
I work for Microsoft. Opinions expressed here are my own and do not necessarily reflect those of my employer,our partners or customers.
#5
Posted 30 May 2011 - 06:56 AM
#6
Posted 30 May 2011 - 07:49 AM
#7
Posted 30 May 2011 - 07:51 AM
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#8
Posted 30 May 2011 - 08:50 AM
Unfortunately, it cannot be done in software - as Mario pointed out, the I/O pins are high (configured as inputs) at reset and there will be always some delay before the software starts running. For example, it takes some time for the oscillator to stabilize, hardware modules need to be initialized etc. Additionally, in case of Netduino there is (2s ?) timeout in the bootloader after which it hands over the control to TinyCLR that actually runs the user application, where you can manipulate I/O pin state.As a possible solution, what do you think of a software solution: the cpu power change event is trapped and the IOs are set to off. Possible?
It is possible to modify the firmware to change pin state during the startup (i.e. set it to logic low), but as Mario already mentioned, there are reasons why not to do that and there will still be a significant delay before such code is run on .NET Micro Framework device (even on 'bare-metal' microcontroller we are talking about hundreds of microseconds initialization time, which is probably long enough for the external board to perform some action, like switching the relay/motor on). The pull-down (resp. pull-up) resistor is the easiest solution - they are used pretty often, so grab a dozen of these (10kΩ, 4k7), they will surely come in handy for other projects...
#9
Posted 30 May 2011 - 11:55 AM
#10
Posted 30 May 2011 - 02:30 PM
http://cgi.ebay.com/...V-/400209006822
What do you think?
Was it a bad purchase?
Thank you all for the info. Really appreciate it.
#11
Posted 30 May 2011 - 02:42 PM
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#12
Posted 30 May 2011 - 03:02 PM
#13
Posted 31 May 2011 - 03:38 AM
I work for Microsoft. Opinions expressed here are my own and do not necessarily reflect those of my employer,our partners or customers.
#14
Posted 31 May 2011 - 04:16 AM
I didn't find anything about the value of the internal MCU pull-ups. I guess their value should be around 10-20K Ohms.
To solve a similar problem I'd see three possibilities:
- (the WORST) add a "stronger" pull-down to any output, so that the internal pull-up won't be enough to feed a decent voltage for the transistor. Let's say a 1K Ohms pull-down, it should keep the power-up output voltage below 0.5V, i.e. less that the transistor threshold (over 1.5V). IMHO this is the worst solution, because makes flowing a lot of useless current (from +3.3V to ground).
- Add an inverter (e.g. 74HC04) to any Netduino output, then drive the transistor using a negative logic.
- The most elegant solution, from my viewpoint, is to use one or two shift registers (74HC595) as Stefan does. It has no problem at power-up, it saves a lot of I/Os and it is much faster than a direct I/O driving.
I didn't check, but Arduino could have two advantages over the Netduino.
Firstly, the Arduino MCU could not have the same behavior of the Netduino's one. Maybe on power-up there's no pull-up enabled, so the problem is completely inexistent.
Secondly, the Arduino firmware could take a lot less than the Netduino's. So, even having the same behavior, the transition time would be too short for making any relay active (e.g. some millisecs).
Cheers
#15
Posted 31 May 2011 - 04:50 AM
The Arduino Uno uses an ATMEGA328 (8-bit AVR) microcontroller. This microcontroller tri-states all GPIOs at startup, with no internal pull-ups. [Tri-state/Hi-Z = "open circuit, disconnected pin"]As I understand it, the Arduino doesn't run into this with these motor controllers. Any idea what about the Arduino makes that possible?
http://www.atmel.com...nts/doc8161.pdf
The Netduino uses a SAM7X512 (32-bit ARM) microcontroller. This microcontroller configures all GPIOs as inputs with pull-ups enabled at startup. These weak pull-ups may register as "positive voltage" to external components.Section 13.2.1 Configuring the Pin (p.76)
"The port pins are tri-stated when reset condition becomes active, even if no clocks are running."
Section 13.2.6 (p.80)
"In this case, the pull-up will be disabled during reset."
http://www.atmel.com...nts/doc6120.pdf
We could set the PIO_PUDR registers to 0x00000000 immediately at boot, to disable all pull-up resistors. But that would still turn them on very briefly--and would afterwards leave the inputs floating. We could also set the PIO_MDER registers to 0xFFFFFFFF to enable all pins in multi-drive mode (open drain)...but the pullups would still be enabled during reset.Section 27.4.1 Pull-up Resistor Control (p.233)
"After reset, all of the pull-ups are enabled"
Table 27-2 PIO Register Mapping (p.238)
Output Status Register at Reset = 0x00000000 (all pins in pure input mode)
Chris
#16
Posted 31 May 2011 - 05:01 AM
The SAM7X datasheet (p.610) lists the pull-up resistor current values as:I didn't find anything about the value of the internal MCU pull-ups. I guess their value should be around 10-20K Ohms.
Netduino analog pins 0-3: 20.6mA typical
Netduino--all other pins: 321mA typical
If Ohm's law serves me right (R = V/I in this case), this gives us rough pullup resistor values of:
Netduino analog pins 0-3: ~16020 ohms
Netduino--all other pins: ~1025 ohms
If you want to use a pull-down resistor to offset the internal pull-ups during reset and with a maximum current of 600mA on the inputs...I'd use a pull-down resistor of 500 ohm or less on the digital pins (and pins A4/A5) and a pull-down resistor of 5 kilohm or less on the analog pins A0-A3.
Chris
#17
Posted 31 May 2011 - 05:29 AM
Ya...I'd use a pull-down resistor of 500 ohm or less on the digital pins (and pins A4/A5) and a pull-down resistor of 5 kilohm or less on the analog pins A0-A3.
I confirm the pull-down solution is even worser than the worst!
Thank you, Chris.
Cheers
EDIT: I checked the specs because your values sound too odds.
The currents are in MICRO-amperès, not milliamps.
The pullup resistors are scaled by 10: about 160K and about 10K.
I think would be an hard task make flowing 600mA through an I/O without blowing it!
Ciao
#18
Posted 31 May 2011 - 12:15 PM
With 8mA per pin (excluding 16mA for 2,3,7) this is pretty close to the limit.
To solve this problem I used different approach (which for me is more flexible):
I used one of the Netduino Digital I/O to control a wee transistor-relay switch but used PNP transistor so on start up relay is off.
Then later in code simply setting the port down opens the transistor and relay goes on. Rest of the schematics gets power from the relay's controlled circuit.
This is flexible also gives me power at any time to switch ON/OFF the power to the circuitry from code.
This is next thing I am writing down into this tutorial. I also will describe using thyristor instead of relay and also possibility to use single power PNP transistor for cases
you power schematics from Netduino's +5V. In this case you should not consume more than 200mA which makes any >1W transistor suitable.
Later in this tutorial I also will describe how one can use FET/MOSFET, DIOD or Transistor NAND as well as NAND TTL IC to achieve same.
#19
Posted 31 May 2011 - 12:33 PM
I agree at all for the waste, especially where is the need of battery-powered devices.I have tried the pull-down resistors but didn't like the idea of draining so much energy. Using 500Oms resistor will drain 6.6mA per pin!
With 8mA per pin (excluding 16mA for 2,3,7) this is pretty close to the limit.
I agree with you again, but:I used one of the Netduino Digital I/O to control a wee transistor-relay switch but used PNP transistor so on start up relay is off.
- most of the readers cannot figure out your idea, so attach any picture describing the circuit (without any formula);
- for a single output, I would have done as you say, but for 16 relays maybe is compact, simpler and cheaper having a couple of ICs (e.g. 74HC244).
Thank you very much for your post.
Cheers
#20
Posted 31 May 2011 - 12:41 PM
I agree with you again, but:
- most of the readers cannot figure out your idea, so attach any picture describing the circuit (without any formula);
I mentioned that I am currently writing exactly this part of the tutorial. I tend to release chapter per week so expect this to be public next week
Meanwhile, following you advice, I will post an schematics image later today so people can get impression.
I am not understanding exactly what you mean? I am using this schema to control the general power flow to the rest of the schematics.for a single output, I would have done as you say, but for 16 relays maybe is compact, simpler and cheaper having a couple of ICs (e.g. 74HC244).
This could be 1 as well as 16 other relays schemes. May be picture will clarify what I am doing
Schematics attached.
From the relay controlled circuit you can power as many other LED switches or any other devices.
Keep in mind 800mA total limit that you can get from Netduino's 5VDC. In fact I use a resettable fuse, connected between +5V pin and relay switch, to prevent any damage to N+). If you need more current use external power device. If you need more voltage you have to recalculate R1 and R2 (calculations example will be provided in the tutorial). As I mentioned before there are other possibilities to make this schema more elegant with replacing the relay or using different switching techniques. Again, those will be illustrated in the tutorial.
To switch "power on" just declare
var powerSwitch = new OutputPort(Pins.GPIO_PIN_D13, false);
Then you can:
powerSwitch.Write(true) // OFF
powerSwitch.Write(false) // ON
You may think you can use PNP transistor to power the LED directly, That's true. Only "uncomfortable" thing is you have to set the port to false to turn the LED On. This is small issue but for somebody that wants to keep things straight this could be annoying, so I came with this solution. I also like it as it adds a bit more control.
Attached Files
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users