sht75 code locked up


Closed Thread
Results 1 to 21 of 21
  1. #1
    microkam's Avatar
    microkam Guest

    Unhappy sht75 code locked up

    i recently complete making PCB board which read humidity and temperature from SHT75 sensor,the board contain DS1307,(PIC16f877@4MHz).
    - SHT75 connecting directly to the board through cable sheild 3m long
    - the environment is very noisy and the board locate in the panel which contain a power supply and contacter's , some contacter jop is to turn the heater (3-ph,6KW) on and off .

    First problem :

    i run the system for many hours all things is ok,then the ds1307 start to locking up i solve this problem by code so if the timing is not changed for some time then the cod make a reset for the pic .

    Second problem :

    all the program is locked up,i add a filter on the input supply 220vac , 100nF, no pin's floating , all things as i think is ok
    in the last i found the problem is in the sht75 code , exactly in this code :-
    '''''''''''''''''''''''''''''''''''
    readsensor:
    GoSub tstart
    GoSub WaitSensor

    ShiftOut dta,clk,1,[cmd\8] ' send command
    Input dta ' wait acknowledge
    Low clk
    While dta=1
    Wend
    PulsOut clk,10 ' send ack
    While dta=0
    Wend
    While dta=1 ' wait for conversion to complete
    Wend
    Low clk
    ShiftIn dta,clk,0,[result.highbyte\8] ' get first byte
    Low dta
    PulsOut clk,10 ' send ack
    ShiftIn dta,clk,0,[result.lowbyte\8] ' get second byte
    Low dta
    PulsOut clk,10 ' send ack
    ShiftIn dta,clk,0,[chksum\8] ' get third byte (checksum)
    High dta
    PulsOut clk,10 ' send ack
    Input dta ' End of Transmission
    Input clk

    Return
    '''''''''''''''''''''''''''''''''''''''''''''
    any one have the same problem .......

  2. #2
    microkam's Avatar
    microkam Guest


    Did you find this post helpful? Yes | No

    Post SHIFTIN locked up

    can i make a maximum time to wait the data in SHIFTIN,if the data is not received in this time jump to the error label .

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    There's no TimeOut facility with Shiftin. I have some doubt on your hardware at first but, if you could use the same setup in a 'normal' environement (let's say on your own bench) and confirm that the problem is still the same, we can probably dig deeper in your stuff.

    I see some strange stuff so far... seems to have some missing PAUSE or something, some pins a set Low/High twice, those While/Wend are obscure... If you coulld post your schematic, it could help. Datasheet link, for lazy user like me, could be handy.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    microkam's Avatar
    microkam Guest


    Did you find this post helpful? Yes | No

    Default

    thanx mister to try to solve my problem..
    i run the board in my lap without heater load and it's run for three days and all things is ok , but the problem start when i connected the heater load , maybe the spark in contacter cause error in the command through sensor cabel sheild , that why the program locked up in the last code i attached .

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Possibles causes:
    unsufficient ground plane on your PCB
    unsufficient power supply filtering
    usused input/output left floating
    Ground loop/ground bouncing
    unsufficient incoming data filtering/buffering ( can we say buffering ??? ;D )
    ...
    ...
    ...
    Is your stuff share a power supply or it have it's own?

    You can still additional hardware to Enable and Disable your Contactor on the Zero Crossing of the AC line. It could be done in software too. By using one or the other method, you'll have to adjust the timing to compensate the Contactor latency.

    This should solve a part of your problem.
    Last edited by mister_e; - 1st June 2006 at 16:05.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    microkam's Avatar
    microkam Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e
    Possibles causes:
    unsufficient ground plane on your PCB
    unsufficient power supply filtering
    usused input/output left floating
    Ground loop/ground bouncing
    .
    the power supply is clean as can be , i put the filter ,the ground plane on my PCB i think is good.

    Quote Originally Posted by mister_e
    unsufficient incoming data filtering/buffering ( can we say buffering ??? ;D )
    .
    how can i make filtering for the data incoming from sensor , or how can i solve this problem by code to reset the program if any locked up happend in the sht code.

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Maybe some opto-isolator could help. Is your unit provide the supply to your Sensor? If so, one more possible cause in the basket.

    Cancel ambient noise by software... i would never try/trust something like that. Sure good enough for analog reading, but as your PIC seems to Stuck in real world and not on a bench... review your hardware first. Software can't really avoid ground bouncing, back EMF, ... If something like that could be done.. i certainely buy the stuff and change the Meteo with

    You really should think about the zero crossing stuff i stated before. Better chance to reduce noise, AND increase the contactor contacts lifetime.
    Last edited by mister_e; - 1st June 2006 at 21:07.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8
    microkam's Avatar
    microkam Guest


    Did you find this post helpful? Yes | No

    Arrow

    thanks mister very much for your trying to help me again.

    Quote Originally Posted by mister_e
    You really should think about the zero crossing stuff i stated before. Better chance to reduce noise, AND increase the contactor contacts lifetime
    the load is 3-ph heater, so how can i make zero crossing on 3-ph load !!!

    this error (stuck in sht code) is happened one time every 2-3 days,so at this time i want code to detect any stuck will happen in this code.

    i process some code like that
    Quote Originally Posted by microkam
    While dta=1
    Wend
    i put a maximum time to stay in this loop , over this time the program reset and read the sensor second time >

    the problem here
    Quote Originally Posted by microkam
    ShiftIn dta,clk,0,[result.highbyte\8]
    i cant put a maximum time for this command ..

    any soluation can help me to pass this problem without changing in hardware.

  9. #9
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    I don't see how it could be done if you just have 1 contactor to do the job... but with 3 .. no problem, fire them on each zero crossing should work.

    I know there's some dedicated contactor for that. Google search i guess.

    Melanie should have some pointer on that.

    As i'm not in a familiar area... i can't be too much of help.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  10. #10
    microkam's Avatar
    microkam Guest


    Did you find this post helpful? Yes | No

    Unhappy

    thank you mister very much again.

    but realy i dont know if any body can help me in this point .

  11. #11
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    MisterE - you can't fire a Contactor on Zero-Cross (well you can but it won't do you much good)... think about it, by the time the contacts close, the mechanical lag involved means zero-cross has long gone... and firing the contactor coil at zero cross does a heap of good... a 10W coil is really important when compared with a few kW of Heater...

    Hmmm... since I have several commerical Three-Phase Heating Controllers on the market, I have to tread carefully...

    Firstly, you only need to control TWO out of the three phases (although all three should be fused/protected).

    The easiest (though not the cheapest) solution is to use a zero-cross SSR in two of the phases. All you do is treat the SSR input as if it was an LED. Switch it on, and it does the rest. You will find that Crydom, Carlo Gavazzi (and others) all do Zero-Cross and non-Zero-Cross versions of all their SSR's. Like I said, chose a Zero-Cross version.

    The alternative is to use an opto-isolated "Zero-Cross Triac Driver" to fire your main Triac (which is what I tend to do). An Internet Search will provide you with heaps... MOC3061, MOC3062, TD3043... again treat it as an LED... Don't forget you need one in each of two phases.

    NEVER EVER hang your PIC in a non-isolated circuit when playing with three-phase power. Trust me, you will die - and worst of all you then won't be able to come back and tell us, so I won't be able to say "I told you so!".

  12. #12
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Yeah i knew about the Contactor latency and i stated it on post #5.

    I'd never drived any 3 phase stuff. Even never used any SSR. For all my AC control i use Triac and, of course the Opto-Isolator (zero cross or not depending the day). Yeah also love the KV of insulation.. same for the power supply... never EVER use transformerless.

    Now our friend have more than enough information to solve the problem.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  13. #13
    microkam's Avatar
    microkam Guest


    Did you find this post helpful? Yes | No

    Exclamation

    thanks all again>
    i tryed to put EMI filter on main control supply, but the problem still there, i supplied PIC through shotky diod and put many 100nF capacitor and nothing changed >

    Quote Originally Posted by Melanie
    NEVER EVER hang your PIC in a non-isolated circuit when playing with three-phase power
    what do you mean in a non-isolated circuit ??
    between my PIC and contacter there is an opto-coupler and small relay , the power supply of (opto-coubler transister) is different for my pic power supply with different transformer and different GND , is this the isolation you mean !!

    is the noise from heater contacter make all the problem through main supply or through air to the board ??

    if i take the board supply (220v) from another location and didnt connect it with the same heater supply will solve this noise problem ???
    Last edited by microkam; - 5th June 2006 at 22:54.

  14. #14
    microkam's Avatar
    microkam Guest


    Did you find this post helpful? Yes | No

    Default

    hi Melanie
    Quote Originally Posted by Melanie
    The easiest (though not the cheapest) solution is to use a zero-cross SSR in two of the phases. All you do is treat the SSR input as if it was an LED. Switch it on, and it does the rest. You will find that Crydom, Carlo Gavazzi (and others) all do Zero-Cross and non-Zero-Cross versions of all their SSR's. Like I said, chose a Zero-Cross version.
    i search for this SSR in my country and it's not avilable and it takes over one monthe if i order it..

    so can you explain to me whats exactly the source of this noise!!
    if i seperate control board and power contactor in different panel will reduce the noise >>>

  15. #15
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    >so can you explain to me whats exactly the source of this noise!!

    The meaning of Life, the Universe and Everything I can probably explain. The source of your noise however escapes me. I'm not in your environment, I can't see your design, and I have no test equipment available to track it down - this is something that you can do - because you are there, and I am here.

    I worry about the code that you posted where you say the problem exists. Your While/Wend statements will hang the program until the correct state of the dta pin is recognised. You must track down WHICH of the several WHILE/WENDS is causing your program to hang and then determine WHY dta did not switch as expected. Is it because the PULSEOUT is out of specification and the chip did not acknoledge. Is it because noise on the line is causing the chip to acknowledge at the wrong time or send garbage. You'll have to dig deeper yourself.

    It's unusual for the DS1307 to hang... I have tens of thousands in the field and it's never happened. Check your 5v supply is CLEAN. Make sure the Battery isn't next to a contactor switcing kVA - the usual things...

  16. #16
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    In addition to Melanie, how about if you disconnect all pins of your SHT sensor and bypass it's own code?

    any available schematic?

    How far your SHT sensor is?

    Is your board send the voltage to your sensor?

    How? i mean, is there any buffer between your PCB and your sensor? case not, it's one other possibility of noise source.

    As i already commented about the SHT obscure code but you said it's working on a single bech... i just want to know what's happen when you bypass this section.

    Any PCB layout picture?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  17. #17
    microkam's Avatar
    microkam Guest


    Did you find this post helpful? Yes | No

    Default

    .......jjj

  18. #18
    microkam's Avatar
    microkam Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e
    How far your SHT sensor is?
    Is your board send the voltage to your sensor?
    How? i mean, is there any buffer between your PCB and your sensor? case not, it's one other possibility of noise source.
    sht cable sheild length 3m.
    sht supplied +5v from my PCB without any buffer,and how can i put this buffer ,can you explain more.

    Quote Originally Posted by Melanie
    Is it because noise on the line is causing the chip to acknowledge at the wrong time or send garbage
    i tracked the problem and i found the problem from noise on the line , i tried to replace the sht cable with short one (0.5m) and the noise is cancled >.

    SO . can i run timer on the first sht code and stop it on the end of code , if the timer reached to the maximum time then reset the pic .

    Quote Originally Posted by Melanie
    Make sure the Battery isn't next to a contactor switcing kVA - the usual things...
    should i connect battary to ds1307 , in my pcb i connect battary pin to ground . is this the problem .

  19. #19
    microkam's Avatar
    microkam Guest


    Did you find this post helpful? Yes | No

    Default

    ffff
    joiu

  20. #20
    microkam's Avatar
    microkam Guest


    Did you find this post helpful? Yes | No

    Default

    srtttf
    fgfg

  21. #21
    microkam's Avatar
    microkam Guest


    Did you find this post helpful? Yes | No

    Default

    oooooo
    llll

Similar Threads

  1. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 21:55
  2. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  3. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  5. Re-Writing IF-THEN-AND-ENDIF code?
    By jessey in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 18th August 2006, 17:23

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts