Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations SSS148 on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

PICmicro & I/O Pin 6

Status
Not open for further replies.

UsmanLula

Electrical
Aug 10, 2005
34
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












 
Replies continue below

Recommended for you

Hi Felix

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
 
UsmanLula;

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

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
 
Usman,

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
 
Okay if you understand the protocol then bit banging is simply a software UART instead of a "state machine" UART. The code looks at the RX pin continuously and frequently so that it can reconstruct the serial data's start bits, data, and stop bits. It's not hard, probably 30-50 assembly instructions. A lot of extra bells and whistles can increase the code greatly. Stuff like autobaud detection, multiple speeds.

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.
 
Max232s are wonderful at running off the rs232 volts.

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...
 
Hi guys

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













 
Usman,
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... ;-) What is the precision of you clock source? Are you using an internal counter/timer as an interrupt source for the management of the serial port lines?
Felixc
 
Hey Felix!

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
 
Usman,

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
 
Hi Felix

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!!!


Il probably have to wait for CCS to respond now. response time is about 24 hours. lol

Usman
 
Hello Usman,
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor