Need some advice.


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1
    Join Date
    Apr 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Default

    thanks for your reply s. here is a piece of software I'm using just to see if I can get it working without the flicker of when temp hits 5000 and 10000, so far failed, I'm using a moc 3021 and a bt137 and bridge with a 1k feeding porta.0 and a 10k holding it low. I have been able to make a simple dimming program so I know this hardware works, I also have an lcd so I need a few more io that a 12f675
    Code:
    Define LCD_DREG PORTB
     'Set starting data bit
     Define LCD_DBIT 4 'rb4,rb5,rb6,rb7
     'Set LCD RS Port
     DEFINE LCD_RSREG portb
     'Set LCD RS Bit
     define LCD_RSBIT 3
     'Set LCD Enable Port
     Define LCD_EREG portb
     'Set LCD Enable Bit
     Define LCD_EBIT 2
     'Set number of LCD Lines
     Define LCD_LINES 2
     'Set Command Delay time in uS
     define LCD_COMMANUS 2000
     'Set Data delay time in uS
     define LCD_DATAUS 50
    
    temp var word
    temp = 0
    temp2 var word
    target var word
    target = 3000
    symbol fire = portb.1
    symbol ac = portb.0
    
    maxdelay var word
    maxdelay = 8000
    
    delay var word
    delay = 4000
    
    trisa = %00000011
    trisb = %00000001
    
    DQ	VAR	PORTa.0			' One-wire data pin
    temperature VAR	WORD			' Temperature storage
    count_remain VAR BYTE			' Count remaining
    count_per_c VAR	BYTE
    
    DS18B20_9bit CON %00011111 ; 93.75ms, 0.5°C
    DS18B20_10bit CON %00111111 ; 187.5ms, 0.25°C <-- My favorite
    DS18B20_11bit CON %01011111 ; 375ms, 0.125°C
    DS18B20_12bit CON %01111111 ; 750ms, 0.0625°C (default)
    
    OWOUT DQ, 1, [$CC, $4E, 0, 0, DS18B20_11bit]
     
    
    
    lcdout 254,1
    pause 100
    
    on interrupt goto firetriac
    intcon = %10010000
    
    mainloop:
    for temp = 0 to 10000
    if temp = 5000 then
    gosub startcon
    endif
    if temp = 10000 then
    gosub readtemp
    endif
    next temp
    goto mainloop 
    
    
    
    
    disable
    firetriac:
    pauseus  delay
    fire = 1
    pauseus 10
    fire = 0
    intcon.1 = 0
    resume
    enable
    
    startcon:
    OWOut DQ, 1, [$CC, $44]       ' Start temperature conversion
    return
    readtemp:
    
    
    waitloop: OWIn DQ, 4, [count_remain]	' Check for still busy converting
    	IF count_remain = 0 Then mainloop    'was this what you ment about no waiting in the 'loop
    
    	OWOut DQ, 1, [$CC, $BE]		' Read the temperature
            OWIn DQ, 0, [temperature.LOWBYTE, temperature.HIGHBYTE, Skip 4, count_remain, count_per_c]
    
    	' Calculate temperature in degrees C to 2 decimal places (not valid for negative temperature)
    	temperature = (temperature >> 1)
    
    	lcdout 254,1, dec temperature / 10 ,".", dec1 temperature , " c" 
        lcdout 254,192, dec delay 
    
    return

  2. #2
    Join Date
    Apr 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Default

    what I want to do over all is to dim an incandescent light depending what temperature it is without an annoying flicker while fetching the temp.

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


    Did you find this post helpful? Yes | No

    Default

    You may try to switch to asm interrupt or Darrel's instant interrupt to see if it works better.

    A real schematic would help...

    To generate 10uSec with PAUSEUS, you need at least a 10MHz crystal. If you're using a 4MHz, you'll need to use asm NOP or GOTO

    A scope is handy for those things. 1 channel on the Main AC, the other on the PIC output... now you see if you're really in-synch. Be careful if you do that, unless we might see some smoke messages
    Last edited by mister_e; - 28th April 2008 at 05:36.
    Steve

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

  4. #4
    Join Date
    Apr 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Default

    my interup seems to work fine it just that the owin owout commands seem to really take alot of time and the interupts are missed in the process. i'll try to draw up a schematic.

  5. #5
    Join Date
    Apr 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Default

    here is a quick diagram, I know thats not a moc3021

  6. #6
    Join Date
    Apr 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Default

    here abit smaller
    Attached Images Attached Images  

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by cphillips82 View Post
    my interup seems to work fine it just that the owin owout commands seem to really take alot of time and the interupts are missed in the process. i'll try to draw up a schematic.
    This is why i've suggested to use Darrel's instant interrupts
    Steve

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

  8. #8
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Talking Why making it simple ???

    Hi,

    The MOC 3041 ( and not 3021 ...) permitted to avoid all the zero detection AND the interrupts ...

    burst mode is really not a problem with heating systems ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  9. #9
    Join Date
    Apr 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Angry

    not too sure what you mean "burst mode" is that like on 1 sec off 4 secon = 20% heat?. I'll try instant interupt but I'm a little affraid of asm..... I hate it!

Similar Threads

  1. Advice on Wiegand Buffer
    By brutc001 in forum Schematics
    Replies: 0
    Last Post: - 19th December 2009, 01:31
  2. Need "PIC16F84A" Controler schematic Advice...
    By Kyo_89 in forum Schematics
    Replies: 1
    Last Post: - 28th May 2009, 00:03
  3. Your OTP advice?
    By truvahorse in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 28th June 2008, 17:37
  4. Decoding an incoming infrared signal: need advice
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 9th May 2008, 17:28
  5. Advice needed on 'neat' Project!
    By vacpress in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th February 2007, 07:21

Members who have read this thread : 0

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