PICmicro & I/O Pin
PICmicro & I/O Pin
(OP)
Hi all,
I have used a PICmicro (as mentioned earlier in the thread - wanted to concentrate on a particular aspect)
I have used the PICmicro I/O to source the power to several components in the circuit. I know that each I/O pin of the PIC16C62B is able to source 25 mA - but if i am powering the PICmicro with a 5V supply (Vdd) - what is the output voltage on each I/O? Is it (according to the PIC16CXX family reference) Vdd-0.7??? (Output Voltage High on I/O)
If so, does that mean each I/O pin can supply a minimum of 4.3V??? Also, what is the tolerance on the I/O pin?
I am almost now about to do an error calculation on the whole circuit. I am sure at the time I measured the voltage at the I/O pin - but I have no record of this!!!
Any help on this very much appreciated. Thanks once again to all who replied to the previous thread!
Usman
Medical Physicist
I have used a PICmicro (as mentioned earlier in the thread - wanted to concentrate on a particular aspect)
I have used the PICmicro I/O to source the power to several components in the circuit. I know that each I/O pin of the PIC16C62B is able to source 25 mA - but if i am powering the PICmicro with a 5V supply (Vdd) - what is the output voltage on each I/O? Is it (according to the PIC16CXX family reference) Vdd-0.7??? (Output Voltage High on I/O)
If so, does that mean each I/O pin can supply a minimum of 4.3V??? Also, what is the tolerance on the I/O pin?
I am almost now about to do an error calculation on the whole circuit. I am sure at the time I measured the voltage at the I/O pin - but I have no record of this!!!
Any help on this very much appreciated. Thanks once again to all who replied to the previous thread!
Usman
Medical Physicist





RE: PICmicro & I/O Pin
But do remember!!! That the total drive to the PIC is supplied only thru one or two pins and that there are very small wires going to it/them. We are talking 18um or wires that are 0.0007 inches in diameter. When you start drawing 25 to 100mA thru this your voltage will drop.
Your scheme while clever is treading on thin ice. The numbers you are looking for aren't spec'd because they are so nebulous. The spec is of typically 3mA >-> Vdd - 0.7. NOT 25mA! Your scheme may still work if you are running things that work down to 3V. But you will experience voltages all over the place depending on other pin loading and processor workload.
RE: PICmicro & I/O Pin
is that the max 25mA source current is effectively against an output short, e.g., when the output is initially low and is driven high, you will transiently see 25mA, but the steady-state current output is as indicated by itsmoked.
TTFN
RE: PICmicro & I/O Pin
RE: PICmicro & I/O Pin
My circuit draws an overall current from the PICmicro of 20 mA (measured). This excludes the PICmicro.
Comments on Thread
Section 30 of the PICmicro Reference states that the Output Voltage will not be reached if the I/O pin is shorted. I have not shorted any I/O pins.
Breakdown of Current Measurement
The S250 strain gauge (1.68mA), LTC1298(0.29 mA), POT (5.43mA) and the classic IA (using three op-amps of the quad LT1014 (1.39mA)) are powered by a single I/O pin of the PICmicro (consuming no more than 10 mA in total). The MAX232 Line Driver is powered by another I/O pin of the PICmicro (consuming no more than 9 mA).
Summary
The current consumed by each of the only two I/O pin used to power the circuit is 10mA i.e. 20 mA in total. Plus a third Pin to power an LED (~10mA). All components mentioned in 'Breakdown' section required a supply voltage of 5V.
Datasheets
According to the MICROCHIP Midrange Reference (Section 30, page 30-11: Electrical Spec), the Output High Voltage (Voh) is Vdd-0.7. This is under the conditions of sourcing 3mA using a supply of 4.5V (Vdd). Now, why would Microchip say each I/O pin can source 25mA?????? So, the Output High Voltage is a minimum of 4.3V. MICROCHIP state its a minimum voltage by the way. Does that mean it can supply 5V??? Or is that when the current consumption is lowered???
Also, why would each Port supply 200 mA in total?? This can't just be a transient? can it? There are 8 I/O Pins in Port B (im using three pins). Divide 200/8 gives 25mA for each I/O pin. So each must be capable of supply 25mA but the test condition only states 3mA for a 4.5 Vdd??? Perhaps they mean when supply the PICmicro with 6V and supplying the maximum current to the PICmicro will provide the 25mA I need???
Comparison to Atmel AVR Micro-controller
Secondly, the Atmel AVR 8-bit micro (ATtiny26X) can source 20 mA and thus supply 4.2V (minimum) (from each Pin of Ports A&B) under conditions when the supply to micro is 5V (Vcc). Does this mean, that this particular AVR is better at sourcing current than the PIC?? If we are simply saying each micro is powered by 4.5Vdd (which they are) - Then the PICmicro supplies 3mA at 3.8V; whereas the AVR supplies 20mA at 4.2V.
Its very confusing now. Need some light on why MICROCHIP claim that each I/O port sources 25mA. Mind you, the circuit does work but I do not recollect measuring the source current from each I/O port. I am still sure I have measured the voltage at each pin. But no record of this!
Conclusion
Any light on this topic guys???
Thanks for the previous few threads - very interesting. The whole idea of this circuit was to put it to SLEEP whilst consuming only around 1.1 uA (PICmicro in SLEEP). But, seen as I am about to do these error calculations - i'l have to make assumptions!
RE: PICmicro & I/O Pin
That will give you a fairly clear picture of what happens if you do not load the pin at all (Vcc, obviously) and if you short the pin to Vdd (Vcc/200 ohms = 25 mA if Vcc is 5.0 V).
It will also give you close to the specified Vcc - 0.7 V when you are drawing 3 mA out of the pin (well, that gives you Vcc - 0.6 V, but close enough). There is probably some non-linearity inside the chip.
There are curves showing output voltage vs source and sink current in the data sheet if you want to go into more detail.
Gunnar Englund
www.gke.org
RE: PICmicro & I/O Pin
If you are stuck bobbing in a life raft doing this, let me know I'd be happy to do it. Take me about 30 minutes. Not a problem.
I presume you are going to try using the bridge and A/D in a ratiometric manner to mitigate the lousy voltage regulation?
RE: PICmicro & I/O Pin
I am revising for my medical electronics viva which is on 21st September. It is based on the three project I have done so far. I would appreciate your help in this. Cheers.
I didnt actually think about the I/O power that much at the time I was building the circuit - silly me. Now that I come to think of it - I should have actually tested the I/O port output properly!.
The viva is about 30-45 minutes long and the examiner is a consultant medical physicist specialising in the field of medical electronics instrumentation. Its my final viva before I qualify to work unsupervised in the clinical setting (hospital).
Thanks in advance
Usman
England
UK
RE: PICmicro & I/O Pin
The PIC appears to perform better than the spec reads. (typical) But still about what I'd guess.
Picture worth a thousand words and all, here you go.
Should be an image in this post. If not,
RE: PICmicro & I/O Pin
I am pretty impressed with the results. So my components are powered at about 4.5V being sourced with ~9mA (each of the two ports).
Does this mean that if my Vcc has a tolerance of 2% i.e. a range of 4.9 - 5.1V, the I/O output voltage will not be affected? Or does it mean that the output I/O will be affected by the same amount?? i.e. 2%. So for a Vcc tolerance of +/-2% (5V), the I/O output will be 4.5V (+/-2%)????
I would like to thank you once again for your efforts. Very much appreciated! Cheers :)
Usman
RE: PICmicro & I/O Pin
Oh yes! The output would be directly related to the supply voltage. Same exact shifts.
My notes of dropping Vcc refers to my system's regulator stiffening up with load not some inherent standard tolerance.
If needed one could always run a tiny low head regulator with a pin and design everything to run on a lower voltage..say 4V.
But I still like the idea.
RE: PICmicro & I/O Pin
RE: PICmicro & I/O Pin
That's exactly what I also would do on a rainy day! Good to see that there are still some enthusiasts left on the Earth! Kudos.
Gunnar Englund
www.gke.org
RE: PICmicro & I/O Pin
I like the regulator idea too. Atleast I will have a larger head room for the current over the regulated voltage level say 4V. The work you did is very interesting. Now i am hoping to spend all day Wednesday doing the calculations for the circuit and its limitations. By the way, looking through the PIC reference PIC16C6X...Figure 17-20: IOH vs. VOH (Vdd=5V). I just realised. For source current of 10mA Voh=4.3V (i.e. Vdd-0.7). I cant believe I missed this graph. In fact I was looking at the PIC16C62A section and not PIC16C61 section.Sorry
Malone - I have only come across one aspect close to what you mentioned and that deals with successive operations on the I/O ports. "...The sequence of instructions should be such to allow the pin voltage to stabilise (load dependent) before the next instruction...". The I/O pins are TTL inputs and I couldnt find any graphs in the PIC reference related to I/O port and its transients. I do know however, that any unused pins should be grounded via a resistor (in case these set off the interrupts and also to ensure the PIC consumes <1uA during SLEEP operation). I will have a look at the other datasheets (strain gauge/ADC/IA) with regards to transients. Thanks
Usman
RE: PICmicro & I/O Pin
I powered the MAX232 using a seperate I/O. Assuming I use the data (from the work of Smokey) and say the I/O supplies ~8.8mA and 4.5V. When I did connect this to the MAX232 Vcc, it didnt work. So what I did was use a 100 Ohm resistor in between the I/O and the MAX Vcc. However, this means that if im supplying 8.8mA via a 100 Ohm resistor, the voltage is bearly a volt (0.88V) being supplied to the MAX232. It was working like this. but how can it work if it requires a 5V supply Vcc???
I looked at the MAX232 datasheet, in the maximum absolute ratings for Vcc i.e. -0.3V to +6V. So does this mean, the MAX232 will work in this voltage range? The MAX232 does require 5-10 mA though. A bit confused here. Any help appreciated.
Usman
RE: PICmicro & I/O Pin
100 x 0.0088 = 0.88V Which is of course,
4.4 - 0.9 = 3.5V
You fed the MAX 3.5V. Some RS232 systems work okay with this if you aren't talking fast or far.
I don't off hand see where the 100 Ohms would help anything.
RE: PICmicro & I/O Pin
Thanks for that. Somehow I couldnt get the MAX232 to work straight off the PIC I/O. MAX may be workin due to the low speed. True.
The PIC16C62 does not have a UART. I was using the RC6/RC7 pins (TX/RX) for serial data transmission. But i set the baud rate of 19,200 in the PIC C program. How does the serial transmission work?? By bit-banging in software using the PCM compiler?? Is the UART a software UART???? Dont understand how the serial transmission works on the PIC16C62.
I didnt of course use SPI or I2C (although I was told to use I2C - no time!).
Thanks once again for your valuable time.
Usman
RE: PICmicro & I/O Pin
- The level converter in the MAX232 may generate some noise.
- "Software UART" means you assemble each frame and bit-bang the output. It also means you (over)sample the input and build the incoming words yourself. Start with 300 baud and work your way up.
Mike Halloran
Pembroke Pines, FL, USA
RE: PICmicro & I/O Pin
Thanks for that. I have already developed the kit. The bit-banging bit was left to the C-compiler. I just stated the RS-232 parameters. thats all I did for the PIC. What is bit-banging in short??? (i have checked the net but i still cant understand it! It goes into too much depth-I didnt implement the algorithm myself).
Ta
Usman
RE: PICmicro & I/O Pin
if you make an iteration to your design, you could use a 74ACT245 as a "higher power" output pins IC. Its off state would provide the same zero power consumption, and the ON state could drive much more milliamps with less voltage loss. As a bonus, you can parallel outputs to further reduce the losses.
The comments about the noise generated by the RS232 buffer also mean that the power supply noise of this buffer can backfire into the PIC through the I/O pin used to power the part. It may cause some unexpected behaviour versus your code, because the noise can fool logic levels within the pic. This is something that an external buffer chip would guard the PIC from.
You can also parallel I/O pins on the PIC to reduce this effect, and of course provide some filtering on the lines used as external power pins. I'm sure that you provided some, already.
Felixc
RE: PICmicro & I/O Pin
Thanks for the comments. I spoke to a collegue today and he mentioned the same - parallel outputs. I think its a good idea. The buffer (74ACT245) you mentioned probably is the best method because of the noise from the MAX chip affecting the data line TTLs. Thats probably what caused the problem when i was driving the MAX directly off the I/O. I was seeing the code on the PC but it was all nonsense. Unfortunately I didnt filter the I/O lines! oops. It was early days and was my first electronics project for the training so I was getting used to electronics.
I did manage to do an error calculation today between AD620A and a homebrew 3-opamp IA. After all the calcs, realised what the significant error factors were - namely input offset voltage, resistor matching, input offset voltage drift and the gain drift. I actually didnt even match the resistors in my classic IA - so the error in matching was the same as the resistor error (+/-5%). Perhaps in the next iteration I can ensure errors are minimal, all power lines filtered properly and so forth.
Felix - your thoughts much appreciated. Interesting I could well do with a buffer next time! :)
Usman
RE: PICmicro & I/O Pin
Do you understand RS232 asynchronous signaling?
I woke up with the reason you needed the 100 Ohms (first thought of the day Argh!)
If you hooked that +/- 4V RS232 line to a PC that was belting out maybe +/-12V the MAX was probably feeding some of this overvoltage back into the PIC causing...
RE: PICmicro & I/O Pin
Its a very interesting thought. hmmmmm. Could it be the noise from the MAX232 or could it be the overvoltage from the PC lines???
If your theory is correct smokey, then why did i need a resistor for it to work (without sending garbage)?? Should it not be better without a resistor then?? But then it wasnt working without it!
Also, yes understand Async rs-232 transmission. Start bit...stop bits. using only two lines (Rx and Tx) instead of an extra clock line (for sync transmission). But I am not sure about the software UART - bit-banging. lol thats puzzling me.
Usman
RE: PICmicro & I/O Pin
I have used these buffers for many things, like driving relay coils and speakers/buzzers, with PICs and other micros, in addition to power other circuits. They replace very well discrete transistors with none of the real estate and assembly woes. (if the curent capabilities are okay) If you think of it, these high power inverters are pairs of P-channel and N-channel Mosfets.
You might see a "maximum pin current" specification for the VCC and VDD pins of your PIC. For all these I/O pins that are used to drive things, the current flows through either the Vcc or Vdd pin, so all these currents add up at these pins. The effect can be a breakdown of power supply bond pins on the die, or also a shift of the ground voltage in the die. The latter may fool the reference levels for the high or low levels seen or driven by the PIC.
Bit banging is what you are doing in software to emulate a UART.
I used an AD620 to amplify strain gages, some 12 years ago when the part was just introduced. A nice part.
If the logic lines are supplying a voltage that is a tad too low, if your regulator is adjustable, you can power the PIC at 5.10 or 5.15 volts. It will raise the I/O output levels by the same amount.
Felixc
RE: PICmicro & I/O Pin
As for the TX the software UART just spews the standard Start-data-stop stuff out. The TX is easy compared to the RX.
I vote for over voltage. Noise would mess up your A/D stuff but the digital side will take quite a lot. What it won't take is the digital side being forced to sink a bunch of current flooding in from some PC. Remember the earlier PICs like your's read back the pin not the logic. So if you force a pin high but in fact pull it low, if you subsequently write the pin, you may end up with an un-intended state.(opposite) This requires that sometimes you must put a NOP between reads and writes of PIC pins.
The 100 OHMs limited the current being fed back into the PIC so that it wasn't faulting.
RE: PICmicro & I/O Pin
I worked on a system that wouldn't reset properly because the Vcc never fell low enough with the rs232 i/f connected.
Deep joy on that one...
RE: PICmicro & I/O Pin
Its like midnight here i was about to crash after making notes on LM7XXX series regulators i used on one of the projects. It was recommended by Harrowitz&Hill (the bible for us in our training).
Thanks Smokey. In fact I have used an NOP in my code but i didnt use it in between the output high (Voh) I/O pins. The bit-banging makes a little more sense now. And the 100 Ohm resistor bit - interesting. Il go with over-voltage. it makes more sense now. How can I calculate errors in baud rate??? I know for 19,200bps, the timing accuracy should be better than 1% i.e if the bit time is 52us then +/-0.5us. But how can I calculate the baud rate error? Ive read up the PICmicro ref - it says the baud rate error formula is for an internal clock. Any light on this??
Felix - yeah that what i was thinking for the future projects. To power the PIC with something like 6V and have a very tight tolerance on the voltage - something better than +/-2% (the regulator i used in the work!). I did some initial research on IA and realised that AD620 (very low bias currents!) has been used by many institutions - many papers mentioned this IA. Its the classic type and now has many variants in the AD62X series.
When I was working with MAX232 chip, my supervisor mentioned another line driver that didnt require any external capacitors for pumping/inverting the TTL voltages to RS232 standard. Its the Dallas chip. Pretty neat.
Usman
RE: PICmicro & I/O Pin
do not feed the PIC over its maximum recommended Vdd voltage though. It is not said that the part will not work over this limit, but the manufacturer will not guarantee that anything will work as per the specs. Your present board may work fine at say 5.5 volts, but a PIC from a different date code may not work, or for example its oscillator may never start when the temperature is a bit cold. Things like that.
If the large caps are an issue with the MAX232, there are models that only need 0.1uF caps. Depending on how many I/O lines you need there are smaller packages too. I found the equivalents from Analog Devices to be more affordable, like the ADM202E.
Will you work at a fixed baud rate? Less validation to do...
Felixc
RE: PICmicro & I/O Pin
Yeah, in the future I will keep the Vcc just under 6V (or optimum voltage) ensuring the regulator has a tight tolerance. Also, i'd rather use a Serial driver chip with capacitors inside. less mess really and less noise perhaps. I am working at a fixed baud rate of 19.2 kbps. My clock is set at 4MHz, using an external XT (quartz crystal oscillator). What did u mean by the precision of the clock??? I didnt use any timers so thats why I wanted to calculate the errors in teh serial timing. But dont really know how im going to do that!.
For the serial transmission, I only set the baud rate in software and it started working! Only used two lines TX/RX. I assume the internal compiler software emulated USART does the rest of the job - bit banging algorithm. But if the serial timing bit-time for 19.2kbps is 52us (1/19200), then accuracy should be better than 1%. However, how on earth am i going to calculate the errors in timing??? Guess the serial transmission is using the PIC clock (4MHz) and the crystal oscillator - teh quartz crystal seems accurate - but there must be a way to quantify the timing accuracy. Puzzled.
Usman
RE: PICmicro & I/O Pin
the crystal is so precise that its precision is not even part of the equation for the UART clock precision.
You must find how your compiler creates its own UART emulation in order to know how precise can it be. It should be somewhere in the documentation. A given serial baud rate needs a given bit clock rate. This clock rate is usually obtained using a counter as a divider and then using it as an interrupt generator where the interrupt routine takes cares of the I/O bits. The frequency obtained from the division of the CPU clock will not be exactly the one required for the UART clock. The difference in these clocks is the percentage that you need to calculate. On easy way to clear this source of error is to use a crystal with a frequency that is a multiple of the required serial port frequency. You will find discussions on this matter in the datasheets of the PICs that have integrated UARTs, and that are using a counter-timer as a baud rate generator. But first of all find how does your compiler creates the UART.
Felixc
RE: PICmicro & I/O Pin
Thanks for the posting. The compiler I used for coding C for the PICmicro was the PCM compiler. I have sent CCS (devloping company of the compiler??) a query regarding serial timing and how the software UART is implemented.
Ive tried to download the CCS compiler manual buts its corrupt!!!
ht
Il probably have to wait for CCS to respond now. response time is about 24 hours. lol
Usman
RE: PICmicro & I/O Pin
I have some experience in instrumentation circuit designs for industrial applications, where some of the similar concerns in the environmental use may apply for the setting you describe. For one, it could be desirable to have some level of signal isolation from the sensor, if this is going out of the electronic enclosure, or part of the "field environment" This will come into play for instance if the design has to go through certification testing, and EMI environmental conditions, noise and impulse sources are applied. How much of course in protection will be in the bandwidth of the imput and its associated decoupling and filtering circuits, and the sourcing impedance, to the signal length, and weather its proximally close in the overall device, or goes for some circuital distance (for instance, passing power, or rotary equipment, coil lines, etc).
In this regard, going from a bench simulation environment to the final circuit changes may put you in a position that for sourcing the drive of the sensor, you may want the output to provide the gating signal only, and use a small controlable low drop linear regulator(on off control pin), to source both the strain guage, as well as the front end of the IA, and provide a RLC Filter to reject the undesired harmonic content, as well as giving a good stable source to this "preamp portion". A secondary amp as a simple fallower maybe wanted that has an RC rolloff to reject the other term.
This doesnt sound like the portion you are at in your work in evaluating the circuit, but I figured Id though it in as it can guide the discussion of where you may wind up as it leans more toward a production type of circuit for use in the described setting. This will also effect your desicions on loading of the microcontroller pins. Another aspect, are that field related wiring in the UL class codifications as well as hospital use electronics, you will have to look at what protective level circuits of things going "outside the box" will require. Typically this will encompass clamping circuits to the Current and voltage level specification, which often even require levels of protective redundancy and spacing requirements. On driven load, on instrumentation in, the requiremetns may place that a given impedance network, of discretation of components are isolating the circuit tracework from the fine pitch work of the highly integrated portions. This is often a balance network of things that meet FP fire proof classification rating, or are of a controlled spacing to ensure the Impulse event in a failure analytic or use case does not cause unmitigated circuit harm.
Jeff Mills
EE - formerly of ABB-TBI, RAE systems et seq.
embeddmcu01@hotmail.com