Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Somthing Wrong

Status
Not open for further replies.

Eng.Abbasi

New Member
hello all,

i have a small question , i use pic16f877a and get signal from function generator to computer at a certain time (about 640 Hz) , its work ok at first then it begin to display wrong data unless i get the power off from the pic then return it it work probably again then the same problem occur , and another thing i observed it that the computer still get data from the port after the pic is turned off in about 5-6 sec ,
Why these two actioin occur i hope you help me
thnxs
note : i use TIMER1 to set 640 Hz
 
I hate to nit-pick on grammer and language ability but this is a case where I simply do not follow what you are trying to communicate.

From your question it sounds like you are using a PIC to determine the frequency of a signal from a function generator and then displaying that frequency on a PC. In your "note", you go on to say that you use TIMER1 to set 640Hz which has nothing to do with your question.

If you are using your hardware UART and you start having transmission problems over time then the issue must be in your code. Until people can see it, there is no way to know what you might have done wrong.

Depending on the power draw of your circuit and the capacity of the filter/decoupling capacitors of your project, it is quite possible for it to run sever seconds after unplugging the power supply.

Can you restate what your project is with better clarity?
 
Last edited:
phalanx said:
Depending on the power draw of your circuit and the capacity of the filter/decoupling capacitors of your project, it is quite possible for it to run sever seconds after unplugging the power supply.
5 to 6 sec is a verry loooooong time unless you have a huge capacitor.

Another possibility is that his PC software can't catch up with the PIC datarate filling the PC UART buffer.
Once the PIC is powered off, the PC software continue to read from the buffer until it's empty what takes 5 to 6 sec.
 
Eng.Abbasi said:
Works ok at first then it begins to display wrong data...
Something is getting hot. Check Fuction Generator interface to PIC.
Eng.Abbasi said:
Computer still gets data from the port after the PIC is turned off for about 5-6 sec...
The signal from the Function Generator is leaking through other circuits to keep the PIC powered. Again, this is a problem with your interface. You are driving the PIC input too hard. Make the input resistor larger.
 
phalanx said:
From your question it sounds like you are using a PIC to determine the frequency of a signal from a function generator and then displaying that frequency on a PC.
you got it wrong, I say that i have a signal from function generator and i displayed it on the PC using pic16f877a .

phalanx said:
In your "note", you go on to say that you use TIMER1 to set 640Hz which has nothing to do with your question.

i dont write this Information for nothing , i think that its hard for the PC program to keep up with the speed of data out of the pic and so after an interval of time the data was displayed wrong (perhaps i should use multithreating to get the data from the serial port and at the same time plot it on the PC) .

phalanx said:
If you are using your hardware UART and you start having transmission problems over time then the issue must be in your code. Until people can see it, there is no way to know what you might have done wrong.

ok i dont mind , but i tried my software with a constant analog values and its work ok without problems , i'll attach my code.

keithK said:
Something is getting hot. Check Fuction Generator interface to PIC.

i dont think so becuase at the same time i display the signal on oscilloscope and there wasn't any problem.
 

Attachments

  • pic.txt
    2.3 KB · Views: 182
Eng.Abbasi said:
I don't think so because at the same time I display the signal on oscilloscope and there wasn't any problem.

I suspect a problem with grounds. The ground of the Signal Generator, PIC, and PC are at different potentials. Did you tie them together?
You said the PIC sends data for 6 seconds after power off. Why? Find the source of this voltage, and I think you'll find the cause of the other problem.
There is a back-circuit somewhere.
I believe the output of the signal generator has several ma of drive. You power off the PIC, but the power from the Signal Generator leaks back to the +5 of the PIC via it's internal op-amp.
You shouldn't have power to the PIC inputs when +5 is dropped. The high signals will leak back internally in the PIC and keep it powered.
The scenarios above may not be totally accurate, but I'm sure it's something along these lines.
 
Many questions...

keithK said:
You said the PIC sends data for 6 seconds after power off. Why? Find the source of this voltage, and I think you'll find the cause of the other problem.
He didn't said that!
He wrote " ... ... the computer still get data ... ..." but we don't know where the data, after power down the PIC, is coming from.
Is it really from the PIC or is it from the serial comm buffer? We don't know yet!

Put the scope on the RS232 line and check for signals after you power down the PIC. That way you will know if the PIC is still sending, like keithK suggested.

What code is running on your PC? What's your baud rate? How do you send data ASCII, binary?

You wrote that it works fine with constant analog values. That's wierd because software don't care for DC or AC signals unless.......

What's the peak to peak value of the signal from the function generator?
Is it AC or DC?
In case of AC, does the negative alternation goes below 0V, GND level?
Does the PIC like that (I don't know PIC's hardware, shame on me...)

Many questions I know but only then we maybe solve your problem...
 
im sorry for being very late
but after many tries i discovered that the pic has nothing to do with this problem , it's 90% that the problem is from my java program becuase my java class still get data when i turn off the pic and if i measure the output of the pic there is nothing .

so of any one tried before interfacing with serial port by java , i appreciate if he told me

thanks all
 
assuming your java code isn't introducing the mystery data, I suspect you are picking up noise on your serial cable. powered off devices don't usually send data. otherwise, follow msc51mc's advice.
 
Eng.Abbasi said:
... ... when i turn off the pic and if i measure the output of the pic there is nothing .
You placed a scoop on the TXD, RXD lines between PIC and PC and saw nothing at all while your PC still gets data. Is that what you did or did you use a multimeter ?

If you really see a stable 0V signal we can forget the noise thing suggested by Philba.


Eng.Abbasi said:
...so of any one tried before interfacing with serial port by java , i appreciate if he told me thanks all
Never did, always used VB or LabView with 8031 µP, never had problems like yours.



A few new questions. Hopefully you will answer this ones...
1) The data you receive after power down the PIC, is it correct data?
I mean if you generate a square wave, I suppose you get data from which you can rebuild a square wave in your java application, what about the data received while the PIC is powered down? Can you still make a square wave out of it?
If yes, I think that's data stored in a buffer somewhere on the PC side, so nothing to worry about (unless you buffer overflows in time, but that's for later... ...).
If no, Philba's noise thing is back on track or ... ...

2) Can you use Hyperterminal to see if you have the same issues?
 
good suggestion on using a terminal program.

he should also try running the java ap with out the pic connected at all.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top